[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
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="&" string="&"/> </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
|
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
|