|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Re: How to match a element + part of an immediate
I'm pretty new to XSL myself, so I will probably be corrected. I am not
aware functionality that can select a specific word based on the order
it is within a node. The only way I know to do that is with
substring-before and substring-after.
This HTML/XML:
<p> the quick
<em>brown</em>
fox jumps
</p>
Transformed with this Style Sheet:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:template match="p">
<html>
<p>
<xsl:value-of select="concat(' ',
substring-before(substring-after(., ' '), ' '), ' ')"/>
<em>
<xsl:value-of
select="substring-before(substring-after(substring-after(., ' '), ' '),
em)"/>
<xsl:value-of select="concat(' ', em, '
')"/>
<xsl:value-of
select="substring-before(substring-after(., em), ' ')"/>
</em>
<xsl:value-of select="concat(' ',
substring-after(substring-after(., em), ' '))"/>
</p>
</html>
</xsl:template>
</xsl:stylesheet>
Produces this HTML source code with MSXML:
<html xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<p> the <em>quick
brown
fox</em> jumps
</p>
</html>
-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Chulsung Kim
Sent: Tuesday, January 13, 2004 11:15 PM
To: xsl-list
Subject: Re: How to match a element + part of an immediate text
sibling?
Sorry for the newbie question. I did search the archive, but I guess I
just
didn't know what keywords to use.
Say you are doing an HTML-to-HTML transformation and you want to
transform:
<p> the quick <em>brown</em> fox jumps </p>to:
<p> the <em>quick brown fox</em> jumps </p>How would you match the <em>
element and the two words immediately surrounding it, so you can
rearrange
them in the template? Or would you match p[em] instead and then
rearrange
its children somehow?
Thanks,
Chulsung Kim
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








