Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

XSL Generating HTML

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,
I have an XSL file that generates HTML. The HTML file that is being generated has HREFs in it. How can I get the HREFS to equal the value of the XML attribute that it is transforming. For Example:
<body>
<xsl:for-each select="Locations/Location">
<a href="/servlet/GetMaps"><xsl:value-of select="Campus"/></a><br/>
</xsl:for-each>
</body>
Above, I would like "/servlet/GetMaps" really to be the value of "xsl:value-of select="Campus"/>".
This is driving me to drink!!!
Bob...
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not to discourage you from drinking , but you can use
<a href="{./servlet/GetMaps}">
construction
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you want to specify the attribute in the output HTML/XHTML, use {XPath}. This is the alternative way to get the value of XML note value using <xsl:value-of select="XPath"/>
 
Ranch Hand
Posts: 171
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The curly brackets are your friend. When you use them inside an attribute value, they will expand to the value of the XPath expression.
You didn't provide much context for your application; but maybe you want something like this:
<a href="{/servlet/GetMaps/@Campus}">fubar</a>
Results may vary.
Geoffrey
 
First, you drop a couch from the plane, THEN you surf it. Here, take this tiny ad with you:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic