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

Using XML Schema info in XSL

Subject: Using XML Schema info in XSL
From: "Martin Bryan" <mtbryan@xxxxxxxxxxxxxx>
Date: Sun, 9 May 1999 10:39:50 +0100
xml schema maxoccur
I'm currently looking at the impact of an XML Schema description on the
writing of XSL style sheets. I am particularly intrigued by how we can make
use of the XML Schema maxOccur attribute. This can be used as shown in the
following example:

  <elementType name='Order'>
   <sequence>
    <elementTypeRef name='MessageID'/>
    <elementTypeRef name='Date' minOccur='1' maxOccur='3'/>
    <elementTypeRef name='RefersTo' minOccur='0' maxOccur='10'/>
    <elementTypeRef name='Buyer'/>
    <elementTypeRef name='Supplier'/>
    <elementTypeRef name='OtherParty' minOccur='1' maxOccur='97'/>
    <elementTypeRef name='Item' minOccur='1' maxOccur='200000'/>
   </sequence>

Now say I want to write a template for the Date element. In this template I
want to run a test to ensure that the Date I have found is one of the up-to
three dates whose parent can be Order. (There can  be other dates nested at
deeper levels. At this stage all I want to do is to confirm that the number
of Date children of Order does not exceed the maxOrder value assigned t the
elementTypeRef whose name is Date in the elementType spec for Order.)

So I have to create a test something like:
<xsl:template match="Date">
<xsl:if test="from-preceding-siblings(Date[position()=-1])<doc(???)"/>
...

The question is what should ??? be if the schema is stored in a relatively
addressed file called order.xsd, the elementTypes are ordered alphabitically
in the file and the definition of Date I am looking for is the first one
given in the Order sequence. (Note: On some models there will be multiple
Date elements in the main sequence, so I need to check it is the first one
whose value I am picking up in the general state.)

Is ??? something like
order.xsd?elementType[@name="Order"]/elementTypeRef[@name="Date"][1][@maxOcc
ur]?
Am I right in thinking the predicates stack, and does the last predicate
return the value of the maxOccur element or do I have to put the doc(...)
within an xsl:value-of statement?

For the first part of the text I really want something like
from-preceding-siblings-and-self(Date[position()=-1]). Is there any easy way
to acheive this? When I need to apply the test to a second Date element in
the sequence (in those cases where there is one) the test I have does not
work, as the count will include the first batch of dates instead. How can I
restrict the test to those with no intervening non-Date elements?

Martin Bryan


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
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-2013 All Rights Reserved.