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

Re: Schema Exploration...

Subject: Re: Schema Exploration...
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 18 Apr 2002 17:44:14 -0400
Re:  Schema Exploration...
Mark,

At 02:07 PM 4/18/2002, you wrote:
I'm trying to select a schema element node relative to the current xs:element node I've referenced in a parameter ($schema_node). The problem is that there are several cases that need to be checked for:

xs:element/*[@name='test1a' or @ref='test1b']
xs:element/xs:complexType/xs:choice/*[@name='test2a' or @ref='test2b']
xs:element/xs:complexType/xs:sequence/*[@name='test3a' or @ref='test3b']

You can take advantage of the fact that your schema should not have xs:elements with *both* a @name and a @ref to do something like:


<xsl:variable name="okaynames" select="'test1a test1b test2a test2b test3a test3b'"/>
<!-- the variable is not strictly necessary but makes things easier -->
<xsl:apply-templates select=".//xs:element[contains($okaynames, (@name|@ref))]"/>


If I understand your problem correctly, this will work because:

.//xs:element selects all xs:element descendants of the current node (*really* strictly, all xs:element children of nodes on the descendant-or-self axis from the current node). If your element declarations go down more than one level, you may have to be more specific with this step, as in select="(xs:element | xsl:complexType/xs:choice/xs:element | xs:complexType/xs:sequence/xs:element)[ ... the predicate ... ]"

The predicate [contains($okaynames, (@name|@ref))] tests true if the value of the @name or @ref attribute of the selected node (whichever is first -- up to your processor since they're attributes -- but there should be only one) is contained in the string $okaynames.

If you wanted to be *really* fancy you could set something like:

<xsl:variable name="okaynames" select="concat(concat(local-name(), 'a'), ' ', concat(local-name(), 'b'))"/>

which makes the string "test1a test1b" for element test1, "test2a test2b" for element test2, etc. (Junk this bit if these aren't actually your element names.)

The space ' ' makes a good delimiter in this test string since it's not allowed inside a legal element name.

We'll trust Mike K., Jeni or anyone else (go to it, gang!) to spot any conceptual errors or omissions I've made here.

I hope that helps--
Wendell



======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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.