C# XSD2代码和xmldsig
我在使用Xsd2Code从xsd生成代码时遇到问题。xsd如下所示:C# XSD2代码和xmldsig,c#,xsd,xsd2code,xml-dsig,C#,Xsd,Xsd2code,Xml Dsig,我在使用Xsd2Code从xsd生成代码时遇到问题。xsd如下所示: <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:ns1="urn:oasis:names:specification:ubl:schema:xsd:CountryIdentificationCode-1.0" xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:Lo
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:ns1="urn:oasis:names:specification:ubl:schema:xsd:CountryIdentificationCode-1.0"
xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:LocationIdentificationCode-1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig.xsd" />
.......
</xs:schema>
错误发生在这里:
[System.Xml.Serialization.XmlTextAttribute(DataType = "base64Binary")]
public byte[] Value
{
get
{
return this.valueField;
}
set
{
this.valueField = value;
}
}
事件,如果我将该属性更改为:
[System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")]
…我得到了其他错误:
Type of choice identifier 'ItemsElementName' is inconsistent with type of 'Items'.
Please use array of System.Collections.Generic.List`1[[MyXSD.ItemsChoiceType2, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].
有人成功地将XSD2代码与xmldsig一起使用了吗?如果可能的话,我宁愿使用XSD2CodeGenerator解决这个问题,而不是手动解决。还有其他选择吗?您是否尝试只使用xsd.exe?(http://msdn.microsoft.com/fr-fr/library/x6c1kb0s%28v=vs.80%29.aspx)
你能用失败的xsd代码的一部分更新你的问题吗?问题是文件顶部的DOCTYPE定义
<!DOCTYPE schema
[
<!ATTLIST schema
xmlns:ds CDATA #FIXED "http://www.w3.org/2000/09/xmldsig#">
<!ENTITY dsig 'http://www.w3.org/2000/09/xmldsig#'>
<!ENTITY % p ''>
<!ENTITY % s ''>
]>
]>
注释掉这个,代码生成就可以了。2009年向xsd2code报告了此问题:。它似乎仍然是一个未解决的问题。在Xsd2Code选项中,将选项“CollectionObject Type”设置为“Array”而不是“List”。有问题的代码是从xmldsig.xsd生成的。我猜问题在于Xsd2Code Generator中的初始化字段和/或使用列表而不是数组。如果您尝试使用基本的xsd.exe生成类,那么您可以比较输出并更好地找出问题所在,因为您将获得更多信息。不知道3个月后您是否仍然关心,但如果您这样做,能否提供正在运行的xsd2code命令行?
<!DOCTYPE schema
[
<!ATTLIST schema
xmlns:ds CDATA #FIXED "http://www.w3.org/2000/09/xmldsig#">
<!ENTITY dsig 'http://www.w3.org/2000/09/xmldsig#'>
<!ENTITY % p ''>
<!ENTITY % s ''>
]>