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

Conflicting templates?

Subject: Conflicting templates?
From: "Robert Soesemann" <rsoesemann@xxxxxxxxxxx>
Date: Fri, 17 Dec 2004 12:25:24 +0100
xsl conflicting templates
It seems that there is a conflict between the two templates in the
following xsl.

The first one adds the xsd association and the second iterates over all
node and convert @name @type values to element names if available. But
the new attribute does not appear in the result document although I copy
attributes with <xsl:copy-of>. Is there a conflict between the
templates?

Robert
---


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<!-- Include global XSL message template -->
	<xsl:include href="globals.xsl"/>

	<!-- Parameter will be filled by ant target -->
	<xsl:param name="validator-url" />


	<!-- 1. Add XMLSchema sssociation to root node -->
	<xsl:template match="/*">
		<xsl:copy>
			<!-- add association to general kiwi validator
xsd -->
			<xsl:attribute
name="xsi:noNamespaceSchemaLocation">
				<xsl:value-of select="$validator-url"/>
			</xsl:attribute>

			<xsl:copy-of select="@*"/>
			<xsl:apply-templates />
		</xsl:copy>
	</xsl:template>

 	<xsl:template match="node()[starts-with(name(),'my-')">
		<xsl:variable name="element-name">
			<xsl:choose>
				<xsl:when test="@name != ''">
					<xsl:value-of select="@name"/>
				</xsl:when>
				<xsl:when test="@type != ''">
					<xsl:value-of select="@type"/>
				</xsl:when>
				<xsl:otherwise></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$element-name != ''">
				<xsl:element name="{$element-name}">
					<xsl:copy-of select="@*"/>
					<xsl:apply-templates />
				</xsl:element>
			</xsl:when>
			<xsl:otherwise>
				<xsl:copy>
					<xsl:copy-of select="@*"/>
					<xsl:apply-templates />
				</xsl:copy>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Freitag, 17. Dezember 2004 11:39
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Add attribute to root node



root nodes (/) represent the whole document and can not have attributes,
the children of the root node are the top level element and any
commeents or processing instructions that occur before or after that
element.

presumably you want to add an attribute to the top level element which
is /* not /

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. For more information on a proactive anti-virus
service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.