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[(_at_)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