xml - 如何从 xsd 中的 xml 定义 xmlns:ns2
问题描述
我正在尝试从 XML 文件创建 XSD。xml 中的根元素的命名空间为
<POSLog xmlns="http://www.nrf-arts.org/IXRetail/namespace/">
现在其中一个子元素出现为
<SequenceNumber xmlns:ns2="http://www.nrf-arts.org/IXRetail/namespace/" xmlns="">1</SequenceNumber>
当我使用我的 XSD 文件验证 XML 时,它无法识别 SequenceNumber 元素。我的 XSD 有以下定义
<xs:schema xmlns:tns="http://www.nrf-arts.org/IXRetail/namespace/" elementFormDefault="qualified" targetNamespace="http://www.nrf-arts.org/IXRetail/namespace/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import />
我该如何解决这个问题?由于我是接收文件的下游应用程序,因此无法修改 XML。
编辑:添加我要解析的 xml。我有几个其他示例文件。目标是根据示例 xml 创建一个 xsd。xsd 将用于在注入之前验证 xml。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<POSLog xmlns="http://www.nrf-arts.org/IXRetail/namespace/">
<Transaction TrainingModeFlag="false" TypeCode="RETAIL_AUTH">
<WorkstationID>25</WorkstationID>
<SequenceNumber>1</SequenceNumber>
<TransactionID>CA00001055</TransactionID>
<OperatorID AssociateID="3333"/>
<CurrencyCode>CAD</CurrencyCode>
<ReceiptDateTime TypeCode="RefundExpiry">2021-08-28T21:32:55.000Z</ReceiptDateTime>
<CustomerOrderTransaction OrderChannel="IN_STORE" TypeCode="Transaction" TransactionStatus="RETAIL_AUTH" CartID="CA00001055">
<LineItem>
<Sale ProductClass="Merchandise" FulfillmentType="IN_STORE" OrderItemID="2">
<Associate>
<AssociateID AssociateID="3333" OperatorType="SalesAssociateID"/>
</Associate>
<Tax TaxClass="BPTX" LineItemTotalTax="true">
<TaxableAmount/>
<Amount>52.00</Amount>
</Tax>
<Tax TaxType="STATE" TaxCode="CA-STATE-ON-ANY" TaxName="HST" TaxClass="BPTX" LineItemTotalTax="false">
<TaxableAmount/>
<Amount>52.00</Amount>
<Percent>13</Percent>
<TaxPerUnitAmount>26.00</TaxPerUnitAmount>
</Tax>
<Item>
<ItemID Name="Copper Amino Isolate Serum 5.00%">copper-amino-isolate-serum-5pct-15ml</ItemID>
<POSIdentity POSIDType="GTIN">
<POSItemID>769915150070</POSItemID>
</POSIdentity>
<RegularSalesUnitPrice>200.00</RegularSalesUnitPrice>
<ActualSalesUnitPrice>200.00</ActualSalesUnitPrice>
<ExtendedAmount>400.00</ExtendedAmount>
<DiscountAmount/>
<Quantity>2</Quantity>
</Item>
</Sale>
<SequenceNumber xmlns:ns2="http://www.nrf-arts.org/IXRetail/namespace/" xmlns="">1</SequenceNumber>
</LineItem>
<LineItem>
<Sale ProductClass="Merchandise" FulfillmentType="IN_STORE" OrderItemID="1">
<Associate>
<AssociateID AssociateID="3333" OperatorType="SalesAssociateID"/>
</Associate>
<Tax TaxClass="BPTX" LineItemTotalTax="true">
<TaxableAmount/>
<Amount>6.24</Amount>
</Tax>
<Tax TaxType="STATE" TaxCode="CA-STATE-ON-ANY" TaxName="HST" TaxClass="BPTX" LineItemTotalTax="false">
<TaxableAmount/>
<Amount>6.24</Amount>
<Percent>13</Percent>
<TaxPerUnitAmount>2.08</TaxPerUnitAmount>
</Tax>
<Item>
<ItemID Name="Pore Delete">finisher-poredelete-30ml</ItemID>
<POSIdentity POSIDType="GTIN">
<POSItemID>769915130393</POSItemID>
</POSIdentity>
<RegularSalesUnitPrice>16.00</RegularSalesUnitPrice>
<ActualSalesUnitPrice>16.00</ActualSalesUnitPrice>
<ExtendedAmount>48.00</ExtendedAmount>
<DiscountAmount/>
<Quantity>3</Quantity>
</Item>
</Sale>
<SequenceNumber xmlns:ns2="http://www.nrf-arts.org/IXRetail/namespace/" xmlns="">2</SequenceNumber>
</LineItem>
<LineItem>
<Tender TenderType="CreditCard">
<Amount>506.24</Amount>
<Authorization>
<ReferenceNumber>853598650372859C</ReferenceNumber>
</Authorization>
<CreditDebit CardType="mc">
<PrimaryAccountNumber Cryptogram="PARTIAL_DATA"/>
</CreditDebit>
</Tender>
<SequenceNumber xmlns:ns2="http://www.nrf-arts.org/IXRetail/namespace/" xmlns="">3</SequenceNumber>
</LineItem>
<LineItem>
<Tax xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ItemTaxType">
<TaxableAmount>448.00</TaxableAmount>
<Amount>58.24</Amount>
</Tax>
<SequenceNumber xmlns:ns2="http://www.nrf-arts.org/IXRetail/namespace/" xmlns="">4</SequenceNumber>
</LineItem>
<Delivery>
<Address AddressType="Delivery">
<AddressLine></AddressLine>
<AddressLine/>
<City></City>
<Territory TypeCode="STATE"></Territory>
<PostalCode></PostalCode>
<Country></Country>
</Address>
</Delivery>
<Customer AlternateCustomerID="C-0000000039">
<CustomerID>0016s000003ZC2KAAW</CustomerID>
<EMail>
<EMailAddress>shi@deciem.com</EMailAddress>
</EMail>
</Customer>
</CustomerOrderTransaction>
<TillID>3333</TillID>
<BusinessDayDate>2020-08-28Z</BusinessDayDate>
<BeginDateTime>2020-08-28T21:32:55.000Z</BeginDateTime>
<EndDateTime>2020-08-28T21:32:55.000Z</EndDateTime>
</Transaction>
</POSLog>
解决方案
推荐阅读
- java - Java 程序未进入 if 语句
- c++ - c++,我正在制作一个程序来计算一个字母在文件中出现的次数
- alloy - 找不到名称“div”...嗯?为什么?
- django - 更改最终用户的 postgres 密码
- python - 将 PyCharm 交互式 shell 中的最后一个命令移动到脚本
- acumatica - 折扣百分比或价格的一般查询
- google-sheets-api - 来自 Ruby 的 Google Sheets_V4 API:如何获取命名范围的_spreadsheet_values
- optaplanner - optaplanner 结果均匀分布
- php - 从数据库加载当前用户
- database - 在不影响性能的情况下访问数据库的选项