473,386 Members | 1,679 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,386 software developers and data experts.

Extracting XML data to be used in XSLT HTML output

Ok:

I have done small level Xml stuff and am just now starting to understand
some of the plumbing involved. I've done a lot of .NET programming for SQL
Server, but little for Xml data stores.

I am currently just interested in using the .xsl file that I have being
applied to a source .xml file through ASP classic. Here's what I have:

XSL file
----------------------------------------------------------------------------
---
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" />

<xsl:template match="/rss/channel">
<xsl:for-each select="item">
<div class="content" style="padding:5px;"><u><b><xsl:value-of
select="title" /></b></u></div>
<div class="bodysm" style="padding:5px;"><xsl:value-of
select="pubDate" /></div><br />
<div class="content" style="padding:5px;">
<xsl:value-of select="description" />
</div><br />
<!-- ***** Line of Interest Below ***** -->
<div class="content" style="border-bottom:1px solid
#ACACAC;padding:5px;"><b><a href=""><xsl:value-of select="link"
/></a></b></div><br />
</xsl:for-each>
<div class="content"
style="color:#ACACAC;padding:5px;text-align:right;">
<i><xsl:value-of select="copyright" /></i><br />
<!-- ***** Line of Interest Below ***** -->
<a href="" style="color:#ACACAC;"><xsl:value-of select="link" /></a>
</div>
</xsl:template>

</xsl:stylesheet>

XML File
----------------------------------------------------------------------------
---
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<title>Test Feed</title>
<link>http://www.grannet.net/rss/rss.xml</link>
<description></description>
<copyright>Copyright (c) 2004 Grant Harmeyer</copyright>
<item>
<title>First Entry in RSS</title>
<link>http://www.hatfish.com/dvd.htm</link>
<pubDate>Fri, 05 Dec 2003 16:26:36 CST</pubDate>
<description>
<![CDATA[

]]>
</description>
</item>
</channel>
</rss>

The ASP code is written in JScript and works just fine, my question is this,
on the Xsl I have commented 2 "Lines of Interest". How do I take the data
that is stored in the <link /> child node of an <item /> and use it as the
target of the output HTML <a /> tag? I.E.: <a href="<link />"><link /></a>

I am sure this is 1 of 2 things. Extremely easy, or not possible given my
current route of implementation, and I guess it's the first of these 2.
Thanks in advance.
Grant Harmeyer
Nov 12 '05 #1
3 1916
Grant,

I'll be thrilled when someone tells me how silly I am because there's a
better way, but I brute force this by changing the output to text, then
escaping every blasted less than sign, then just shoving it in

&lt;a href="<xsl:value-of select="link"/>"/></a>

--
Kathleen Dollard
Microsoft MVP
Author "Code Generation in Microsoft .NET"
"Grant Harmeyer" <gn*********@hotmail.com> wrote in message
news:uv****************@tk2msftngp13.phx.gbl...
Ok:

I have done small level Xml stuff and am just now starting to understand
some of the plumbing involved. I've done a lot of .NET programming for SQL
Server, but little for Xml data stores.

I am currently just interested in using the .xsl file that I have being
applied to a source .xml file through ASP classic. Here's what I have:

XSL file
-------------------------------------------------------------------------- -- ---
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" />

<xsl:template match="/rss/channel">
<xsl:for-each select="item">
<div class="content" style="padding:5px;"><u><b><xsl:value-of
select="title" /></b></u></div>
<div class="bodysm" style="padding:5px;"><xsl:value-of
select="pubDate" /></div><br />
<div class="content" style="padding:5px;">
<xsl:value-of select="description" />
</div><br />
<!-- ***** Line of Interest Below ***** -->
<div class="content" style="border-bottom:1px solid
#ACACAC;padding:5px;"><b><a href=""><xsl:value-of select="link"
/></a></b></div><br />
</xsl:for-each>
<div class="content"
style="color:#ACACAC;padding:5px;text-align:right;">
<i><xsl:value-of select="copyright" /></i><br />
<!-- ***** Line of Interest Below ***** -->
<a href="" style="color:#ACACAC;"><xsl:value-of select="link" /></a>
</div>
</xsl:template>

</xsl:stylesheet>

XML File
-------------------------------------------------------------------------- -- ---
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<title>Test Feed</title>
<link>http://www.grannet.net/rss/rss.xml</link>
<description></description>
<copyright>Copyright (c) 2004 Grant Harmeyer</copyright>
<item>
<title>First Entry in RSS</title>
<link>http://www.hatfish.com/dvd.htm</link>
<pubDate>Fri, 05 Dec 2003 16:26:36 CST</pubDate>
<description>
<![CDATA[

]]>
</description>
</item>
</channel>
</rss>

The ASP code is written in JScript and works just fine, my question is this, on the Xsl I have commented 2 "Lines of Interest". How do I take the data
that is stored in the <link /> child node of an <item /> and use it as the
target of the output HTML <a /> tag? I.E.: <a href="<link />"><link /></a>

I am sure this is 1 of 2 things. Extremely easy, or not possible given my
current route of implementation, and I guess it's the first of these 2.
Thanks in advance.
Grant Harmeyer

Nov 12 '05 #2
Grant Harmeyer wrote:
<!-- ***** Line of Interest Below ***** -->
<div class="content" style="border-bottom:1px solid
#ACACAC;padding:5px;"><b><a href=""><xsl:value-of select="link"
/></a></b></div><br />
<div class="content" style="border-bottom:1px solid
#ACACAC;padding:5px;"><b><a href="{link}"><xsl:value-of select="link" /></a></b></div><br /> <!-- ***** Line of Interest Below ***** -->
<a href="" style="color:#ACACAC;"><xsl:value-of select="link" /></a>


<a href="{link}" style="color:#ACACAC;"><xsl:value-of select="link" /></a>

Learn about attribute-value templates in XSLT.

--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog
Nov 12 '05 #3
Oleg,

I love you!

I understand and use attribute-value templates. I did not realize they would
work in this context, and to be honest my head's still not totally around
why they do. I understand Key to be explaining them in a narrower context in
XSLT, Programmer's Reference. That will significnatly clean up some sample
templates (although the book's at the printers :( egg on face ):

--
Kathleen Dollard
Microsoft MVP
Author "Code Generation in Microsoft .NET"
"Oleg Tkachenko" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:Ol****************@TK2MSFTNGP09.phx.gbl...
Grant Harmeyer wrote:
<!-- ***** Line of Interest Below ***** -->
<div class="content" style="border-bottom:1px solid
#ACACAC;padding:5px;"><b><a href=""><xsl:value-of select="link"
/></a></b></div><br />
<div class="content" style="border-bottom:1px solid
#ACACAC;padding:5px;"><b><a href="{link}"><xsl:value-of select="link"
> /></a></b></div><br />

<!-- ***** Line of Interest Below ***** -->
<a href="" style="color:#ACACAC;"><xsl:value-of select="link"

/></a>
<a href="{link}" style="color:#ACACAC;"><xsl:value-of select="link" /></a>

Learn about attribute-value templates in XSLT.

--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog

Nov 12 '05 #4

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

Similar topics

1
by: Harry Zoroc | last post by:
I would like to treat an xsd Schema file as XML file and to display the targetNamespace and all the imports. That's it. But the following does not work. Why? I did not enter the stylesheet in the...
3
by: Sandros | last post by:
Background: I'm collecting usability statistics for a group of applications. Each count has the following attributes: date, application, major heading, minor heading, count. My intent is to pull...
4
by: Robert Fentress | last post by:
I'm loading an xml data file and then trying to take a particular node and add it, as html, to an element on my page using inner HTML. The xml is like what is below, with the ... representing...
4
by: Moogy | last post by:
I'm pulling my hair out here. First, I'm new to XML, so that doesn't help, but none of this makes any sense to me. All I'm trying to do is take a simple source XML file and translate it with an...
9
by: AA | last post by:
Hello, I need to extract an element from a xml document something like this <myXml> <Header> <Name/> <LastName/> <Age/> </Head> <Body> <Properties>
4
by: Bill Nguyen | last post by:
I wonder if I can write to an XML file using column structure (and column names) of an SQLserver table. for example: Table A: column1 int column2 char(30) column3 date XML output:
6
by: Mag Gam | last post by:
Hi All, I am new to XML, and trying to extract some data from a file. The file looks like this: <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST>...
4
by: Debbiedo | last post by:
My software program outputs an XML Driving Directions file that I need to input into an Access table (although if need be I can import a dbf or xls) so that I can relate one of the fields...
4
by: mark4asp | last post by:
I have an element, report which contains tags which have been transformed. E.g. <pis &lt;p&gt <myXml> <report>This text has html tags in it.&lt;p&gt which but <has been changed to &lt;&gt</report>...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.