• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

How do I apply a template based on a node value

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following XML
<menu>
<item>System Admin</item>
<item>Position Posting</item>
<item>Static Data Management</item>
...
</menu>
I am trying to write an XSL just to translate the "<item>": System Admin, however, the following XSL gives a compiling error:
<xsl:template match="item='System Admin'">
currCel = "mnusetupbatch";
currClass = "hgwhiteborder2-1";
parentcurrCel = "mnurisksim";
parentcurrClass = "hgwhiteborder2";
var actionCall = "";
</xsl:template>
Can somebody help? Thanks in advance!
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<xsl:template match="item[text()='System Admin']">
This will match an item node with text content of System Admin.
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This should also work:
<xsl:template match="item[.='System Admin']">
since the string value of the item node is the value of its text element.
 
You got style baby! More than this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic