Subject: Re: Using analyze-string to add tabs
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Tue, 20 Sep 2011 12:07:56 +0100
|
The regex attribute of xsl:analyze-string is an attribute value
template, so if it contains curly braces they must be doubled.
People sometimes find it more convenient to put the regex in a variable,
and then use regex="{$regex}".
Michael Kay
Saxonica
On 20/09/2011 09:39, Jeff Wilson wrote:
Good morning,
I'm just trying to add tabs to the text of certain elements. It seems
to be much harder than I anticipated.
Any help would be greatly appreciated.
Thanks,
Jeff
Input:
<root>
<ListNumbered aid:pstyle="ListNumbered">1.To access the native file
readers menu, navigate to Global Options File Readers.</ListNumbered>
<ListNumbered aid:pstyle="ListNumbered">2.In the Options Editor,
expand the File Readers hierarchy on the left, as shown in Figure
2.4.</ListNumbered>
</root>
Desired output:
<root>
<ListNumbered>	1.	To access the native file readers menu,
navigate to Global Options File Readers.</ListNumbered>
<ListNumbered>	2	.In the Options Editor, expand the File
Readers hierarchy on the left, as shown in Figure 2.4.</ListNumbered>
</root>
XSLT to date, but I'm stumped:
<xsl:for-each select="current-group()">
<xsl:choose>
<xsl:when test="contains(@aid:pstyle, 'ListNumbered')">
<xsl:analyze-string select="." regex="(\d{1,3}\.)(.*?)">
<xsl:matching-substring>
<xsl:text>	</xsl:text><xsl:value-of
select="regex-group(1)"/><xsl:text>	</xsl:text><xsl:value-of
select="regex-group(2)"/></xsl:element><xsl:text>
</xsl:text>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:when>
<xsl:choose>
</xsl:for-each>
|