我正在使用 xsd2code VS 插件从几个 xsd 文件创建一些数据类,但我遇到了一个问题,即 XSD 中元素的命名空间前缀没有出现在生成的 XML 文件中。
XSD:
<xsd:complexType name="ProductMasterItemType">
<xsd:sequence>
<xsd:element ref="cmn:PrimaryItemCode"/>
<xsd:element ref="cmn:NewPrimaryItemCode" minOccurs="0"/>
<xsd:element ref="cmn:ProductGroupCode"/>
<xsd:element ref="cmn:ProductStatus"/>
<xsd:element ref="cmn:EffectiveDate" minOccurs="0"/>
<xsd:element ref="cmn:RecordStatus"/>
<xsd:element name="AlternateItemCodes"
type="cmn:AlternateItemCodeListType"
minOccurs="0"/>
<xsd:element name="TargetMarketList"
type="mdx:TargetMarketListType"
minOccurs="0"/>
<xsd:element name="ItemInfoList"
type="mdx:ItemInfoListType"/>
<xsd:element name="PackagingInfoList"
type="mdx:PackagingInfoListType"
minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
生成的 XML:
<ProductMasterItem>
<PrimaryItemCode xmlns="urn:tracelink:mapper:sl:mdx:commontypes">
<type>INTERNAL_MATERIAL_CODE</type>
TestBOM5
</PrimaryItemCode>
<ProductGroupCode xmlns="urn:tracelink:mapper:sl:mdx:commontypes"
>100</ProductGroupCode>
<ProductStatus xmlns="urn:tracelink:mapper:sl:mdx:commontypes"
>Released</ProductStatus>
<RecordStatus xmlns="urn:tracelink:mapper:sl:mdx:commontypes"
>Active</RecordStatus>
<TargetMarketList>
<TargetMarket>
<CountryMarket
xmlns="urn:tracelink:mapper:sl:mdx:commontypes"
>US</CountryMarket>
</TargetMarket>
<DeleteTargetMarket/>
</TargetMarketList>
<ItemInfoList>
<ItemInfo>
<LanguageCode xmlns="urn:tracelink:mapper:sl:mdx:commontypes"
>EN</LanguageCode>
<ProductDescription
xmlns="urn:tracelink:mapper:sl:mdx:commontypes"
>Test BOM 5</ProductDescription>
<DrugName xmlns="urn:tracelink:mapper:sl:mdx:commontypes"
>Nameofadrug</DrugName>
<Manufacturer xmlns="urn:tracelink:mapper:sl:mdx:commontypes"
>- No Manufacturer -</Manufacturer>
<Strength xmlns="urn:tracelink:mapper:sl:mdx:commontypes"
>verystrong</Strength>
<DosageForm xmlns="urn:tracelink:mapper:sl:mdx:commontypes"
>15ml</DosageForm>
<PackageSize xmlns="urn:tracelink:mapper:sl:mdx:commontypes"
>40ml</PackageSize>
</ItemInfo>
<DeleteItemInfo/>
</ItemInfoList>
生成的 XML 没有元素的“cmn”命名空间前缀。运行插件时是否错误地生成了类?这是我需要在插件源代码中更改的内容吗?
我没有很多使用 XML 的经验,因此如果信息不足,我深表歉意。如果我遗漏了您需要知道以帮助回答的内容,请告诉我!提前致谢 :)