|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] [xslt2] matching matches
Hi :)
I'm writing an XSLT2 transformation to go from a code listing such as [...] 007 <title>Sirup</title> [...] to something like this: (output of current state of the templates) [...] 007 <span class="tag"><<span class="tagname">title</span>></span>Sirup<span class="tag"></<span class="tagname">title</span>></span> [...] The code listings get marked up, so that I can so syntax highlighting via CSS. I'm using Saxon 7.3.1. Now I want to markup the attributes, as .attribute_name and .attribute_value. What I'm trying now is to call a second template with the string that consists of all the attributes, to get a marked up version returned. But somehow the match is not passed to the second template. Any help appreciated :) ##### (all regexen etc are unfinished) #####
<t:template match="code[@class='screen']">
<t:copy>
<t:for-each select="@*">
<t:copy/>
</t:for-each>
<t:analyze-string select="."
regex="<(\/?)([^\s>\!]+)([^>]+)?>">
<t:matching-substring>
<span class="tag">
<t:text><</t:text>
<t:value-of select="regex-group(1)"/>
<span class="tagname">
<t:value-of select="regex-group(2)"/>
</span>
<!--
returns all attributes, not marked up
<t:value-of select="regex-group(3)"/>
-->
<!--
<t:message>
regex-group(3): <t:value-of select="regex-group(3)"/>
</t:message>
-->
<!-- nothing gets returned here :| -->
<t:call-template name="markup_attributes">
<with-param name="input"
select="regex-group(3)"/>
</t:call-template>
<t:text>></t:text>
</span>
</t:matching-substring>
<t:non-matching-substring>
<t:value-of select="."/>
</t:non-matching-substring>
</t:analyze-string>
</t:copy>
</t:template><t:template name="markup_attributes">
<t:param name="input"/>
<!--
<t:message>
$input: <t:value-of select="$input"/>
</t:message>
-->
<t:analyze-string select="$input"
regex="\s+([^=]+)=">
<t:matching-substring>
<span class="attribute_name">
<t:value-of select="regex-group(1)"/>
<t:text>=</t:text>
</span>
</t:matching-substring>
<t:non-matching-substring>
<t:value-of select="."/>
</t:non-matching-substring>
</t:analyze-string>
</t:template>
##### (end) #####Tobi -- http://www.pinkjuice.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|

Cart








