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

Re: Schema Exploration...

Subject: Re: Schema Exploration...
From: "Mark R. Diggory" <mdiggory@xxxxxxxxxxxxxxxxx>
Date: Sat, 20 Apr 2002 22:43:10 -0400
itworks schema



Having a canonical representation, in particular with groups and derivations resolved (or ignored), it becomes easier to create the key. You can create a key that combines the name that you're looking for with the element (or complex type) in which it's contained. For example if you're adopting a "Russian Doll" style, where all complex types are anonymous and elements are all nested inside each other, you can use the following:

<xsl:key name="elements-by-parent-element"
 match="xs:element//xs:element"
 use="concat(ancestor::xs:element[1]/@name, '//' (@name | @ref))" />

Ok, yes, I took this approach and defined a key like yours only with the match selection I got from Wendell.

<xsl:key name="elements-by-parent-element" match="xs:schema/xs:element | xs:element/xs:element | xs:element/xs:complexType/xs:choice/xs:element | xs:element/xs:complexType/xs:sequence/xs:element | xs:element/xs:complexType/xs:element" use="concat(ancestor::xs:element[1]/@name, '//', (@name | @ref))"/>

Yes, I'd like to come up with a simpler match pattern that gets all the possiblities for xs:elements. Plus, I want to do some similar keys for attributes-by-parent-element.

So Far the closest I've been able to come is:

<xsl:variable name="my_snode" select="($parent_snode/descendant::xs:element)[@name=$node_name or @ref=$node_name]"/>

Unfortunately, I don't think this will exclude cases where the "child" xs:element (its not really a child, I know) isn't really a "1st" descendant. 1st descendant meaning, there are no xs:elements between it and the "parent" xs:element (its not really a parent, I know).

So I was try something like this, but I can't get the syntax right:
		
<xsl:variable name="my_snode" select="($parent_snode/descendant::xs:element/*[ancestor::xs:element[@name=$parent_snode/@name]][1] )[@name=$node_name or @ref=$node_name]"/>


Each xs:element that occurs within another xs:element is indexed by a combination of its closest ancestor xs:element's name and its own name or ref attribute. For example, to find all the elements called 'foo' nested inside elements called 'bar', you could use:

key('elements-by-parent-element', 'bar//foo')

I have a good example going now with this approach. It works very well for the schema I've been working with. Here's a demo site (Don't expect it will stay there forever.)

http://vdc.fas.harvard.edu:8080/Editor/index.htm (Look under Project 2)

Its a little slow due to some server side buffering I need to resolve, but it works.

The XSL and schema are provided as well.

-Mark


(The other thing that you'll have to tackle some point in the future
is namespace resolution of the 'ref' attributes.)


gulp




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.