Subject: RE: [xsl] Template call question From: "Michael Kay" <mhk@xxxxxxxxx> Date: Mon, 28 Jun 2004 16:59:53 +0100 |
I haven't fully understood this, but I've made a few points where the code looks questionable. > I have the following xslt: > > > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:output method="xml" version="1.0" encoding="UTF-8" > indent="yes"/> > > <xsl:variable name="MYPARENT" > select="Redirect_URL_Comparison/QUERY1"/> > <xsl:template match="Redirect_URL_Comparison"> > > <table> > <xsl:variable name="ORG_URL" > select="QUERY1/row/VWCAMPAIGNREDIRECT.AR_URL"/> The QUERY1 has multiple rows, so this will select a set of elements. No problem with that, but because you used a singular variable name I'm not sure you're aware of it. > <xsl:variable name="NEW_URL" select="NONE"/> Since you have no elements named "NONE", this variable will be an empty node-set. Again, not intrisically wrong, so long as you know what you are doing. > <tr> > <td>name:</td> > <td> > <xsl:value-of > select="$MYPARENT/row/VWCAMPAIGNREDIRECT.AR_NAME"/> Because there are multiple rows, xsl:value-of (in XSLT 1.0) will output the value of this item in the first row. Is that what you intended? > <xsl:for-each select="QUERY1"> There is only one QUERY1 element in your data, so sorting the set of QUERY1 elements is not going to achieve much. > > <xsl:sort select="row/VWCAMPAIGNREDIRECT.AR_URL"/> > > <xsl:call-template name="get_url"> > <xsl:with-param name="PREV_URL"/> > <xsl:with-param name="CURR_URL" select="$ORG_URL"/> > </xsl:call-template> > </xsl:for-each> > </table> > > </xsl:template> > > > <xsl:template name="get_url"> > <xsl:param name="PREV_URL"/> > <xsl:param name="CURR_URL"/> > > <xsl:for-each > select="$MYPARENT/row[VWCAMPAIGNREDIRECT.AR_URL=$CURR_URL]"> In the xsl:for-each you're processing all the rows where this item is equal to $CURR_URL, which as noted earlier is actually a node-set containing all the values of VWCAMPAIGNREDIRECT.AR_URL. "=" returns true if the value matches any of these values, which it always will, because all the values are present in the set. > <tr> > <xsl:choose> > <xsl:when > test="((normalize-space($CURR_URL)=normalize-space(VWCAMPAIGNREDIRECT.AR_URL )) )"> Now you have me completely confused: you've selected nodes where A=$B, and now you're testing to see if normalize-space(A)=normalize-space($B). If two strings are equal, they will still be equal after normalizing whitespace, so the xsl:when branch will always be chosen. In fact it's more subtle than this, because normalize-space selects the first node in the node-set, but I think we're now so many errors deep that it's not worth further analysis. Michael Kay
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Template call question, Paria Heidari | Thread | value-of select="" on source XML wh, Jan Kohnert |
value-of select="" on source XML wh, Jan Kohnert | Date | RE: [xsl] value-of select="" on sou, Michael Kay |
Month |