Hi All,

Recently i have developed a new XSL file in altova XMLSpy , and the XSL version is 2.0.
When i tried the Transformation , in different environemt(without using XMLSpy), i am thrown with below error.

ERROR: 'Syntax error in 'descendant::element()'.'
FATAL ERROR: 'Could not compile stylesheet'
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(Unknown Source)
at xml.Xml2Html.main(Xml2Html.java:13)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:fo="http://www.w3.org/1999/XSL/Format"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:fn="http://www.w3.org/2005/xpath-functions">
	<xsl:template match="/">
		<html>
			<head>
				<title>test</title>
				<link href="tabs.css" rel="stylesheet"
					type="text/css">
				</link>
			</head>
			<body>

				<xsl:for-each select="/node()">
					<xsl:if test="descendant::element()">
						<ol id="toc">
							<xsl:choose>
								<xsl:when
									test="descendant::element()">
									<xsl:call-template name="parn" />
									<!-- This calls the Template named Parn->which fetches all the parent nodes!-->
								</xsl:when>
							</xsl:choose>

						</ol>
					</xsl:if>
					<xsl:if test="not(following-sibling::*)">
						<xsl:for-each
							select="following-sibling::node()">

							<li>
								<xsl:value-of select="local-name()"></xsl:value-of>
							</li>




						</xsl:for-each>

					</xsl:if>



					<!--<xsl:choose>
						<xsl:when test="parent::element() &lt; 0">
						
						<ul id="toc">
						<li> <xsl:value-of select="ancestor-or-self::node()"/></li>
						
						
						</ul>
						</xsl:when>
						<xsl:otherwise>
						
						<ul id="toc">
						<li><xsl:message>test</xsl:message></li>
						</ul>
						
						</xsl:otherwise>
						</xsl:choose>-->

				</xsl:for-each>

			</body>
		</html>

	</xsl:template>

	<xsl:template name="parn">

		<xsl:if test="descendant-or-self::element()">

			<xsl:for-each select="descendant-or-self::element()">

				<li>
					<a href="#">
						<xsl:value-of select="name(..)" />
					</a>
				</li>

				<div id="content">
					<p>
						<xsl:call-template name="attrs" /><!-- This calls the Template named attrs->which fetches all the attributes for each and every parent nodes!-->
					</p>


				</div>

			</xsl:for-each>


		</xsl:if>

	</xsl:template>


	<xsl:template name="attrs">
		<xsl:choose>
			<xsl:when test="not(count(attribute::*)=0)">

				<table border="0.5">
					<xsl:for-each select="node()" />
					<xsl:for-each select="attribute::*">
						<tr>
							<td>
								<label for="user">
									<xsl:value-of select="local-name()" />
								</label>
							</td>
							<td>
								<input type="text">
									<xsl:attribute name="id">
	  								<xsl:value-of
											select="local-name()" /> 
	  							</xsl:attribute>
									<xsl:attribute name="name">
	  								<xsl:value-of
											select="local-name()" /> 
	  							</xsl:attribute>
									<xsl:attribute name="value">
									<xsl:value-of select="." />
								</xsl:attribute>
								</input>
								<br />
							</td>
						</tr>
						<xsl:if
							test="not(position()=last() or last()=1)" />
					</xsl:for-each>

				</table>
			</xsl:when>
			<xsl:otherwise>
				<br />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>


</xsl:stylesheet>

Above is the XSL that i developed.

Frens..

Is that possible to apply many styles ..

1. Find the type of the node , if that node is Parent (Apply a style).

2. when the node is descendant, apply some other style..

Style , what i am talking abt is Nested Tabs.

it wud be better , if some 1 posts the style embedded in the above XSL. Above XSL is made of Identity Transformation.It can be tested with any XML file.

Thanks.

This article has been dead for over six months. Start a new discussion instead.