Subject: Re: [xsl] XPath (regex?) question about $& in an XSLT stylesheet From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 18 Aug 2008 19:07:34 -0400 |
I have an element <Person>Benes (senior), Frances</Person>.
I can remove the '(senior)' from the data using <xsl:value-of select="replace(., '\([a-zA-Z]+\)', ' ' )"/>
which gives me <Person>Benes , Frances</Person> but I want just the opposite: <Person>(senior)</Person>
t:\ftemp>type wilson.xml <Person>Benes (senior), Frances</Person>
t:\ftemp>type wilson.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="*"> <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}"> <xsl:value-of select="replace(., '(.*)(\([a-zA-Z]+\))(.*)', '$2' )"/> </xsl:element> </xsl:template>
</xsl:stylesheet> t:\ftemp>xslt2 wilson.xml wilson.xsl con <?xml version="1.0" encoding="UTF-8"?><Person>(senior)</Person> t:\ftemp>
-- Upcoming XSLT/XSL-FO hands-on courses: Wellington, NZ 2009-01 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XPath (regex?) question about, Mark Wilson | Thread | Re: [xsl] XPath (regex?) question a, G. Ken Holman |
[xsl] XPath (regex?) question about, Mark Wilson | Date | Re: [xsl] XPath (regex?) question a, G. Ken Holman |
Month |