XML+XSL Hyperlinks
-
Hello, this is a very basic problem, i think. How can I define an url in the XML file and format/output it with a XSL file? This is my XML file: Download 1 DWL1 link Download 2 DWL2 link2 This is my XSL file:
Archive
Downloads
Name
Webcode
Goto
[]( WHAT HERE??? )
What do i have to put in the 8. line above? ("WHAT HERE???") This mustn't be a fixed string, it must be loadable from the .xml file. How do i encode the link in the XML file? :confused: -Dominik
-
Hello, this is a very basic problem, i think. How can I define an url in the XML file and format/output it with a XSL file? This is my XML file: Download 1 DWL1 link Download 2 DWL2 link2 This is my XSL file:
Archive
Downloads
Name
Webcode
Goto
[]( WHAT HERE??? )
What do i have to put in the 8. line above? ("WHAT HERE???") This mustn't be a fixed string, it must be loadable from the .xml file. How do i encode the link in the XML file? :confused: -Dominik
you need to use xsl:attribute to create the href= part of the anchor tag. Something like: That's off the top of my head, but it's basically correct. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
-
you need to use xsl:attribute to create the href= part of the anchor tag. Something like: That's off the top of my head, but it's basically correct. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
or the short version:
<a href="{link}"><xsl:value-of select='link'/></a>
notice the use of the curly brakets to shortcut any xpath expression....
"When the only tool you have is a hammer, a sore thumb you will have."
-
or the short version:
<a href="{link}"><xsl:value-of select='link'/></a>
notice the use of the curly brakets to shortcut any xpath expression....
"When the only tool you have is a hammer, a sore thumb you will have."
That looks great - how does it work ? It's pulling a node called 'link' out of the current context node, and the curly brackets mean that it's put into there, or the curly brackets pull it out of the current context node seperately ? Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
-
That looks great - how does it work ? It's pulling a node called 'link' out of the current context node, and the curly brackets mean that it's put into there, or the curly brackets pull it out of the current context node seperately ? Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
curly brackets are shorthand - they tell the xsl processor to replace the contents with the result of the xpath xpresions xml:
<company logo="bob.gif"/>
xlst:<xsl:apply-template match="company"> <img src="{@logo}"/> </xsl:apply-template>
hope this makes sense - saves alot of typing :) [edit]note that is always in the context of the current node - so equal tocurrent()/@logo
[/edit]
"When the only tool you have is a hammer, a sore thumb you will have."
-
curly brackets are shorthand - they tell the xsl processor to replace the contents with the result of the xpath xpresions xml:
<company logo="bob.gif"/>
xlst:<xsl:apply-template match="company"> <img src="{@logo}"/> </xsl:apply-template>
hope this makes sense - saves alot of typing :) [edit]note that is always in the context of the current node - so equal tocurrent()/@logo
[/edit]
"When the only tool you have is a hammer, a sore thumb you will have."
Cool - yes, thanks. I did not know you could do that, and I will find it very useful. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
-
curly brackets are shorthand - they tell the xsl processor to replace the contents with the result of the xpath xpresions xml:
<company logo="bob.gif"/>
xlst:<xsl:apply-template match="company"> <img src="{@logo}"/> </xsl:apply-template>
hope this makes sense - saves alot of typing :) [edit]note that is always in the context of the current node - so equal tocurrent()/@logo
[/edit]
"When the only tool you have is a hammer, a sore thumb you will have."
Philip Fitzsimons wrote: curly brackets are shorthand - they tell the xsl processor to replace the contents with the result of the xpath xpresions Wow, thanks for the awesome tip. Never seen this mentioned in any XSL tutorial before, is it part of the standard?
Paul Watson
Bluegrass
Cape Town, South AfricaRay Cassick wrote: Well I am not female, not gay and I am not Paul Watson
-
Philip Fitzsimons wrote: curly brackets are shorthand - they tell the xsl processor to replace the contents with the result of the xpath xpresions Wow, thanks for the awesome tip. Never seen this mentioned in any XSL tutorial before, is it part of the standard?
Paul Watson
Bluegrass
Cape Town, South AfricaRay Cassick wrote: Well I am not female, not gay and I am not Paul Watson
yes its part of the standard - comes under 7.6.2 Attribute Value Templates http://www.w3.org/TR/1999/REC-xslt-19991116#dt-attribute-value-template[^]
"When the only tool you have is a hammer, a sore thumb you will have."