Subject: Re: [xsl] Writing array elements based on a an evaluation of one of the child elements|
From: "Jon Gorman" <jonathan.gorman@xxxxxxxxx>
Date: Wed, 24 May 2006 07:35:36 -0500
So now I have...
<xsl:template match = "ACCOUNT-LIST"> <xsl:if test="string-length(ACCOUNT-NO/text() > 0)"> <xsl:element name = "ACCOUNT-LIST"> <xsl:for-each select="."/> </xsl:element> </xsl:if> </xsl:template>
and this writes a whole bunch of empty <ACCOUNT-LIST> elements Which I guess is happening
^^^^^^^^^^^^^^ Well, guessing isn't going to help much.
because somehow I'm not refering to the correct occurence of the ACCOUNT-NO
child > > node I'm dealing with? And I'll need some xsl:for-each logic Why the for-each? Why wouldn't you be referring to the correct occurence. Not likely we'll know unless you actually show the input.
I see the xsl above as saying...the current node (ACCOUNT-LIST).
When you see the ACCOUNT-LIST element 1) check if the child element ACCOUNT-NO has a text length gt; 0 2) If yes write an element called ACCOUNT-LIST that has all the values of
Well, change 1) to say check if the first text child of ACCOUNT-NO has a length of 0, which David Carlisle already pointed out is pointless since it wouldn't be created if it didn't.
I guess I'm mising a whole chunk that specifies the current occurence^^^ that darn word again.
Well, without any example of input and only having vaguely folllowed this thread, I'll have to do some guess of my own.
What is the text length between the dashes?: - - What is the text length between these dashes?: - -
The point I'm trying to make is that XSLT will count the whitespace. If you think it shouldn't, you need to tell it not too. Notice too you've ignored the advice of several people on the list and are still just getting the first text node. If you read the specs you'll find more information about string manipulation and how to get the string value. (The xslt 1.0 really is readable) The short answer can also be found in the FAQ (Under Empty Elements -> Testing for Empty elements). You need to normalize the space of the text value of the element.
Also it sounds like you'll always create Account-List but not necessarily Account-No. So why are you bothering with that this in the template for account list?
<xsl:template match="ACCOUNT-LIST"> <xsl:copy> <xsl:apply-templates /> </xsl:copy> </xsl:template>
<xsl:template match="ACCOUNT-NO"> <xsl:if test="normalized-space(.)"> <xsl:copy> <xsl:apply-templates /> </xsl:copy> </xsl:if> </xsl:template>
Now if you want to make sure you understand the points, make sure you understand the difference between getting the string value of ACCOUNT-NO and getting the child text nodes of ACCOUNT-NO. Then remember that whitespace counts in XML since one of it's roles is in the markup of documents.
the child elements----- Original Message ---- From: Florent Georges <darkman_spam@xxxxxxxx> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Sent: Wednesday, 24 May, 2006 1:31:01 PM Subject: Re: [xsl] Writing array elements based on a an evaluation of one of
neil cave wrote:
> THat and the fact that I should be evaluating
> string-length(//ACCOUNT-NO/text()) > 0 )
It depends on your input type and on what you want exactly to test. But in this case, I think you can just test the presence of the text nodes (not their length being gt 0). It looks quite strange to me to test on all ACCOUNT-NO in the document. But you're the only one that knows.
___________________________________________________________________________ Yahoo! Mail riinvente le mail ! Dicouvrez le nouveau Yahoo! Mail et son
|<- Previous||Index||Next ->|
|Re: [xsl] Writing array elements ba, Wendell Piez||Thread||[xsl] XPath "none" /type/ not avail, Florent Georges|
|Re: [xsl] Writing array elements ba, neil cave||Date||Re: [xsl] XPath "none" /type/ not a, Florent Georges|