XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 5th, 2004, 08:39 AM
jarra jarra is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: the Netherlands
Posts: 66 jarra User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 39 sec
Reputation Power: 5
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

Reply With Quote
  #2  
Old July 5th, 2004, 09:36 AM
nihaarika2002 nihaarika2002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 49 nihaarika2002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
<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">
<xslutput 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>



========================

Reply With Quote
  #3  
Old July 5th, 2004, 01:32 PM
jarra jarra is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: the Netherlands
Posts: 66 jarra User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 39 sec
Reputation Power: 5
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>

Reply With Quote
  #4  
Old July 6th, 2004, 03:23 AM
nihaarika2002 nihaarika2002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 49 nihaarika2002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
<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">
<xslutput doctype-system="/resources/dtd/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" cdata-section-elements="script" indent="yes" method="xml" />
<xslutput 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

Reply With Quote
  #5  
Old July 6th, 2004, 01:12 PM
jarra jarra is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: the Netherlands
Posts: 66 jarra User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 39 sec
Reputation Power: 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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > text link in xslt


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT