Subject: Re: [xsl] xsl:analyze-string problem From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Thu, 08 Feb 2007 18:16:21 +0100 |
Hi XSLT 2.0 wizards,
while the syntax and semantics of xsl:analyze-string have become clear to me, I am now in search of an idiom implying it which it could help me solve this problem. (Or maybe of an alternative...)
In the input I find elements like these:
1) <e> def ghi</e> 2) <e> abc 22 def 3 ghi 1. </e> 3) <e> 2. </e> 4) <e> 3. def 35 78 ghi </e>
The possible contents fit into exactly 4 classes:
1) just some words and/or numbers 2) like 1), but followed by a number and a period 3) just a number and a period 4) like 3), but followed by some words and/or numbers
In each case, spaces may or may not appear at beginning and end of the content and must be preserved (no matter to which group they get attached).
The problem consists of replacing the original "e" element by creating new elements according to these rules:
A) A number followed by a period goes into a "ordinal" element.
B) Words and numbers go into a "text" element.
C) In cases 1) and 4), where words and numbers appear at the end, the content of the current "e" element must be concatenated with all adjacent "e" elements of type 1) and 2) before putting it all into the "text" element.
By contrast, in cases 2) and 3) which are ended by a number and a period the contents of the following "e" instance should never be appended.
What is not clear to me is:
- whether the regex actually suffices to match the rules
- if it is a good idea to use xsl:for-each there
- how to assure concatenation of all the "e" instances' contents in cases 1) and 4) without processing them repeatedly - i.e.: how can I restrict the call to xsl:apply-templates to cases 2) and 3)?
<text> def ghi</text> <text> abc 22 def 3 ghi </text> <ordinal start="" end="yes">1. </ordinal> <ordinal start="yes" end=""> 2.</ordinal> <text> </text> <ordinal start="yes" end=""> 3.</ordinal> <text> def 35 78 ghi </text>
Cheers, -- Abel
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] xsl:analyze-string proble, Michael Kay | Thread | [xsl] casting in xpath, Robert C Corsaro |
RE: [xsl] xsl:analyze-string proble, Michael Kay | Date | Re: [xsl] position()!=last() works , Sam Carleton |
Month |