p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   text and child nodes (http://p2p.wrox.com/showthread.php?t=67252)

eepyoga April 8th, 2008 12:37 PM

text and child nodes
 
Hi everybody,

here's my problem...
I have a piece of XML:
...
<article>
  <emphasis>(</emphasis><ndr>1</ndr><emphasis>)</emphasis>
My TEXT
<emphasis>(</emphasis><ndr>2</ndr><emphasis>)</emphasis>
</article>
...

I should use a XSLT 1.0 to transform it and apply templates for the children emphasis-ndr-emphasis preceding "My TEXT", then write "my TEXT" and finally apply templates for the children emphasis-ndr-emphasis following "My TEXT".
The number of children emphasis-ndr-emphasis preceding or following "My TEXT" may vary.

How can I do that??

Any help would be appreciated.
Thanks a lot!

EePy.



Martin Honnen April 8th, 2008 12:45 PM

Code:

<xsl:template match="article">
  <xsl:apply-templates
    select="*[following-sibling::text()[. = 'My TEXT']]" mode="mode1"/>
  <xsl:apply-templates select="text()[. = 'My TEXT']"/>
  <xsl:apply-templates
    select="*[preceding-sibling::text()[. = 'My TEXT']]" mode="mode2"/>
</xsl:template>

--
  Martin Honnen
  Microsoft MVP - XML


All times are GMT -4. The time now is 04:45 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.