[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: declaring an element having subelements and restricted child-text-node value

From: George Cristian Bina <george@oxygenxml.com>
Date: Tue, 06 Jun 2006 14:50:30 +0300
Message-ID: <44856C06.10601@oxygenxml.com>
To: Vasilis Vagenas <vagenas.v@gmail.com>
Cc: xmlschema-dev@w3.org
textnode value

Hi,

When you have mixed content you cannot place constraints on the text 
nodes. In fact in your sample the Brand element has 3 text nodes:

"HP\n  "
"\n  "
"\n"

where \n stands for new line.

However, if you use Schematron then you can add rules to check for what 
you want but I would recommend changing the XML structure to have the 
brand name inside an element or attribute:

<Brand>
   <Name>HP</Name>
   <Type>Laptop</Type>
   <Type>Desktop</Type>
</Brand>

or

<Brand Name="HP">
   <Type>Laptop</Type>
   <Type>Desktop</Type>
</Brand>


Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Vasilis Vagenas wrote:
> 
> I am trying to write an xml schema which will allow xml instance
> documents of the following form:
> 
> [............]
> <Brand>X1
>   <Type>X2
> [............]
> 
> where X1 must belong to a set of string values, e.g. X1 in {"HP", 
> "Toshiba"}
> and X2 must belong to another set of string values, e.g. X2 in
> {"Laptop","Desktop"}.
> 
> For examle:
> <Brand>HP
>   <Type>Laptop</Type>
>   <Type>Desktop</Type>
> </Brand>
> 
> 
> How can I declare an element that satisfies the following:
> 1) it has subelements and
> 2) the value of its child-text node is restricted (to belong to a set
> of values),
> just as in the example above?
> 
> I can declare an element satisfying either condition 1 or condition 2,
> but not both of them.
> 
> Thank you very much!
> 
> 
Received on Tuesday, 6 June 2006 11:48:00 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.