473,657 Members | 2,351 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.c om"
xmlns="http://www.w3schools.c om"
elementFormDefa ult="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.c om"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://www.w3schools.c om">

<to>Registrar </to>
<from>Student </from>
<heading>Remind er</heading>
<body>Transcrip ts 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:schemaLocat ion to the xsd file, the
parsing goes fine.

any help is greatly appreciated..

//marc

Jul 20 '05 #1
3 4980


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.c om"
xmlns="http://www.w3schools.c om"
elementFormDefa ult="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.c om"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://www.w3schools.c om">

<to>Registrar </to>
<from>Student </from>
<heading>Remind er</heading>
<body>Transcrip ts 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:schemaLocat ion 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*****@notick et.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
3320
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 schema instance.
0
4223
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> > <password>brown</password> > </userlogin> > Above is my schema instance.
4
2930
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 I parse some element from XML document I don't know until runtime the type of the element (it depends on the type used in user-defined schema). XML parser obviously validates that the value of the element is correct type but still I receive that...
6
2485
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. I've made a small list of some good and bad points of both. These points don't really go into the grammar aspects of these languages, but are more about secondary aspects. The grammar aspects are different, but both are suitable for validating...
2
2486
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 target namespace of the components from the included schema document. I'm confused because of the rules I read in the XML Schema spec <http://www.w3.org/TR/xmlschema-1/#element-element>: > If the <element> element information item has <schema>...
1
3110
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 schema and then add a new XML document, set the reference to the schema and start typing in the data in Visual Studio's "data view" window which seems to work fine. But then I view the document in XML view and Visual Studio indicates an error in...
0
1422
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" indent="yes"/> <xsl:template match="/"> <xsl:element name="Test">it works</xsl:element> </xsl:template>
3
1753
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 containing multiple User records. The external supplier validates this entire document using schema 1. This document is then uploaded to our system. b) Our system then checks that the supplied document "looks okay", minimally, using Schema 2. Schema...
6
2240
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 an entire, complete instance document for that other schema? Let's say I have the following schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="BogusElement"...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8504
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8606
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4159
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2732
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 we have to send another system
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.