gpt4 book ai didi

XSLT:xsi:schemaLocation 未显示在 XML 上

转载 作者:行者123 更新时间:2023-12-01 05:53:12 31 4
gpt4 key购买 nike

我正在尝试进行转换,但我遇到了 xsi:schemaLocation 未显示在 XML 结果上的问题。我已经搜索了为什么会发生这种情况,但我似乎无法找到它。请帮忙

输入 XML

<asx:abap version="1.0" xmlns:asx="http://www.sap.com/abapxml">
<asx:values>
<_--5CCLASS_--3DZCL_T4_NOM_--5CTYPE_--3DTT_SAP_REQ>
<item>
<TECHNICAL_KEY>00006000000000326391</TECHNICAL_KEY>
<TSCARRIER>CPL</TSCARRIER>
<MATERIAL>V2</MATERIAL>
<PIPELINE_CYCLE>45</PIPELINE_CYCLE>
<PIPELINE_SEQUENCE>1</PIPELINE_SEQUENCE>
<CYCLE_YEAR>2012</CYCLE_YEAR>
<SCD/>
<NOM_NUMBER>CITV2451</NOM_NUMBER>
<DATE_TIME>2012-06-20T00:00:00</DATE_TIME>
<CREATE_DATE_TIME>2012-06-06T18:01:18</CREATE_DATE_TIME>
<TOTAL_ITEMS>1 </TOTAL_ITEMS>
<T4NOMNR/>
<ITEM_NUMBER>0000000010</ITEM_NUMBER>
<ITEM_DETAIL_CHANGE_CODE/>
<PIPELINE_EVENT>Delivery</PIPELINE_EVENT>
<PIPELINE_EVENT_AFFECT>Decrease</PIPELINE_EVENT_AFFECT>
<QUANTITY>25000.00</QUANTITY>
<UOM>BR</UOM>
<LOCATION>AHT</LOCATION>
<LOCATION_PARTNER>AHT</LOCATION_PARTNER>
<CONTRACT_PARTNER/>
<SUPPLIER/>
<TANKAGE_PARTNER>KM1</TANKAGE_PARTNER>
<CONSIGNEE_PARTNER>CIT</CONSIGNEE_PARTNER>
<CONS_SUPPLIER>Consignee</CONS_SUPPLIER>
<TRANSPURIND>Add</TRANSPURIND>
<VERSION>1</VERSION>
<PARTROLEIND>Shipper</PARTROLEIND>
<SHIPPARTID>CIT</SHIPPARTID>
<PART_IDENTIFIER>AssignedByCarrier</PART_IDENTIFIER>
<PROD_IDENTIFIER>AssignedByMarketplace</PROD_IDENTIFIER>
<PART_TANKAGE>Tankage</PART_TANKAGE>
<CARRIER_STRING>Carrier</CARRIER_STRING>
<SHIPNOMNRSTRING>ShipperNominationNumber</SHIPNOMNRSTRING>
</item>
</_--5CCLASS_--3DZCL_T4_NOM_--5CTYPE_--3DTT_SAP_REQ>
</asx:values>

XSLT 代码
    <?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.api.org/pidXML/v1.2" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pidx="http://www.api.org/pidXML/v1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.api.org/pidXML/v1.2 https://www.transport4.com/xml/schemas/PipelineNominationCreateV1-3.xsd">
<xsl:template match="/">
<xsl:element name="pidx:PipelineNominationCreate">
<xsl:attribute name="pidx:documentIdentifier"><xsl:value-of select="//TECHNICAL_KEY"/></xsl:attribute>
<xsl:attribute name="pidx:transactionPurposeIndicator"><xsl:value-of select="//TRANSPURIND"/></xsl:attribute>
<xsl:attribute name="pidx:version"><xsl:value-of select="//VERSION"/></xsl:attribute>
<xsl:element name="pidx:PipelineNominationCreateProperties">
<xsl:element name="pidx:CreatedByPartner">
<xsl:element name="pidx:PartnerInformation">
<xsl:attribute name="partnerRoleIndicator"><xsl:value-of select="//PARTROLEIND"/></xsl:attribute>
<xsl:element name="pidx:PartnerIdentifier">
<xsl:attribute name="partnerIdentifierIndicator"><xsl:value-of select="//PART_IDENTIFIER"/></xsl:attribute>
<xsl:value-of select="//SHIPPARTID"/>
</xsl:element>
</xsl:element>
<xsl:element name="pidx:EventDateTime">
<xsl:value-of select="//CREATE_DATE_TIME"/>
</xsl:element>
</xsl:element>
<xsl:element name="pidx:PartnerInformation">
<xsl:attribute name="partnerRoleIndicator"><xsl:value-of select="//PARTROLEIND"/></xsl:attribute>
<xsl:element name="pidx:PartnerIdentifier">
<xsl:attribute name="partnerIdentifierIndicator"><xsl:value-of select="//PART_IDENTIFIER"/></xsl:attribute>
<xsl:value-of select="//SHIPPARTID"/>
</xsl:element>
</xsl:element>
<xsl:element name="pidx:PartnerInformation">
<xsl:attribute name="partnerRoleIndicator"><xsl:value-of select="//CARRIER_STRING"/></xsl:attribute>
<xsl:element name="pidx:PartnerIdentifier">
<xsl:attribute name="partnerIdentifierIndicator"><xsl:value-of select="//PART_IDENTIFIER"/></xsl:attribute>
<xsl:value-of select="//TSCARRIER"/>
</xsl:element>
</xsl:element>
<xsl:element name="pidx:ProductInformation">
<xsl:element name="pidx:ProductIdentifier">
<xsl:attribute name="assigningOrganization"><xsl:value-of select="//PROD_IDENTIFIER"/></xsl:attribute>
<xsl:value-of select="//MATERIAL"/>
</xsl:element>
</xsl:element>
<xsl:element name="pidx:PipelineCycle">
<xsl:value-of select="//PIPELINE_CYCLE"/>
</xsl:element>
<xsl:element name="pidx:PipelineCycleYear">
<xsl:value-of select="//CYCLE_YEAR"/>
</xsl:element>
<xsl:element name="pidx:PipelineSequence">
<xsl:value-of select="//PIPLELINE_SEQUENCE"/>
</xsl:element>
<xsl:element name="pidx:PipelineSCD">
<xsl:value-of select="//SCD"/>
</xsl:element>
<xsl:element name="pidx:ReferenceInformation">
<xsl:attribute name="referenceInformationIndicator"><xsl:value-of select="//SHIPNOMNRSTRING"/></xsl:attribute>
<xsl:element name="pidx:ReferenceNumber">
<xsl:value-of select="//NOM_NUMBER"/>
</xsl:element>
<xsl:element name="pidx:Description">
</xsl:element>
</xsl:element>
</xsl:element>
<xsl:element name="pidx:PipelineNominationCreateDetails">
<xsl:for-each select="//item">
<xsl:element name="pidx:PipelineNominationCreateLineItem">
<xsl:element name="pidx:LineItemNumber">
<xsl:value-of select="ITEM_NUMBER"/>
</xsl:element>
<xsl:element name="pidx:LineItemNominationQuantity">
<xsl:element name="pidx:Quantity">
<xsl:value-of select="QUANTITY"/>
</xsl:element>
<xsl:element name="pidx:UnitOfMeasureCode">
<xsl:value-of select="UOM"/>
</xsl:element>
</xsl:element>
<xsl:element name="pidx:PartnerInformation">
<xsl:attribute name="partnerRoleIndicator"><xsl:value-of select="CONS_SUPPLIER"/></xsl:attribute>
<xsl:element name="pidx:PartnerIdentifier">
<xsl:attribute name="partnerIdentifierIndicator"><xsl:value-of select="//PART_IDENTIFIER"/></xsl:attribute>
<xsl:value-of select="CONSIGNEE_PARTNER"/>
</xsl:element>
</xsl:element>
<xsl:element name="pidx:PartnerInformation">
<xsl:attribute name="partnerRoleIndicator"><xsl:value-of select="PART_TANKAGE"/></xsl:attribute>
<xsl:element name="pidx:PartnerIdentifier">
<xsl:attribute name="partnerIdentifierIndicator"><xsl:value-of select="//PART_IDENTIFIER"/></xsl:attribute>
<xsl:value-of select="TANKAGE_PARTNER"/>
</xsl:element>
</xsl:element>
<xsl:element name="pidx:ScheduleStartDateTime">
<xsl:value-of select="DATE_TIME"/>
</xsl:element>
<xsl:element name="pidx:ScheduleRequestDateTime">
</xsl:element>
<xsl:element name="pidx:PipelineEventInformation">
<xsl:element name="pidx:PipelineEvent">
<xsl:value-of select="PIPELINE_EVENT"/>
</xsl:element>
<xsl:element name="pidx:PipelineEventVolumeAffect">
<xsl:value-of select="PIPELINE_EVENT_AFFECT"/>
</xsl:element>
</xsl:element>
<xsl:element name="pidx:CustodyLocationInformation">
<xsl:element name="pidx:CustodyLocationIdentifier">
<xsl:attribute name="identifierIndicator"><xsl:value-of select="//PART_IDENTIFIER"/></xsl:attribute>
<xsl:value-of select="LOCATION_PARTNER"/>
</xsl:element>
</xsl:element>
<xsl:element name="pidx:ReferenceInformation">
<xsl:attribute name="referenceInformationIndicator">
</xsl:attribute>
<xsl:element name="pidx:ReferenceNumber">
</xsl:element>
<xsl:element name="pidx:Description">
</xsl:element>
</xsl:element>
<xsl:element name="pidx:Comment">
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
<xsl:element name="pidx:PipelineNominationCreateSummary">
<xsl:element name="pidx:TotalLineItems">
<xsl:value-of select="//TOTAL_ITEMS"/>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

结果 XML 缺少 schemaLocation
    <?xml version="1.0" encoding="iso-8859-1"?>
<pidx:PipelineNominationCreate xmlns:pidx="http://www.api.org/pidXML/v1.2" xmlns="http://www.api.org/pidXML/v1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" pidx:documentIdentifier="00006000000000326391" pidx:transactionPurposeIndicator="Add" pidx:version="1">
<pidx:PipelineNominationCreateProperties>
<pidx:CreatedByPartner>
<pidx:PartnerInformation partnerRoleIndicator="Shipper">
<pidx:PartnerIdentifier partnerIdentifierIndicator="AssignedByCarrier">CIT</pidx:PartnerIdentifier>
</pidx:PartnerInformation>
<pidx:EventDateTime>2012-06-07T15:55:35</pidx:EventDateTime>
</pidx:CreatedByPartner>
<pidx:PartnerInformation partnerRoleIndicator="Shipper">
<pidx:PartnerIdentifier partnerIdentifierIndicator="AssignedByCarrier">CIT</pidx:PartnerIdentifier>
</pidx:PartnerInformation>
<pidx:PartnerInformation partnerRoleIndicator="Carrier">
<pidx:PartnerIdentifier partnerIdentifierIndicator="AssignedByCarrier">CPL</pidx:PartnerIdentifier>
</pidx:PartnerInformation>
<pidx:ProductInformation>
<pidx:ProductIdentifier assigningOrganization="AssignedByMarketplace">V2</pidx:ProductIdentifier>
</pidx:ProductInformation>
<pidx:PipelineCycle>45</pidx:PipelineCycle>
<pidx:PipelineCycleYear>2012</pidx:PipelineCycleYear>
<pidx:PipelineSequence/>
<pidx:PipelineSCD/>
<pidx:ReferenceInformation referenceInformationIndicator="ShipperNominationNumber">
<pidx:ReferenceNumber>CITV2451</pidx:ReferenceNumber>
<pidx:Description/>
</pidx:ReferenceInformation>
</pidx:PipelineNominationCreateProperties>
<pidx:PipelineNominationCreateDetails>
<pidx:PipelineNominationCreateLineItem>
<pidx:LineItemNumber>0000000010</pidx:LineItemNumber>
<pidx:LineItemNominationQuantity>
<pidx:Quantity>25000.0</pidx:Quantity>
<pidx:UnitOfMeasureCode>BR</pidx:UnitOfMeasureCode>
</pidx:LineItemNominationQuantity>
<pidx:PartnerInformation partnerRoleIndicator="Consignee">
<pidx:PartnerIdentifier partnerIdentifierIndicator="AssignedByCarrier">CIT</pidx:PartnerIdentifier>
</pidx:PartnerInformation>
<pidx:PartnerInformation partnerRoleIndicator="Tankage">
<pidx:PartnerIdentifier partnerIdentifierIndicator="AssignedByCarrier">KM1</pidx:PartnerIdentifier>
</pidx:PartnerInformation>
<pidx:ScheduleStartDateTime>2012-06-20T00:00:00</pidx:ScheduleStartDateTime>
<pidx:ScheduleRequestDateTime/>
<pidx:PipelineEventInformation>
<pidx:PipelineEvent>Delivery</pidx:PipelineEvent>
<pidx:PipelineEventVolumeAffect>Decrease</pidx:PipelineEventVolumeAffect>
</pidx:PipelineEventInformation>
<pidx:CustodyLocationInformation>
<pidx:CustodyLocationIdentifier identifierIndicator="AssignedByCarrier">AHT</pidx:CustodyLocationIdentifier>
</pidx:CustodyLocationInformation>
<pidx:ReferenceInformation referenceInformationIndicator="">
<pidx:ReferenceNumber/>
<pidx:Description/>
</pidx:ReferenceInformation>
<pidx:Comment/>
</pidx:PipelineNominationCreateLineItem>
</pidx:PipelineNominationCreateDetails>
<pidx:PipelineNominationCreateSummary>
<pidx:TotalLineItems>1 </pidx:TotalLineItems>
</pidx:PipelineNominationCreateSummary>
</pidx:PipelineNominationCreate>

任何帮助,将不胜感激。

谢谢!

最佳答案

您已经在 XSLT 文档中定义了 xsi:schemaLocation,但是您没有尝试在 XSLT 中的任何地方在 XML 文档中创建它。它不会自动添加到您的输出文档中。您将需要创建它。

您可以像这样从 XSLT 文档中复制 xsi:schemaLocation 属性:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns="http://www.api.org/pidXML/v1.2"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:pidx="http://www.api.org/pidXML/v1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.api.org/pidXML/v1.2 https://www.transport4.com/xml/schemas/PipelineNominationCreateV1-3.xsd">
<xsl:template match="/">
<xsl:element name="pidx:PipelineNominationCreate">
<xsl:copy-of select="document('')/*/@xsi:schemaLocation"/>

关于XSLT:xsi:schemaLocation 未显示在 XML 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10940541/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com