XML Schema: element containing any XHTML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • qwix
    New Member
    • Dec 2006
    • 1

    XML Schema: element containing any XHTML

    Hi,

    after hours spent Googling I'm undone. What I need is to create a XML schema allowing some element to contain any XHTML element(s).

    This is my XML file I'm trying to validate according to the schema:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <myelement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test2.xsd">
     <p>hello!</p>
    </myelement>
    test2.xsd:
    Somewhere I found this should work:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    	<xs:element name="myelement">
    		<xs:complexType>
    			<xs:sequence>
    				<xs:any namespace="http://www.w3.org/1999/xhtml" processContents="strict" minOccurs="0" maxOccurs="unbounded" />
    			</xs:sequence>
    		</xs:complexType>
    	</xs:element>
    </xs:schema>
    but I'm getting this error:
    File Untitled3.xml is not valid.
    Element <p> is not allowed under element <myelement>.
    Reason: The following elements are expected at this location {http://www.w3.org/1999/xhtml}
    Error location: myelement / p
    Details
    cvc-model-group: Element <p> unexpected by type '{anonymous}' of element <myelement>.
    cvc-elt.5.2.1: The element <myelement> is not valid with respect to the actual type definition '{anonymous}'.

    I also tried importing namespace and this:
    Code:
    <xs:any namespace="##any" processContents="strict" maxOccurs="unbounded"/>
    but with same (no) results.

    Can anyone tell me what am I doing wrong?
    Thanks
Working...