Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > SUBJECT: XML schema together with XHTML

Reply
Thread Tools

SUBJECT: XML schema together with XHTML

 
 
dantohester@gmail.com
Guest
Posts: n/a
 
      02-13-2007
Hi there,

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)?

Thanks a lot for the help.

Daniel

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      02-13-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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 namespace http://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/
 
Reply With Quote
 
 
 
 
dantohester@gmail.com
Guest
Posts: n/a
 
      02-13-2007
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 xmlnssd="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"
xmlnssi="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 <(E-Mail Removed)> wrote:
> (E-Mail Removed) 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/



 
Reply With Quote
 
dantohester@gmail.com
Guest
Posts: n/a
 
      02-13-2007
My BAD,
I was making a mistake. Bellow is the good example.
A problem still arises: the solution works if my XHTML part has an
XHTM schema header. What if that XHTML is "coordinated" by a DTD? How
can I still incorporate that part in my XML file?

I do appreciate your help - Thank you!

Daniel

the good XML schema:
<xsd:element name="XHTML">
<xsd:complexType>
<xsd:sequence>
<xsd:any minOccurs="0" namespace="http://www.w3.org/
1999/xhtml" processContents="lax"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
web.xml / XML schema issue, why do some XML schema attributes disappear asciz@starmail.com Java 3 02-20-2007 09:56 AM
Validation with XSD using XML::LibXML::Schema, and XML::Validator::Schema huntingseasonson@gmail.com Perl Misc 5 11-29-2006 12:37 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
XML Schema to XML Schema Conversion Hari Om XML 1 03-02-2004 09:04 PM
XML schema regular expressions question and recommended XML Schema book Fred Smith XML 1 02-05-2004 11:12 AM



Advertisments