Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 9th, 2005, 08:47 AM
Registered User
 
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default create an element using a variable for the name

I have this xml.
the name attribute values are not known and could contain any value

<tag name="indexes">
    <tag name="scro_number">S29811/94Q</tag>
    <tag name="subject_surname">DICKIE</tag>
    <tag name="keywords">DICKIE</tag>
    <tag name="case_number">BA05001553</tag>
    <tag name="office_code">BA</tag>
    <tag name="date_of_receipt">2005-10-07</tag>
    <tag name="witness_seq_no">1</tag>
</tag>

and want to generate this

<indexes>
    <scro_number>S29811/94Q</scro_number>
    <subject_surname>DICKIE</subject_surname>
    <keywords>DICKIE</keywords>
    <case_number>BA05001553</case_number>
    <office_code>BA</office_code>
    <date_of_receipt>2005-10-07</date_of_receipt>
    <witness_seq_no>1</witness_seq_no>
</indexes>

I hwve tried to create a new element using the name attribute to give it a name

<xsl:element>
  <xsl:attribute name="name"><xsl:value-of select="@name"></xsl:attribute>
</xsl:element>

but it appears that the element must have a fixed name

Any ideas??


 
Old December 9th, 2005, 09:04 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

<xsl:element name="{$name}">



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old December 9th, 2005, 09:46 AM
Registered User
 
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Variable for xsl:element Name Belch XSLT 5 November 2nd, 2007 04:28 AM
create XML element with namespace MikeLI Pro Visual Basic 2005 2 June 29th, 2006 08:33 PM
Can I create a class from a variable? MAtkins General .NET 2 August 1st, 2005 11:57 AM
create a new variable in javascript crmpicco Classic ASP Basics 2 February 2nd, 2005 12:53 PM
how to create Global Variable VIshwastrivedi SQL Server 2000 5 September 30th, 2004 08:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.