|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
text link in xslt
Hi,
I'm pretty new to xslt. want to transform something like this xml: Code:
<txt> <p>For individuals who are neither <linkc url="http://www.jarra.nl/">designers</linkc> nor artists, it may seem like those who are, use a lot of smoke and mirrors.</p> <p>I thought it might be interesting to share the process I went through to create the design.</p> </txt> with some xslt like this: Code:
<xsl:template match="p">
<p><xsl:value-of select="."/></p>
</xsl:template>
<xsl:template match="linkc">
<a href="{@url}"> <xsl:value-of select="linkc"/> </a>
</xsl:template>
whereby <linkc> should keep it's position in <p>. You can see the complete test files here: http://www.jarra.nl/_TEST/jarra3-xml.xml http://www.jarra.nl/_TEST/jarrass3-xsl.xsl Thanx a lot for your help, jarra
__________________
http://www.jarra.nl |
|
#2
|
|||
|
|||
|
<a href> <p> in text
hi
i hope this is the solution u r looking for thank u with regards niha ------------------------------ <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl utput method="html"/><xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="p"> <p><xsl:apply-templates /></p> </xsl:template> <xsl:template match="linkc"> <a href="{@url}"> <xsl:value-of select="."/> </a> </xsl:template> </xsl:stylesheet> ======================== |
|
#3
|
|||
|
|||
|
Thanks a lot for your reply,
and it's what i'm looking for... but it's part of a bigger file. This is my stylesheet, and the problem i'm having, is how to call those templates. when using the apply-templates function, it's outputting all nodes again. How to do this..? thanx, jarra Code:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:my="http://www.jarra.nl/" xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml">
<xsl:output doctype-system="/resources/dtd/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" cdata-section-elements="script" indent="yes" method="xml" />
<xsl:output omit-xml-declaration="yes" />
<xsl:template match="root">
<head>
<title>
<xsl:value-of select="title"/>
</title>
<link rel="stylesheet" type="text/css" href="css/jarracss.css"/>
</head>
<body>
<div id="header"><a id="above"></a></div>
<div id="subheader">
<div id="tabs">
<ul>
<xsl:for-each select="tabs/link">
<li><a href="{@url}"> <xsl:value-of select="."/> </a></li>
</xsl:for-each>
</ul>
</div>
</div>
<div id="top">
<div id="navigator"></div>
</div>
<div id="left">
<div id="leftcontent">
<ul>
<xsl:for-each select="left/link">
<li><a href="{@url}"> <xsl:value-of select="."/> </a></li>
</xsl:for-each>
</ul>
</div>
</div>
<div id="right">
<h1><xsl:value-of select="right/kop"/></h1>
<dl><dd class="end"></dd></dl>
<h2><xsl:value-of select="right/subkop"/></h2>
<xsl:apply-templates/>
<dl><dd class="end"></dd></dl>
</div>
<div id="bottom">
| <a href="#above">top</a> | <a href="http://validator.w3.org/check/referer" title="Validate XHTML 1.1">XHTML 1.1</a> and <a href="http://jigsaw.w3.org/css-validator/check/referer" title="Validate CSS">CSS</a> valid |
</div>
<div class="hide">
<p><strong>Compatibility note:</strong></p>
</div>
</body>
</xsl:template>
<xsl:template match="p">
<p><xsl:apply-templates /></p>
</xsl:template>
<xsl:template match="linkc">
<a href="{@url}"> <xsl:value-of select="."/> </a>
</xsl:template>
</xsl:stylesheet>
|
|
#4
|
|||
|
|||
|
<xsl:apply-templates select="
hi jarra
in <xsl:apply-templates u have select option to call particular nodes actually here i could not able to understand which nodes info u want to show and where - i dont know i understand correct or not i think u want to show - after this <h2><xsl:value-of select="right/subkop"/></h2> statement - u want to show - right/txt/p - info and - not date info - this is what i understood and this is the code for that ============================= <?xml version="1.0" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:my="http://www.jarra.nl/" xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"> <xsl utput doctype-system="/resources/dtd/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" cdata-section-elements="script" indent="yes" method="xml" /> <xsl utput omit-xml-declaration="yes" /> <xsl:template match="root"> <head> <title> <xsl:value-of select="title"/> </title> <link rel="stylesheet" type="text/css" href="css/jarracss.css"/> </head> <body> <div id="header"><a id="above"></a></div> <div id="subheader"> <div id="tabs"> <ul> <xsl:for-each select="tabs/link"> <li><a href="{@url}"> <xsl:value-of select="."/> </a></li> </xsl:for-each> </ul> </div> </div> <div id="top"> <div id="navigator"></div> </div> <div id="left"> <div id="leftcontent"> <ul> <xsl:for-each select="left/link"> <li><a href="{@url}"> <xsl:value-of select="."/> </a></li> </xsl:for-each> </ul> </div> </div> <div id="right"> <h1><xsl:value-of select="right/kop"/></h1> <dl><dd class="end"></dd></dl> <h2><xsl:value-of select="right/subkop"/></h2> <xsl:apply-templates select="right/txt"/> <dl><dd class="end"></dd></dl> </div> <div id="bottom"> | <a href="#above">top</a> | <a href="http://validator.w3.org/check/referer" title="Validate XHTML 1.1">XHTML 1.1</a> and <a href="http://jigsaw.w3.org/css-validator/check/referer" title="Validate CSS">CSS</a> valid | </div> <div class="hide"> <p><strong>Compatibility note:</strong></p> </div> </body> </xsl:template> <xsl:template match="p"> <p><xsl:apply-templates /></p> </xsl:template> <xsl:template match="linkc"> <a href="{@url}"> <xsl:value-of select="."/> </a> </xsl:template> </xsl:stylesheet> ============================= hope this code helps u- thank u with regards niha |
|
#5
|
|||
|
|||
|
Hi Niha,
Thanx a lot for your help, it's exactly what i wanted! gosh, seems so easy now, but i tried lot's of different ways, and none of them worked. so if i use this command: <xsl:apply-templates select="right"/> it's applying templates to all sub-nodes of the node "right", and only to those nodes. thanx again, jarra |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > text link in xslt |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|