Generate C# class from XSD (xhtml.blkstruct.class)
I have an xsd file, simplified as below with an element referencing the xhtml.BlkStruct.class. I have tried xsd.exe and xsd2code trying to generate a C# class from it, but I am always getting errors.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xs:complexType name="test">
<xs:group ref="xhtml.BlkStruct.class"/>
</xs:complexType>
</xs:schema>
This is the error (reference to an undeclared / not declared model group)
Error: Verweis auf eine nicht deklarierte Modellgruppe 'http://www.w3.org/1999/xhtml:xhtml.BlkStruct.class'.
Can anybody help me out what is going wrong here?
Background I am tryint to XmlSerialize a string containing (simple) HTML/XML mixed with sting content, so things like
<p>, <div>, etc
for example
Hello <u>underlined text</u> <b>bold text</b> world
Well, you're not supplying the xhtml.BlkStruct.class
anywhere in your XSD. You might need to include its definition to succeed in the code generation. Download the file from http://www.w3.org/MarkUp/SCHEMA/ and add a
<xs:include schemaLocation="xhtml-basic11-model-1.xsd">
But do you really need a strongly typed DOM? A simpler solution is to define your test field as string, and include your HTML as CDATA or encoded html. My experience is that mixing XML with HTML is always a bad design choice and you have better luck with treating the HTML part as text.
链接地址: http://www.djcxy.com/p/34320.html上一篇: 从XSD生成C#类