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

How to get preceding-siblings that appear before a ce

Subject: How to get preceding-siblings that appear before a certain text
From: UlyLee <ulyleeka@xxxxxxxxx>
Date: Thu, 29 Sep 2005 04:19:38 -0700 (PDT)
xsl preceding siblings
Hi!

I have this source file:

<test>
<p>Aaron<xref>test1</xref>
<xref>test2</xref> Abraham<xref>test3</xref> Adam and
Eve<xref>test4</xref> Adam<xref>test5</xref>
</p>
</test>

and a xsl file like these:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes">
<xsl:character-map name="map">
<xsl:output-character character="&amp;"
string="&amp;"/>
</xsl:character-map>
<xsl:output method="xml" version="1.0"
encoding="UTF-8" indent="yes"
use-character-maps="map"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{name(.)}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

<xsl:template match="p">
<xsl:for-each select="text()">
<xsl:element name="indexterm">
<xsl:attribute name="sort"><xsl:value-of
select="."/></xsl:attribute>
<xsl:attribute name="type">name</xsl:attribute>
<xsl:element name="headword"><xsl:value-of
select="."/></xsl:element>
<xsl:element name="indextermbody">
<xsl:element name="p">
<xsl:apply-templates
select="following-sibling::xref"/>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

And want an output like this:

<test>
<indexterm sort="Aaron" type="name">
<headword>Aaron</headword>
<indextermbody>
<p><xref>test1</xref><xref>test2</xref></p>
</indextermbody>
</indexterm>
<indexterm sort=" Abraham" type="name">
<headword> Abraham</headword>
<indextermbody>
<p><xref>test3</xref></p>
</indextermbody>
</indexterm>
<indexterm sort=" Adam and Eve" type="name">
<headword> Adam and Eve</headword>
<indextermbody>
<p><xref>test4</xref></p>
</indextermbody>
</indexterm>
<indexterm sort=" Adam" type="name">
<headword> Adam</headword>
<indextermbody>
<p><xref>test5</xref></p>
</indextermbody>
</indexterm>
</test>

But what i'm getting, because of the
following-sibling::xref, all of the xref and not the
xref that that appear before the next text() node. Is
there a way to achieve this?

-- UlyLee


		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

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.