xsl-list
[Top] [All Lists]

Re: regexp question

2004-09-12 14:40:19
On Sep 12, 2004, at 5:09 PM, Michael Kay wrote:

I would do it like this:

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

That worked, once I added the namespace prefix.

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.

I'm willing to let Bob's name get a bit mangled. I can always manually correct stuff that falls thought the cracks occasionally.

The most important thing is to get "surname, forename" so that I can more easily query and transform that later (into more finely parsed bibliographic records, for example). While there will be exceptions to this rule, I'm content enough to just say:

        -   a name is all caps
        -   within a name the last name is the surname
        -   anything before that are the forenames
        -   multiple names are delimited by either ", " or " and "

Titlecasing would be nice (though I note there's no such function in XSLT 2.0).

Bruce



<Prev in Thread] Current Thread [Next in Thread>