Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Newbie question: Attributes and schema's

Reply
Thread Tools

Newbie question: Attributes and schema's

 
 
Robert Dunn
Guest
Posts: n/a
 
      08-18-2004
Hi,

I'm interested in creating a schema that enforces a node tree based on
an attribute. For example:

<Invocation type="COM">
<GUID>{63D94CD7-C566-457D-B011-D544483D7862}</GUID>
</Invocation>
<Invocation type="DCOM">
<MachineName>IITWEB-1</MachineName>
<GUID>{63D94CD7-C566-457D-B011-D544483D7862}</GUID>
</Invocation>
<Invocation type="DLL">
<Location>C:\Temp\Product.dll</Location>
</Invocation>

Is this possible? At the moment I've got the schema with a choice
around MachineName, GUID and Location but ultimately it would be nice
to enforce the relationship between the nodes and the attribute.
Current schema:

<xs:element name="Invocation">
<xs:complexType>
<xs:choice>
<xs:element ref="MachineName" minOccurs="0"/>
<xs:element ref="GUID" minOccurs="0"/>
<xs:element ref="Location" minOccurs="0"/>
</xs:choice>
<xs:attribute name="type" use="required">
<xs:simpleType>
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="COM"/>
<xs:enumeration value="DCOM"/>
<xs:enumeration value="DLL"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>

Thanks,
Rob.
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      08-18-2004


Robert Dunn wrote:


> I'm interested in creating a schema that enforces a node tree based on
> an attribute. For example:
>
> <Invocation type="COM">
> <GUID>{63D94CD7-C566-457D-B011-D544483D7862}</GUID>
> </Invocation>
> <Invocation type="DCOM">
> <MachineName>IITWEB-1</MachineName>
> <GUID>{63D94CD7-C566-457D-B011-D544483D7862}</GUID>
> </Invocation>
> <Invocation type="DLL">
> <Location>C:\Temp\Product.dll</Location>
> </Invocation>
>
> Is this possible? At the moment I've got the schema with a choice
> around MachineName, GUID and Location but ultimately it would be nice
> to enforce the relationship between the nodes and the attribute.


There is no way with a W3C XML schema to enforce an element's content
depending on an attribute's value.

There are other schema languages like Schematron for instance which
allow yo to make assertions using the full power of XPath and that way
you are able to check that for a certain attribute value you have a
certain element substructure.
You can find more about Schematron here:
http://xml.ascc.net/schematron/

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Robert Dunn
Guest
Posts: n/a
 
      08-18-2004
Martin Honnen <(E-Mail Removed)> wrote in message news:<41234977$0$28853$(E-Mail Removed)-online.net>...
> Robert Dunn wrote:
>
>
> > ...

>
> There is no way with a W3C XML schema to enforce an element's content
> depending on an attribute's value.
>
> There are other schema languages like Schematron for instance which
> allow yo to make assertions using the full power of XPath and that way
> you are able to check that for a certain attribute value you have a
> certain element substructure.
> You can find more about Schematron here:
> http://xml.ascc.net/schematron/


Martin, thanks for your response.

Rob.
 
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
data attributes override method attributes? Jayden Python 16 09-29-2012 03:20 AM
attributes ala java annotations or .Net attributes? Kyle Schmitt Ruby 3 07-24-2007 07:48 PM
class attributes & data attributes james_027 Python 2 06-20-2007 03:12 PM
WebControl.Attributes.Add and custom attributes P4trykx ASP .Net 2 01-31-2007 04:33 PM
Parse reserved attributes as normal attributes Max XML 1 09-22-2006 12:04 PM



Advertisments