Martin,
Thanks for your pointer - it is very useful.
I am still getting an error on the validation. Maybe I am doing
something wrong.
I did this:
###schema
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.myTarget.com"
xmlns="http://www.myTarget.com"
elementFormDefault="qualified">
<xsd:element name="LDOC">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="XHTML" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="META" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="XHTML" type="XHTMLType"/>
<xsd:complexType name="XHTMLType">
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:anyAttribute namespace="http://www.w3.org/1999/
xhtml" processContents="lax"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
####### xml file
<?xml version="1.0" encoding="UTF-8"?>
<lxx:LCCDOC xmlns:lxx="http://www.myTarget.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.myTarget.com
file:LDocument_V0.xsd">
<lxx:XHTML>
<html></html <!-- ERROR -->
</lxx:XHTML>
<lxx:META>
On Feb 13, 9:39 am, Martin Honnen <mahotr...@yahoo.dewrote:
dantohes...@gmail.com wrote:
I have the following situation:
I want to create an XML document that contains 2 parts:
a) a XHTML part (it can be either version 1.0 or 1.1 )
b) a non XHTML part that contains some information about the first
part - like the location of that content or some other info on
different constituents of the first part
The elements of the second part are defined by an XML schema.
My question is how to do this in an elegant manner?
Should I import somehow (I have no idea how) the XHTML schema on the
part 2 schema? Or should I deal only on the instance XML file with
this issue (if yes - how)?
You can author the schema for the elements you want to define yourself
and then, where XHTML elements are allowed, you use xs:any together with
the XHTML namespacehttp://www.w3.org/1999/xhtml. On the xs:any element
you use the attribute processContents="lax", that way the processor will
validate if a schema for that namespace is known or skip validation if
no schema is known.
As for importing an XHTML schema, the W3C has made various efforts at
doing this, one is <http://www.w3.org/TR/xhtml1-schema/>, it is only a
note however, not a normative schema. Importing a schema is simply done
with e.g.
<xs:import namespac="http://www.w3.org/1999/xhtml"/>
with an optional URL provided for the schema location.
--
Martin Honnen
http://JavaScript.FAQTs.com/