我正在使用xsd插件从几个xsd2code文件创建一些数据类,并且我遇到了一个问题,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的经验,所以如果这不是足够的信息,我很抱歉。如果我遗漏了一些你需要知道的东西来帮助回答,让我知道!提前感谢:)
发布于 2014-12-28 05:29:46
schema元素有一个名为elementFormDefault的属性,该属性确定复杂类型的本地元素是否符合名称空间。缺省值是'unqualified',这意味着您的元素AlternateItemCodes、TargetMarketList等根本不是名称空间限定的。如果将该值更改为“qualified”,则本地元素位于模式文档的目标名称空间中,即位于由xsd:schema的targetNamespace属性标识的名称空间中。
从您的示例中可以看出,您可能没有模式的目标名称空间,并且您可能希望复杂类型的名称空间由元素采用;但事实并非如此。
https://stackoverflow.com/questions/27662790
复制相似问题