This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: I'm very new to the XML/XSL world ...
- To: xsl-list <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Re: I'm very new to the XML/XSL world ...
- From: owner-xsl-list at lists dot mulberrytech dot com (by way of B. Tommie Usdin)
- Date: Tue, 17 Apr 2001 09:47:10 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
Date: Tue, 17 Apr 2001 06:34:44 -0700 (PDT)
From: Dan Diebolt <dandiebolt@yahoo.com>
Subject: Re: I'm very new to the XML/XSL world ...
To: xsl-list@lists.mulberrytech.com
In-Reply-To: <200104170630.CAA09488@biglist.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
>I'm very new to the XML/XSL world.
Who isn't?
>I want to use XSL in a similar fashion to a database query.
You need XQuery for that, but XSLT/XPath can do the job.
Try the enclosed. You may need to use the function normalize-space()
to deal with the white space within you elements " A Person ". I
just ignored it to concentrate on the XPath issues. In understanding
the XPath you simply need to know that the text outside of the []'s
steers you to the node you are selecting, while the text within the
[]' qualifies what nodes are selected:
You can obtain the sec_head for a given $title as a two step process.
First, select the sec_ref attribute of graph elements where the
graph element a has title element wich content equal to $title:
select="//graph[title=$title]/@sec_ref"/>
Second select the sec_head element within a section element with an id
attribute equal to $sec_ref:
select="//section[@id=$sec_ref]/sec_head"/>
Hope this helps.
Regards,
Dan
File: IDProblem17April2001.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="IDProblem17April2001.xsl"?>
<graph_catalogue>
<graph sec_ref="EAF" >
<title>Graph</title>
</graph>
<section id="EAF" >
<sec_head>Person</sec_head>
</section>
</graph_catalogue>
File: IDProblem17April2001.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="title" select="'Graph'"/>
<xsl:template match="/">
<xsl:variable name="sec_ref" select="//graph[title=$title]/@sec_ref"/>
<xsl:value-of select="//section[@id=$sec_ref]/sec_head"/>
</xsl:template>
</xsl:stylesheet>
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list