This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: xsl-element not allowed directly below xsl-stylesheet?


Since xsl:element is not a top level element,it cannot be a direct child of xsl:stylesheet.
The following are top level elements
___________________

<xsl:attribute-set>
<xsl:decimal-format>
<xsl:include>
<xsl:key match>
<xsl:namespace-alias>
<xsl:output>
<xsl:param>
<xsl:preserve-space>
<xsl:strip-space>
<xsl:template>
<xsl:variable>
________________

So you should call <xsl:apply-templates> matching each of the form-elements within a <xsl:template> and then define the template with a corresponding match..

The following code will help you..
for example
if your xml looks like
<?xml version="1.0"?>
<root>
<form1>form1</form1>
<form2>form2</form2>
<form3>form3</form3>
</root>

Now your xsl would be..

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="root">
<forms>
<form1>
<xsl:apply-templates select="form1"/>
</form1>
<xsl:element name="forms2-3">
<xsl:apply-templates select="form2|form3"/>
</xsl:element>
</forms>
</xsl:template>
<xsl:template match="form1">
<xsl:value-of select = "."/>
</xsl:template>
<xsl:template match="form2">
<xsl:value-of select = "."/>
</xsl:template>
<xsl:template match="form3">
<xsl:value-of select = "."/>
</xsl:template>
</xsl:stylesheet>

the following is the result of the transformation..

<?xml version="1.0" encoding="UTF-16" ?>
<forms>
<form1>form1</form1>
<forms2-3>form2form3</forms2-3>
</forms>

Hope this helps
Vasu

From: "Christer Nordvik" <christer.nordvik@trafsys.no>
Reply-To: xsl-list@lists.mulberrytech.com
To: <xsl-list@lists.mulberrytech.com>
Subject: [xsl] xsl-element not allowed directly below xsl-stylesheet?
Date: Tue, 13 Aug 2002 10:33:02 +0200

I have an XSL stylesheet that have the structure:

<xsl:stylesheet>

 <xsl:template match="form1">
	...
 </xsl:template>

 <xsl:template match="form2">
    	...
 </xsl:template>

 <xsl:template match="form3">
   	...
 </xsl:template>

</xsl:stylesheet>

And now I need an element tag that starts before form2 and ends after
form3. But when I try to include an <xsl:element> before the
<xsl:template> tag I get an error saying that <xsl:stylesheet> can't
contain <xsl:element> tags.

Is there any other way of specifying an element?

Best Regards,

Christer Nordvik



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]