473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Embedding xlst element into html tag

Hi!

I'm absolutely newbie with XSLT. Please, help me with this example.

I have simple XML document like this:

<skip />
<aaa>
<link url="url1" />
<link url="url2" />
<skip />
</aaa>
<skip />

that should be transformed to HTML like:

...
<a href="url1">url1</a>
<a href="url2">url2</a>
...

I suppose, it may looks like this:

<skip />
</xsl:template match="aaa">
<xsl:for-each select="link">
<a href="???"><xsl:value-of select="./@url" /></a>
</xsl:for-each>
</xsl:template>
<skip />

with "./@url" value in place of "???". But I can't use XPath inside
html tags. How can I embed xlst element into html tag? If it's
impossible, how to implement this transformation?

TIA,
Vital Lobachevsky
Jul 20 '05 #1
1 3047
In article <da**************************@posting.google.com >,
Vital Lobachevsky <ti**@tochka.by> wrote:

% </xsl:template match="aaa">
% <xsl:for-each select="link">
% <a href="???"><xsl:value-of select="./@url" /></a>
% </xsl:for-each>
% </xsl:template>
%
% with "./@url" value in place of "???". But I can't use XPath inside
% html tags. How can I embed xlst element into html tag? If it's
% impossible, how to implement this transformation?

You can, using an attribute value template:

</xsl:template match="aaa">
<xsl:for-each select="link">
<a href="{@url}"><xsl:value-of select="./@url" /></a>
</xsl:for-each>
</xsl:template>

You can also use xsl:attribute:

</xsl:template match="aaa">
<xsl:for-each select="link">
<a>
<xsl:attribute name='href'><xsl:value-of select='@url'/></xsl:attribute>
<xsl:value-of select="./@url" /></a>
</xsl:for-each>
</xsl:template>
--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: WStoreyII | last post by:
Hello, I have a cgi program made in c which will output xml that I have obtained from a mysql database. I have the xml output setup to be transformed by blog.xsl in the header of the xml output....
3
by: Mr. Clean | last post by:
Very new to XML style sheets and need some help getting this XML: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE CDSLogger SYSTEM "CDSLogger.dtd"> <CDSLogger> <ErrorObject> <BatchName>This...
53
by: Andrew Poulos | last post by:
I've got some CSS that looks like this: body { margin: 0; font-family: Arial, Helvetica, sans-serif; font-size: 140.01%; color: #000000; } but IE won't apply the font size to text in table...
8
by: Alan Lue | last post by:
Hi, I'm trying to set up a webpage so that I can view multiple HTML files from the same page. For example, you might go to http://example.com/lab_tests.html and be able to view lab1.html,...
3
by: Hai Nguyen | last post by:
I would like to know after transforming my datatables which store in dataset into XML form. Now I want to save it into a file and also create a XLST file to read it. How can I do that? Would you...
3
by: Hai Nguyen | last post by:
Sorry I don't have code yet. I'm asking for solutions which can help me solve the problem. This is the first time I have to cope this situation, hence I'm clueless how to start. I would like to ask...
1
by: stefano | last post by:
Hi, I have a file xml (p.xml) and I use XSLT to trasform p.xml to XHTML. this is the xml file: .... <test label="x"> <itemList> <testItem oknumber="2" > .... </testItem> </itemList>
0
by: hq4000 | last post by:
Given AStyleSheet.xsl : <AStyleSheet> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.mytest.mytest2.mytest3.com" version="1.0"> <xsl:output method="xml"...
2
by: John Grandy | last post by:
I am not having success embedding carriage return and line feed characters into a string and displaying them with an ASP.NET label. Is anyone getting either of the following to work ? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.