You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Mark Biamonte <Ma...@merant.com> on 2000/07/24 15:58:24 UTC
Embedding schema in an XML document
Is there a way to create an XML document that contains both the schema for
the document and the document content and be able to validate the document
against the embedded schema with the Xerces XML processor? For instance, I
have the following XML file and Schema
test.xsd:
<?xml version="1.0"?>
<schema targetNamespace=" <http://www.merant.com/schemas/test>
http://www.merant.com/schemas/test"
xmlns=" <http://www.w3.org/1999/XMLSchema>
http://www.w3.org/1999/XMLSchema"
xmlns:rs=" <http://www.merant.com/schemas/test>
http://www.merant.com/schemas/test"
elementFormDefault="qualified"
attributeFormDefault="qualified">
<element name="table" type="rs:tableType"/>
<complexType name="tableType">
<element name="record" minOccurs="0" maxOccurs="unbounded"
type="rs:recordType"/>
</complexType>
<complexType name="recordType">
<element name="charcol" minOccurs="0">
<simpleType base="string">
<length value="8"/>
</simpleType>
</element>
</complexType>
</schema>
test.xml
<?xml version="1.0"?>
<table xmlns =" <http://www.merant.com/schemas/test>
http://www.merant.com/schemas/test"
xmlns:xsi=" <http://www.w3.org/1999/XMLSchema-instance>
http://www.w3.org/1999/XMLSchema-instance"
xsi:schemaLocation=" <http://www.merant.com/schemas/test>
http://www.merant.com/schemas/test
sampleschema.xsd">
<record>
<charcol>abcdefg </charcol>
</record>
<record>
<charcol>bcdefghi</charcol>
</record>
</table>
I can use the 1.1.2 java parser to parse and validate this XML file. I
would like to combine them into a single file. Doing the following does not
work because there is more than one root node in the document.
<?xml version="1.0"?>
<schema targetNamespace=" <http://www.merant.com/schemas/test>
http://www.merant.com/schemas/test"
xmlns=" <http://www.w3.org/1999/XMLSchema>
http://www.w3.org/1999/XMLSchema"
xmlns:rs= <http://www.merant.com/schemas/test>
http://www.merant.com/schemas/test
elementFormDefault="qualified"
attributeFormDefault="qualified">
<element name="table" type="rs:tableType"/>
<complexType name="tableType">
<element name="record" minOccurs="0" maxOccurs="unbounded"
type="rs:recordType"/>
</complexType>
<complexType name="recordType">
<element name="charcol" minOccurs="0">
<simpleType base="string">
<length value="8"/>
</simpleType>
</element>
</complexType>
</schema>
<rs:table>
<rs:record>
<rs:charcol>abcdefg </rs:charcol>
</rs:record>
<rs:record>
<rs:charcol>bcdefghi</rs:charcol>
</rs:record>
</rs:table>
Is there a way to get the data and schema in the same file?
Thanks
----------------------------
Mark Biamonte
Sr. Software Developer
MERANT
Mark.Biamonte@Merant.com
Re: Embedding schema in an XML document
Posted by Andy Clark <an...@apache.org>.
Mark Biamonte wrote:
> Is there a way to create an XML document that contains both the schema
> for the document and the document content and be able to validate the
> document against the embedded schema with the Xerces XML processor?
> For instance, I have the following XML file and Schema
This is one of the things that I never saw resolved with Schemas:
how to handle standalone documents. I don't think that you can,
really.
--
Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org
Re: Embedding schema in an XML document
Posted by Eric Ye <er...@locus.apache.org>.
No, not that I know of from the Schema Spec 4/7 working draft. But as long as the standards allows it, it won't be difficult to expand the implementation to do such things.
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: Mark Biamonte
To: 'xerces-j-dev@xml.apache.org'
Sent: Monday, July 24, 2000 6:58 AM
Subject: Embedding schema in an XML document
Is there a way to create an XML document that contains both the schema for the document and the document content and be able to validate the document against the embedded schema with the Xerces XML processor? For instance, I have the following XML file and Schema
test.xsd:
<?xml version="1.0"?>
<schema targetNamespace="http://www.merant.com/schemas/test"
xmlns="http://www.w3.org/1999/XMLSchema"
xmlns:rs="http://www.merant.com/schemas/test"
elementFormDefault="qualified"
attributeFormDefault="qualified">
<element name="table" type="rs:tableType"/>
<complexType name="tableType">
<element name="record" minOccurs="0" maxOccurs="unbounded"
type="rs:recordType"/>
</complexType>
<complexType name="recordType">
<element name="charcol" minOccurs="0">
<simpleType base="string">
<length value="8"/>
</simpleType>
</element>
</complexType>
</schema>
test.xml
<?xml version="1.0"?>
<table xmlns ="http://www.merant.com/schemas/test"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xsi:schemaLocation="http://www.merant.com/schemas/test
sampleschema.xsd">
<record>
<charcol>abcdefg </charcol>
</record>
<record>
<charcol>bcdefghi</charcol>
</record>
</table>
I can use the 1.1.2 java parser to parse and validate this XML file. I would like to combine them into a single file. Doing the following does not work because there is more than one root node in the document.
<?xml version="1.0"?>
<schema targetNamespace="http://www.merant.com/schemas/test"
xmlns="http://www.w3.org/1999/XMLSchema"
xmlns:rs=http://www.merant.com/schemas/test
elementFormDefault="qualified"
attributeFormDefault="qualified">
<element name="table" type="rs:tableType"/>
<complexType name="tableType">
<element name="record" minOccurs="0" maxOccurs="unbounded"
type="rs:recordType"/>
</complexType>
<complexType name="recordType">
<element name="charcol" minOccurs="0">
<simpleType base="string">
<length value="8"/>
</simpleType>
</element>
</complexType>
</schema>
<rs:table>
<rs:record>
<rs:charcol>abcdefg </rs:charcol>
</rs:record>
<rs:record>
<rs:charcol>bcdefghi</rs:charcol>
</rs:record>
</rs:table>
Is there a way to get the data and schema in the same file?
Thanks
----------------------------
Mark Biamonte
Sr. Software Developer
MERANT
Mark.Biamonte@Merant.com