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

RE: Complex Template Match

Subject: RE: Complex Template Match
From: "Karl J. Stubsjoen" <karl@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Jul 2004 14:43:29 -0700
template match
I have come up with a For-Each solution:

<xsl:template match="ENTRIES_TEMPLATE" mode="PRINTER_FRIENDLY">
	<form action="{$DOC_ACTION}" method="POST">
	<table style="width:{@width};">
		<!-- build header row -->
        <tr><th>&nbsp;</th>
        <xsl:apply-templates select="Entry[1]/Element"
mode="ENTRY_HEADER"/></tr>

 <!-- [[[[[[ FOR EACH SOLUTION ]]]]]]] -->

        <xsl:for-each select="Entry">
	   <xsl:variable name="element_name"><xsl:value-of
select="concat('competitor_name_',position())"/></xsl:variable>
            <xsl:if
test="string($BROWSER_VARS//ELEMENT[@name=$element_name]/.)">
            	<tr>
			  <xsl:apply-templates select="Element" mode="PRINTER_FRIENDLY">
                    	<xsl:with-param name="position"><xsl:value-of
select="position()"/></xsl:with-param>
                    </xsl:apply-templates>
                  </tr>
            </xsl:if>
        </xsl:for-each>


 <!-- [[[[[[ END FOR EACH SOLUTION ]]]]]]] -->


    </table>
    	<input type="hidden" name="ax" value="0"/>
    </form>
</xsl:template>


-----Original Message-----
From: Karl J. Stubsjoen [mailto:karl@xxxxxxxxxxxxxxxxxxxx]
Sent: Thursday, July 22, 2004 2:12 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Complex Template Match


Hello,

I have a complicated match... and complicated to explain, but I will try.
I pass 2 XML sources to a stylesheet:

BROWSER_VARS
ENTRY_TEMPLATE


ENTRY_TEMPLATE will have 50 nodes that match "ENTRY".
BROWSER_VARS will have 1-50 "ELEMENT" entries.

I "apply-templates" on $ENTRY_TEMPLATE//Entry/Element.  (I could
apply-templates on BROWSER_VARS but there is no way to perform a lookup from
BROWSER_VARS to ENTRY_TEMPLATE).

The lookup "match" I do from and ENTRY element to BROWSER_VARS is a
concatenation of the name element of ENTRY and the position() against the
BROWSER_VARS/ELEMENT name attribute.  It looks like this:


=== TEMPLATE MATCH SNIPPET ===
<xsl:template match="Element">
<xsl:variable name="element_name"><xsl:value-of
select="concat(@name,'_',$position)"/></xsl:variable>

<xsl:value-of select="$BROWSER_VARS//ELEMENT[@name=$element_name]/."/>


With all of that said, I'd like to change the following "apply-templates"
rule:
    	<xsl:apply-templates select="Element"/>

To include only "Element"(s) who have a $BROWSWER_VARS//ELEMENT match.
Is this possible?

Karl

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.