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

RE: template match : node-set paring through multiple-

Subject: RE: template match : node-set paring through multiple-axis relationships
From: Jonathan Sprinkle <jonathan.sprinkle@xxxxxxxxxxxxxx>
Date: Tue, 3 Jun 2003 12:34:32 -0500
xsl template match
>From message
(http://www.biglist.com/lists/xsl-list/archives/200305/msg01198.html)

Discouraged by XSL's limitations, I gave up doing it the nice way and hacked
my own solution.  In case you care, here it is.  It is a pain in the bum,
because now I have to create a bunch of variables, and do my own name
mangling if I have two different things to do to a 'b' in two different
contexts because XSL's namespace is intuitively different from conventional
namespaces in C++.  However, it works, and I can generate it generically
from a graphical transformation language.

For those who are in charge, and using this list to educate others on XSL to
evangelise it to the world on XSL and its usage, I am disappointed that no
one responded to my request, even to say "boy, that sure is a different
problem".  :(

Jonathan

=========== XSL Stylesheet ==========
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <xsl:template match="/">
                <xsl:apply-templates/>
        </xsl:template>
        <xsl:template match="b">
                <xsl:variable name="focus" select="current()"/>
                <xsl:variable name="b2"
select="parent::a/parent::a/child::b" />
                <xsl:choose>
                        <xsl:when test="current(
)[$b2][$focus][//c[c1[@role='dst'][@target=$b2/@id]][c1[@role='src'][@target
=$focus/@id]]]">
                                <xsl:call-template
name="WhatToDoWithMy_B_Now"/>
                        </xsl:when>
                </xsl:choose>
        </xsl:template>
        <xsl:template name="WhatToDoWithMy_B_Now">
                <xsl:comment>Matched B...<xsl:value-of select="@id"/>
                </xsl:comment>
        </xsl:template>
</xsl:stylesheet> 

=========== XML Source ==========
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [
	<!ELEMENT root (a* | c*)*>
	<!ELEMENT a (a* | b*)*>
	<!ELEMENT b (#PCDATA)>
	<!ATTLIST b
	id ID #IMPLIED
>
	<!ELEMENT c (c1*)>
	<!ELEMENT c1 (#PCDATA)>
	<!ATTLIST c1
	role CDATA #IMPLIED
		target IDREF #IMPLIED
>
]>
<root>
	<a>
		<b id="_10"/>
		<a>
			<b id="_11"/>
			<b id="_12"/>
		</a>
	</a>
	<c>
		<c1 role="src" target="_11"/>
		<c1 role="dst" target="_10"/>
	</c>
	<c>
		<c1 role="src" target="_12"/>
		<c1 role="dst" target="_11"/>
	</c>
</root>

 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.