473,503 Members | 11,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

embedding schema in the xml document..


Hi All,

I'm new to xml world and i was looking for a way
to embed the xml schema info in the xml document
itself. i tried the following:

--- xml schema + document combined ---

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">

<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

<?xml version="1.0"?>

<note
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com">

<to>Registrar</to>
<from>Student</from>
<heading>Reminder</heading>
<body>Transcripts requested ASAP</body>
</note>

-----

is this a valid thing to do ? xerces parser will not
parse the above xml. if i put the schema in another file
and refer the xsi:schemaLocation to the xsd file, the
parsing goes fine.

any help is greatly appreciated..

//marc

Jul 20 '05 #1
3 4973


marcus wrote:
I'm new to xml world and i was looking for a way
to embed the xml schema info in the xml document
itself. i tried the following:

--- xml schema + document combined ---

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">

<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

<?xml version="1.0"?>

<note
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com">

<to>Registrar</to>
<from>Student</from>
<heading>Reminder</heading>
<body>Transcripts requested ASAP</body>
</note>

-----

is this a valid thing to do ? xerces parser will not
parse the above xml. if i put the schema in another file
and refer the xsi:schemaLocation to the xsd file, the
parsing goes fine.


What you have is not even well-formed as only one XML declaration
followed by exactly one root element is allowed.
I don't think it makes much sense to embed an XML schema into an
instance document.

--

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

Jul 20 '05 #2
Martin Honnen wrote:
What you have is not even well-formed as only one XML declaration
followed by exactly one root element is allowed.
I don't think it makes much sense to embed an XML schema into an
instance document.


the scenario is: an emdedded device has its server hold
the device config as a dom document inmemory. clients
across network can request device to change its config
by providing xml dom subtree that needs to be changed.

the idea was to send the schema of the subtree (as the
device config is made of small schema docs each referring
to the subtree that could be changed) along with the
server response so the clinets donot have to maintian
a list of schema docs.

from your description it looks like clients across the
nework would have to maintain the schema locally as
the device does not the computing power to serve the
schema docs over network.

any thoughts/comments/suggestions ?

Thanks !
//marc

Jul 20 '05 #3
marcus <mc*****@noticket.org> wrote in message >
the scenario is: an emdedded device has its server hold
the device config as a dom document inmemory. clients
across network can request device to change its config
by providing xml dom subtree that needs to be changed.


One option would be to use a DTD instead of W3C XML Schema. DTD can be
embedded into the document.

Toivo Lainevool
http://www.XMLPatterns.com - Develop effective DTDs and XML Schema
documents for your XML using structural design patterns.
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3305
by: wooks | last post by:
<?xml version='1.0'?> <userlogin xmlns="urn:faster:userlogin" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> <login>mick</login> <password>brown</password> </userlogin> Above is my...
0
4202
by: C. M. Sperberg-McQueen | last post by:
wooks (wookiz@hotmail.com) wrote: > <?xml version='1.0'?> > <userlogin xmlns="urn:faster:userlogin" > xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> > <login>mick</login> > ...
4
2920
by: Jari Kujansuu | last post by:
I can successfully parse XML document using SAX or DOM and I can also validate XML document against schema. Problem is that my program should deal with user-defined schemas which means that when...
6
2476
by: Pieter | last post by:
I've read a lot of posts on "why relax ng is so very good" and on "why w3c xml schema should be the only schema language". I'm, however, still not clear on why I should prefer one over the other. ...
2
2469
by: Stanimir Stamenkov | last post by:
I'm trying to find out if it is permissible to include a schema document with absent target namespace to a schema with specified target namespace, and if it is, what are the rules to resolve the...
1
3095
by: Dave Taylor | last post by:
I'm trying to create a simple Schema and associated document in Visual Studio that will store information regarding units and conversion (meters, feet, inches, degrees C, F, K, etc.) I create a...
0
1409
by: hq4000 | last post by:
Given AStyleSheet.xsl : <AStyleSheet> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.mytest.mytest2.mytest3.com" version="1.0"> <xsl:output method="xml"...
3
1736
by: Lord0 | last post by:
I *think* I need to be able to validate subsets of an XML document using different schema. The functionality I'm trying to implement is this. a) External suppliers produce an XML document...
6
2219
by: Grant Robertson | last post by:
If I use the 'any' element in my schema to allow elements from another schema to be used in instance documents based on my schema, is there a way to force that the contents of that element must be...
0
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5604
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.