RE: xsl parent [actually re preceding-sibling]

Subject: RE: xsl parent [actually re preceding-sibling]
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Wed, 15 Mar 2000 10:39:55 -0000
> here is my code:
> 
>      <xsl:variable name="POITEM">10</xsl:variable>

Not an error, but I'd suggest using <xsl:variable name="POITEM"
select="10"/> so it's a number rather than a result tree fragment.

>      <xsl:attribute name="quantity">
>  		<xsl:for-each select="/Table[@Name =
> 'PO_ITEM_ACCOUNT_ASSIGNMENT']/Record/Parameter">

A very strange select statement, you are asking for Table elements that are
immediate children of the root and that also satisfy some predicate; since a
well-formed document has only one child element of the root this will return
zero or one Table elements. OK if that's what you really want.

> 		 <xsl:if test="./@Name = 'PO_ITEM'">

"./" at the start of a path expression is redundant.

> 		 <xsl:variable name="POITEMTEMP"><xsl:value-of 
> select="."/></xsl:variable>
> 			 <xsl:if test="$POITEMTEMP=$POITEM">

Don't know why you are using a variable here, what's wrong with
test=".=$POITEM"?

> 			    <xsl:value-of
> select="preceding-sibling::node()[./@Name='QUANTITY']"/>

Nothing wrong with this. The "./" is redundant but does no harm. But in your
example this selects nothing because the PO_ITEM parameter is the first, so
it has no preceding siblings.

> 			 </xsl:if>
> 		 </xsl:if>
> 		</xsl:for-each>
> 	 </xsl:attribute>
>

Mike Kay 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread