[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Schema Exploration...
Wendell Piez wrote:
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))]"/>
Ok, the attribute values for @name and @ref can't be hardcoded because
this is a general approach (test1a test1b .....) are just foobar's that
would come from the name() of the tag in the XML document.
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 ... ]"
This seems the most effective solution and it worked:
<xsl:variable name="my_snode" select="($parent_snode/xs:element |
$parent_snode/xs:complexType/xs:choice/xs:element |
$parent_snode/xs:complexType/xs:sequence/xs:element)[@name=$node_name or
@ref=$node_name]"/>
I don't suspect that a xs:element can fall anywhere else in another
xs:element. But if it does I can just add it to the select statement.
My current goal is to build a JSP/Saxon based XML Editor that config's
itself using an assigned schema. You'll be able to open any xml doc in
it and add/remove/edit the contents of it based on the schema. The
source of the doc will be configurable as well so that one can use it as
a front end for editing xml stored in a database or in a directory on a
server...
-Thanks (You just reduced the size of my xslt document by about 75%)
Mark
HMDC
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
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
RSS 2.0 |
|
Atom 0.3 |
|
|