RE: [xsl] aborting element creation

Subject: RE: [xsl] aborting element creation
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 10 Feb 2005 17:44:18 -0000
Actually, using xsl:element name="{EXPR}" with a bad element name is defined
in the spec to be a recoverable error, and the recovery action is exactly as
you describe. But it's implementation-dependent whether a product reports
the error or takes the recovery action, and in my view this is one of those
errors that really ought to be fatal.

Use conditional logic in your stylesheet, it's a much better solution. I
would do it using multiple template rules, as I suggested, not with an
xsl:choose conditional.

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

> -----Original Message-----
> From: Joris Gillis [mailto:roac@xxxxxxxxxx] 
> Sent: 10 February 2005 17:25
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] aborting element creation
> 
> 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