• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

set Attributes with XSLT

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Its very easy to accesd Attributest with @ , but how about setting
Attributes ?
following example
<xsl:variable name="currentValue">
testvalue
</xsl:variable>
<NEWTAG Attribute="$currentValue">somevalue</NEWTAG>
ouput is :

<NEWTAG Attribute="$currentValue">somevalue</NEWTAG>
but should be
<NEWTAG Attribute="somevalue">somevalue</NEWTAG>
it isnt working this way - how can i put the value within this
variable in the tag <NEWTAG>
thx and bye,
Holger
 
Holger Prause
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<xsl:variable name="currentValue">
testvalue
</xsl:variable>
<NEWTAG>
<xsl:attribute name="Attribute">
<xsl:value-of select="$currentValue"/>
</xsl:attribute>
somevalue</NEWTAG>
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Holger's response makes a good point. For the sake of reusability and modularity, I always try to use the xsl: methods to create elements, text, and so on, rather than simply embedding the tags and text in the stylesheet. This makes it much easier to modify the stylesheet later if you need to. Also, certain types of structures (like attributes) can only be created this way.
- Kevin
------------------
Kevin Williams
Senior System Architect, Equient Corporation
author of: Professional XML Databases
 
I will suppress my every urge. But not this shameless plug:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic