Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xml-dev] increment pattern for an attribute..

From: "Michael Kay" <mike@--------.--->
To: "'dave'" <ceek63@-----.--->,<xml-dev@-----.---.--->
Date: 11/6/2007 9:15:00 AM
You don't say what technology you are using to define the schema. But let's
assume it's XSDL 1.1 with assertions (and with no limits on the XPath syntax
allowed in assertions) - as implemented in Saxon 9.0.

Then I think you can do it with

<xs:complexType name="type-of-data-element">
  ...
  <xs:assert test="e1[1]/@val=20 and 
  every $e in e1[position()>1] satisfies $e/@val =
$e/preceding-sibling::e1/@val + 1"/>
</xs:complexType>

I'm not sure this is quite right according to your description - perhaps you
allow gaps in the numbering sequence. In that case it's:

<xs:assert test="e1[1]/@val=20 and 
every $e in e1[position()>1] satisfies $e/+@val >
$e/preceding-sibling::e1/+@val"/>

(The odd little "+" signs are a quirky way of forcing conversion to a number
in XPath 2.0)

Give it a try and let us know if it works.

Michael Kay
http://www.saxonica.com/

> 	
> I need to define the schema for "val" attribute in the below XML:
> 
> <data term="EXP">
> <el val="20">
> <ch> some data </ch>
> </el>
> <el val="21">
> <ch> some data </ch>
> </el>
> .....similarly for val=22,23,24,....N
> </data>
> 
> <data term="SUPP">
> <el val="20">
> <ch> some data </ch>
> </el>
> <el val="21">
> <ch> some data </ch>
> </el>
> .....similarly for val=22,23,24,....N
> </data>
> 
> Here, am more interested in the "val" attribute of "el" 
> element. What is the Specific schema for "val"
> attribute which satisfies the following conditions:
> 1. allowed values for "val" are 20,21,22,..... N (no limit on 
> N although it's typically < 100.) 2. "val" always begins with 
> 20 in each "data" element scope.
> 3. "val" must be in ascending order (20,21,22...etc) 4. "val" 
> must be unique in each "data" element scope.
> 
> appreciate any pointers.
> +D
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection 
> around http://mail.yahoo.com 
> 
> ______________________________________________________________
> _________
> 
> XML-DEV is a publicly archived, unmoderated list hosted by 
> OASIS to support XML implementation and development. To 
> minimize spam in the archives, you must subscribe before posting.
> 
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@l...
> subscribe: xml-dev-subscribe@l... List archive: 
> http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent