[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: analyze-string question
David,
When I revisited the solution that I proposed, I noticed some redundancy (xsl:choose) in the function my:wrap-nested. Please find the reworked solution below. Th solution succeeds at nesting the alts by virtue of the greediness of the '.+' regex. If there is no prior markup in an alt group (no <stress>, in particular), it will select the outermost bracket pair and then process whats between the brackets recursively. But it cannot, unfortunately, mitigate the risk of ambiguous input (when alt forms are allowed to start with vowels and when there are no other rules to unequivocally discern stressing markup from alt markup). Gerrit
<xsl:template match="p"> <xsl:copy> <xsl:sequence select="my:wrap-nested(., '<([^aeiou].+)>')"/> </xsl:copy> </xsl:template> <xsl:function name="my:wrap-nested" as="node()*"> <xsl:param name="string" as="xs:string" /> <xsl:param name="regex" as="xs:string" /> <xsl:analyze-string select="$string" regex="{$regex}" flags="i"> <xsl:matching-substring> <alt> <xsl:sequence select="my:wrap-nested(regex-group(1), $regex)"/> </alt> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:sequence select="my:stress(.)"/> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:function> <xsl:function name="my:stress" as="node()*"> <xsl:param name="string" as="xs:string" /> <xsl:analyze-string select="$string" regex="<([aeiou])" flags="i"> <xsl:matching-substring> <stress> <xsl:value-of select="regex-group(1)"/> </stress> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:function> </xsl:stylesheet> On 2012-10-27 14:45, Birnbaum, David J wrote: Dear XSLT List,
Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930 Geschdftsf|hrer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt, Dr. Reinhard Vvckler
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|