RE: [xsl] Glossary Help

Subject: RE: [xsl] Glossary Help
From: "Shailesh Shinde" <shailesh@xxxxxxxxxxxx>
Date: Sat, 29 Jul 2006 15:22:27 +0530
Hi,

Migrating glossary xsl code to main xsl----which copies source xml to
outputxml with Updates of glossary elements in outputxml, but getting output
with no contents in divisions. Except glossary. What changes will required?

XSL for the same......

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="xml" indent="yes"/>
	<xsl:template match="*">
		<xsl:copy>
			<xsl:copy-of select="@*"/>
			<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>
	
	<xsl:template match="division">
	<xsl:if test="@type='appendix'">
		<division>
			<xsl:copy-of select="@*"/>
			<xsl:for-each select="topic">
				<topic>
					<xsl:copy-of select="@*"/>
					<xsl:copy-of select="title"/>
					<xsl:apply-templates select="body"/>
				</topic>
			</xsl:for-each>
		</division>
		</xsl:if>
	</xsl:template>
	<xsl:template match="body">
		<glossarylist>
			<!--xsl:apply-templates
select="p/i/b[not(../../text())]" /-->
			<xsl:apply-templates select="p[not(text())]/i/b"/>
			<xsl:apply-templates select="p/i/b[../../text()]"/>
			<xsl:apply-templates select="p/b[not(../text())]"/>
			<xsl:apply-templates select="p/b[../text()]"/>
		</glossarylist>
	</xsl:template>
	<xsl:template match="p/i/b[not(../../text())]">
		<glossarydiv>
			<xsl:value-of select="."/>
		</glossarydiv>
	</xsl:template>
	<xsl:template match="p/i/b[../../text()]">
		<glossaryentry>
			<glossaryterm>
				<xsl:value-of select="."/>
			</glossaryterm>
			<glossarydef>
				<xsl:value-of select="../../text()"/>
			</glossarydef>
		</glossaryentry>
	</xsl:template>
	<xsl:template match="p/b[not(../text())]">
		<glossarydiv>
			<xsl:value-of select="."/>
		</glossarydiv>
	</xsl:template>
	<xsl:template match="p/b[../text()]">
		<glossaryentry>
			<glossaryterm>
				<xsl:value-of select="."/>
			</glossaryterm>
			<glossarydef>
				<xsl:value-of select="../text()"/>
			</glossarydef>
		</glossaryentry>
	</xsl:template>
</xsl:stylesheet>

-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx] 
Sent: Saturday, July 29, 2006 2:59 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Glossary Help

>     <xsl:apply-templates select="p/i/b[not(../../text())]" />

Another example - two in one morning, apparently independent - of the
predicate being moved quite unnecessarily to the last step in a path
expression. Write:

<xsl:apply-templates select="p[not(text())]/i/b" />

Michael Kay
http://www.saxonica.com/

Current Thread