![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| [SOLVED] How to generate dynamic DIV id with XSLT? I want to generate some DIV tag with XSLT, from a XML document. But I cannot do this(syntax error ...): <div id="(xslt tag to get a value from XML)"> What can I do? do you have any suggestion? |
| |
| |||
| 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! |
![]() |
| Thread Tools | |
| Display Modes | |
| |