• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

set Attributes with XSLT

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!