Perhaps you meant to use an attribute value template (AVT)?

<xsl:template match="*">
  <xsl:element name="{local-name()}" />
</xsl:template>

Attributes which are interpreted as AVTs are indicated as such in the
recommendation.  See:

   http://www.w3.org/TR/xslt#dt-attribute-value-template

and the paragraph following the one you quoted:

   http://www.w3.org/TR/xslt#section-Creating-Elements-with-xsl:element

   "The name attribute is interpreted as an attribute value template. It is
   an error if the string that results from instantiating the attribute
   value template is not a QName."

Dave



                                                                                
                              
                      "Phil Rice"                                               
                              
                      <[EMAIL PROTECTED]         To:      <[EMAIL PROTECTED]>   
                     
                      ow.com>                  cc:      (bcc: David N 
Bertoni/Cambridge/IBM)                  
                                               Subject: Can the <xsl:element> 
have a name attribute that is   
                      02/20/2002 01:48         dynamic?                         
                              
                      AM                                                        
                              
                                                                                
                              
                                                                                
                              



I have tried the following:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version
="1.0">
<xsl:template match="*">
  <xsl:element name="local-name()" />
</xsl:template>
</xsl:stylesheet>


I was expecting to get a single element with a name of the top element.
Unfortunately I got

<?xml version="1.0" encoding="UTF-8"?>
file:///C:/WINDOWS/jbproject/XMLTransformation/calls.xsl; Line 4; Column
38; Illegal value used for attribute name: local-name()

When I replace the offending xsl:element line with   <xsl:value-of select
="local-name()" /> I get:

<?xml version="1.0" encoding="UTF-8"?>
PHONE_RECORDS


As I understand the specification:
"The xsl:element instruction allows an element to be created with a
computed name. The expanded QName of the element to be created is specified
by a required name attribute and an optional namespace attribute."

I am probably being naive, but I would appreciate any help

Phil Rice




Reply via email to