• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

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.
 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic