[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|