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

RE: regexp question

Subject: RE: regexp question
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Sun, 12 Sep 2004 22:09:25 +0100
xsl regexp
I would do it like this:

<xsl:template match="img[matches(@src, '.*dropcap/.\.gif')]" mode="dropcap">
  <xsl:value-of select="@alt"/>
</xsl:template>

<xsl:template match="xhtml:p">
  <xsl:variable name="temp">
    <xsl:apply-templates mode="dropcap"/>
  </xsl:variable>
    <p>
      <xsl:analyze-string flags="s" select="string($temp)" 
 regex='&quot;(.*?)&quot;'>
        <xsl:matching-substring>
 	<q><xsl:value-of select="regex-group(1)"/></q>
        </xsl:matching-substring>
        <xsl:non-matching-substring>
 	<xsl:value-of select="."/>
        </xsl:non-matching-substring>
      </xsl:analyze-string>
    </p>
 </xsl:template>
 
> 
> Within paragraphs, there are just two things I want to do: 1) convert 
> fake quotes to <q> elements, and b) to change graphic dropcaps like 
> this ...
> 
>          <p><img 
> src="http://graphics7.nytimes.com/images/dropcap/m.gif"
>          width="37" height="33" align="left" border="0" 
> alt="M" />OSCOW,
>          ....</p>
> 
> .... to text. 
> 
> Also, is there some reasonably reliable way -- again using 
> xslt 2.0 -- 
> to take this ...
> 
>    <meta name="byl" content="By C. J. CHIVERS and STEVEN LEE MYERS" />
> 
> .... and turn it into this:
> 
>    <meta name="author" content="Chivers, C. J." />
>    <meta name="author" content="Myers, Steven Lee" />
> 

It all depends on how wide the variations are in your source data. If you
want to do the above, while also changing "BOB DU CHARME" to "du Charme,
Bob", then you have got an interesting challenge on your hands. Try to
define the algorithm you want to use before you start asking how to code it
in XSLT.

Michael Kay

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.