[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] aborting element creation


Subject: Re: [xsl] aborting element creation
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Thu, 10 Feb 2005 18:24:39 +0100

Thanks for answering.

Tempore 18:01:03, die 02/10/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Michael Kay <mike@xxxxxxxxxxxx>:

I've no idea what you mean by "with no decisive structure or pattern
matching", or why you want to constrain the solution, but the obvious way to
solve your problem is by have two template rules one with match="node" and one with match="node[@encapsulate]".
This is what I mean with "pattern matching". (Sorry, I'm quite bad at using correct terminology)
It solves of course my trivial and fictional XML problem, but is no answer to my real question (which I might have asked in a non-intelligible manner).


Your template, when it processes a node with no @encapsulate attribute, is generating an element whose name is "", which will obviously fail.
Indeed, but why can't the 'xsl:element' not just do nothing instead of raising an error when the name is empty?

So that this template:

<xsl:template match="/">
	<root>
		<xsl:element name="">
			<node/>
		</xsl:element>
	</root>
</xsl:template>

would generate the same result as:

<xsl:template match="/">
	<root>
		<node/>
	</root>
</xsl:template>

So <xsl:element name=""/> would be treated somewhat like <xsl:for-each select="."/>


I know XSL1.0 does not behave like this; I wanted to know if XSL2.0 did, or if there were tricks to simulate the behaviour without 'xsl:test' or XPath testing.



regards, -- Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041) Vincit omnia simplicitas Keep it simple


Current Thread
Keywords