How to generate dynamic DIV id with XSLT?
-
-
Answer:
Basically to insert the value of a node where a literal value would normally go you'll use the {} within the quoted string. I don't know what the xml you're wanting to pull the id from is so I'll give you two examples. 1) the id is in a node: source xml: <root><mydivid>divMine</mydivid></root... xslt: <div id="{//root/mydivid}"></div> 2) the id is in an attribute: source xml: <root mydivid="divMine"></root> xslt: <div id="{//root/@mydivid}"></div> Of course you can always declare an xsl:variable as well so that you don't have to use the whole xpath in the {}, or if you're in a template where the context is the parent node of the one that you're wanting to pull the id from you just use the name of the node or attribute in the {} (mydivid or @mydivid if your template's match="root"). Hopefully that's somewhat helpful!
bzkit1983 at Yahoo! Answers Visit the source
Other answers
Basically to insert the value of a node where a literal value would normally go you'll use the {} within the quoted string. I don't know what the xml you're wanting to pull the id from is so I'll give you two examples. 1) the id is in a node: source xml: <root><mydivid>divMine</mydivid></root… xslt: <div id="{//root/mydivid}"></div> 2) the id is in an attribute: source xml: <root mydivid="divMine"></root> xslt: <div id="{//root/@mydivid}"></div> Of course you can always declare an xsl:variable as well so that you don't have to use the whole xpath in the {}, or if you're in a template where the context is the parent node of the one that you're wanting to pull the id from you just use the name of the node or attribute in the {} (mydivid or @mydivid if your template's match="root"). Hopefully that's somewhat helpful!
LDonaghe
Related Q & A:
- How To Generate Your Own Unlock Code?Best solution by Stack Overflow
- How To Generate Unlock Codes?Best solution by makeuseof.com
- How to generate reports?Best solution by Stack Overflow
- How to check which div is visible while scrolling?Best solution by stackoverflow.com
- How to merge 2 xml docs with xslt?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.