Rob Newman wrote:
Hi All,
I am trying to parse the contents of <pfstring> to get the 5th column
("TA_D03A" in the example), the 10th ("regular internet") and the 11th
("hosted") for each line and push it to "output.xml" thus:
<snip />
Each entry in input.xml/pfarr/pfstring is on a new line. I am trying
to use the regex functions and have the following, but it does not
seem to be working:
<xsl:analyze-string select="$elValue"
regex="\s*(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+(.*)\s+\n">
You seem to be trying to capture it all at once. But you are not taking
into consideration the basic greediness of any regular expression (this
is explained, for instance, on www.regular-expressions.info). Instead of
trying to match it all at once, there's (in your case) a much simpler
way to match this:
<xsl:for-each select="tokenize($elValue, '\n')">
<xsl:for-each select="tokenize($elValue, '\s+')">
do your stuff
</xsl:for-each>
</xsl:for-each>
You may want to put the second for-each in a variable, which makes for
easy reference by index:
<xsl:for-each select="tokenize($elValue, '\n')">
<xsl:variable select="tokenize($elValue, '\s+')" name="values" />
do your stuff with $values
</xsl:for-each>
HTH,
Cheers,
-- Abel
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--