[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

[xslt2] matching matches

Subject: [xslt2] matching matches
From: Tobias Reif <tobiasreif@xxxxxxxxxxxxx>
Date: Mon, 30 Dec 2002 16:18:24 +0100
t matching
Hi :)

I'm writing an XSLT2 transformation to go from a code listing such as

[...]
007     &lt;title&gt;Sirup&lt;/title&gt;
[...]

to something like this:
(output of current state of the templates)

[...]
007 <span class="tag">&lt;<span class="tagname">title</span>&gt;</span>Sirup<span class="tag">&lt;/<span class="tagname">title</span>&gt;</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="&lt;(\/?)([^\s&gt;\!]+)([^&gt;]+)?&gt;">
      <t:matching-substring>
        <span class="tag">
          <t:text>&lt;</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>&gt;</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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.