Extension of a tag in XSchema using an XHTML type.

B

Binesh Bannerjee

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.
In another thread said:
XHTML is XML so there is no problem to use it inside of an XML document e.g.
<root>
<description>
<p xmlns="http://www.w3.org/1999/xhtml">description goes here</p>
</description>
</root>

Here's my problem tho... I want to do basically this:
<xsd:schema
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:html="http://www.w3.org/1999/xhtml"
elementFormDefault="qualified"<xsd:import namespace="http://www.w3.org/1999/xhtml" schemaLocation="http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd"/>
<xsd:element name="mybody" type="html:body" />
</xsd:schema>

and give it (something like)
<?xml version="1.0"?>
<mybody
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="duck.xsd"<i>Hello!</i>
</mybody>

I'm using Xerces-J-2.6.2, and it barks at me with
org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'html:body' to a(n) 'type definition' component.

How do I make the <mybody> tag take any elements that could go in html:body?

(As a side note, it also barks at me with
org.xml.sax.SAXParseException: InvalidRegex: Pattern value '[-+]?(\d+|\d+(\.\d+)?%)(,\s*[-+]?(\d+|\d+(\.\d+)?%))*' is not a valid regular expression. The reported error was: ''-' is an invalid character range. Write '\-'.'.

But, I'm not as concerned with this... Perhaps it's just an idiosynchrasy
of Xerces... But, it's easy enough to fix, by simply _copying_ the
xhtml1-strict.xsd and changing all instances of [-+] to [\-+]...

Anyhoo, any help appreciated.
Thanks!
Binesh Bannerjee

- --
"It's stupendous! And yet so lucid!"
"It's STUPID!"

PGP Key: http://www.hex21.com/~binesh/binesh-public.asc
PGP Key fingerprint = 421D B4C2 2E96 B8EE 7190 A0CF B42F E71C 7FC3 AD96

SSH2 Key: http://www.hex21.com/~binesh/binesh-ssh2.pub
OpenSSH Key: http://www.hex21.com/~binesh/binesh-openssh.pub
BubbleBabble = xibeb-voges-havez-pabaf-debop-cylil-lelyc-viruv-bygeg-zotoh-dixex
Fingerprint = 9d:7c:84:5d:80:e3:65:8d:ee:9e:a3:b9:56:0a:e9:ad

SSH1 Key: http://www.hex21.com/~binesh/binesh-ssh1.pub

CipherKnight Seals:
http://www.hex21.com/~binesh/binesh-seal.tar.bz2.cs256
http://www.hex21.com/~binesh/binesh-seal.zip.cs256
http://www.hex21.com/~binesh/binesh-certificate.gif.cs256
Decrypt with CipherSaber2 N=256, Password="WelcomeJedi!" (No quotes)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFBqDR7tC/nHH/DrZYRAtk6AJ0Qi8tq6hifyiOIH8phywo/9TOuiwCfXYJz
+rf/ZLEyMjANenVEP4jA5OI=
=debr
-----END PGP SIGNATURE-----
 
M

Martin Honnen

Yes, that is possible, but it uses a defined XHTML <p> element in the
right namespace http://www.w3.org/1999/xhtml and it doesn't say anything
on designing a schema for such a document.
Here's my problem tho... I want to do basically this:
<xsd:schema
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:html="http://www.w3.org/1999/xhtml"
elementFormDefault="qualified"
>
<xsd:import namespace="http://www.w3.org/1999/xhtml" schemaLocation="http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd"/>
<xsd:element name="mybody" type="html:body" />

Well check that schema you import, it defines an element named body but
not a type of that name so what you could do with that schema is
<xsd:element ref="html:body" />
of course that means that then in your XML you have to use
<body xmlns="http://www.w3.org/1999/xhtml">
or
and give it (something like)
<?xml version="1.0"?>
<mybody
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="duck.xsd"
>
<i>Hello!</i>
</mybody>

As said you would need
<body xmlns="http://www.w3.org/1999/xhtml">
<p><i>Hello!</i></p>
</body>
(where I have added the <p> element to conform with the XHTML 1.0 strict
content requirements)
 
B

Binesh Bannerjee

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Honnen said:
Well check that schema you import, it defines an element named body but
not a type of that name so what you could do with that schema is
<xsd:element ref="html:body" />
of course that means that then in your XML you have to use
<body xmlns="http://www.w3.org/1999/xhtml">
or
<xhtml:body xmlns:xhtml="http://www.w3.org/1999/xhtml">

Thanks for your response!

But, I want to somehow make the schema such that the XML doesn't need
to specify a _second_ schema (as in
<?xml version="1.0"?>
<mybody
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:xsi:noNamespaceSchemaLocation="duck.xsd"<p xmlns="http://www.w3.org/1999/xhtml"><i>Hello!</i></p>
</mybody>

because, that is just my contrived example... In reality, what I want is
something like this:
<?xml version="1.0"?>
<person
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:xsi:noNamespaceSchemaLocation="duck.xsd"<name>
<first>Binesh</first>
<last>Bannerjee</last>
</name>
<memo>
<p><i>Binesh Bannerjee</i> seeks to know more
about <b>XSchema</b></p>
</memo>
</person>

Is there a way of doing it without needing to specify that schema in the
<p> there? Can I simply define <memo> in duck.xsd to extend html:body ?

Thanks again for your response!
Binesh

As said you would need
<body xmlns="http://www.w3.org/1999/xhtml">
<p><i>Hello!</i></p>
</body>
(where I have added the <p> element to conform with the XHTML 1.0 strict
content requirements)

Martin Honnen
http://JavaScript.FAQTs.com/


- --
"I've SEEN the future. Do you know what it is? It's a 47 yr. old
virgin sitting around in his beige pajamas drinking a banana
brocoli shake singing 'I'm an oscar meyer weiner'."
-- Edgar Friendly - Demolition Man

PGP Key: http://www.hex21.com/~binesh/binesh-public.asc
PGP Key fingerprint = 421D B4C2 2E96 B8EE 7190 A0CF B42F E71C 7FC3 AD96

SSH2 Key: http://www.hex21.com/~binesh/binesh-ssh2.pub
OpenSSH Key: http://www.hex21.com/~binesh/binesh-openssh.pub
BubbleBabble = xibeb-voges-havez-pabaf-debop-cylil-lelyc-viruv-bygeg-zotoh-dixex
Fingerprint = 9d:7c:84:5d:80:e3:65:8d:ee:9e:a3:b9:56:0a:e9:ad

SSH1 Key: http://www.hex21.com/~binesh/binesh-ssh1.pub

CipherKnight Seals:
http://www.hex21.com/~binesh/binesh-seal.tar.bz2.cs256
http://www.hex21.com/~binesh/binesh-seal.zip.cs256
http://www.hex21.com/~binesh/binesh-certificate.gif.cs256
Decrypt with CipherSaber2 N=256, Password="WelcomeJedi!" (No quotes)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFBqKFAtC/nHH/DrZYRAlW1AJ9f03eeBXIEidxH7Md9vRfxaFuQLgCgt/h2
p2Dgm+zQpaN2ozS96VPDlQo=
=aTHp
-----END PGP SIGNATURE-----
 
M

Martin Honnen

Binesh Bannerjee wrote:

In reality, what I want is
something like this:
<?xml version="1.0"?>
<person
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:xsi:noNamespaceSchemaLocation="duck.xsd"
>
<name>
<first>Binesh</first>
<last>Bannerjee</last>
</name>
<memo>
<p><i>Binesh Bannerjee</i> seeks to know more
about <b>XSchema</b></p>
</memo>
</person>

Well of course you can use <p>, <i>, and <b> without a namespace but
then those are not XHTML elements, only the proper namespace e.g.
<p xmlns="http://www.w3.org/1999/xhtml>
gives the element the proper semantics.

As for a schema if you don't want to declare the namespace you can use
xs:any e.g.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">

<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="name">
<xs:complexType>
<xs:sequence>
<xs:element name="first" type="xs:string" />
<xs:element name="last" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="memo">
<xs:complexType>
<xs:sequence>
<xs:any processContents="lax" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>

that way you can use any kind of content in <memo>.

If you want to use XHTML content then you could use the following schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
version="1.0">

<xs:import namespace="http://www.w3.org/1999/xhtml"
schemaLocation="http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd" />

<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="name">
<xs:complexType>
<xs:sequence>
<xs:element name="first" type="xs:string" />
<xs:element name="last" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="memo" type="xhtml:Block" />
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>

but then you need content as follows:

<?xml version="1.0"?>
<person
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="test2004112702Xsd.xml"<name>
<first>Binesh</first>
<last>Bannerjee</last>
</name>
<memo>
<p xmlns="http://www.w3.org/1999/xhtml"><i>Binesh Bannerjee</i> seeks
to know more
about <b>XSchema</b></p>
</memo>
</person>

That validates here with Xerces-J without problems but MSXML has
problems processing that XHTML schema as it declares
xmlns:xml="http://www.w3.org/XML/1998/namespace"
which is a predefined namespace. I haven't tested with other processors.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top