Adding attributes to HTML elements
This is an open discussion with 5 replies, filed under General.
Search
you can reference variables or xpath expressions in any element properties by wrapping them in curly braces.
<body id="{$root-page}">
Or you can use something like:
<body> <xsl:attribute name="id"> <xsl:value-of select="$root"/> </xsl:attribute> </body>
wouldn't that set his id to something like http://www.example.com
though?
wouldn't that set his id to something like http://www.example.com though?
Yes, yes it would. But it's really just indicative of how you can set attributes, rather than the parameter you choose to output.
Ah, thanks so much. Yes, using <body id="{$root-page}">
is what I wanted.
Create an account or sign in to comment.
Hi, I'm somewhat new to XSLT but so far I'm really liking it and can see how powerful it can be.
One problem I haven't been to figure out yet is how to get this HTML:
Where foo is the section name. I see that $root-page is the variable I want to use but I can simply output the way I would in, say, PHP.
I can do this:
but is there a better way?