0

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

    &ltp&gt, &ltdiv&gt, etc

for example

    Hello &ltu&gtunderlined text&lt/u&gt &ltb&gtbold text&lt/b&gt world
nogenius
  • 574
  • 1
  • 6
  • 18

1 Answers1

0

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.

Niels V
  • 1,005
  • 8
  • 11
  • actually the xhtml.blkstruct.class is defined in the XHTML Basic XML Schema Driver, see [here](http://www.w3.org/TR/xhtml-basic/#a_sdriver) . How can I manage to reuse this definition? – nogenius Sep 04 '15 at 21:44
  • See my updated answer, but you might need more files locally. – Niels V Sep 05 '15 at 10:22
  • 1
    This doesn't work for me - I'm always getting errors that xhtml.BlkStruct.class is not declared... Any other ideas on how to create a C# class for serializing a text with a basic set of recursive html attributes ( a, div, p, ul, ol, sup)? – nogenius Sep 05 '15 at 22:46