[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Extracting XPath stuff for an href.

Subject: Extracting XPath stuff for an href.
From: James Steward <jamessteward@xxxxxxxxxxxxxxx>
Date: Mon, 03 Jul 2006 08:32:17 +1000
xpath href
Hi All,

Being a newbie to XSL I'm probably going to ask some dumb questions but
I have googled for what I'm trying to do and tried many variations to
this and not yet found a solution.

I have a test.dtd with basic structure as...

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT AAA (BBB,CCC)>
<!ELEMENT BBB (DDD+)>
<!ELEMENT CCC (DDD+)>
<!ELEMENT DDD EMPTY>
<!ATTLIST DDD
	eee CDATA #REQUIRED>

And an test.xml doc that looks like...

?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<!DOCTYPE AAA SYSTEM "test.dtd">
<AAA>
        <BBB>
                <DDD eee="Bar1"/>
		...etc
	</BBB>
        <CCC>
                <DDD eee="BarX"/>
		...etc
	</CCC>
</AAA>

Then my xsl looks like,
<?xml version="1.0"?><!--test.xsl-->
<!--XSLT 1.0 - http://localhost -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

       <xsl:template match="/">
                <html>
                        <head><title>Test</title></head>
                        <body>
                        <h1>
                                <center>
                                        <xsl:text>Test</xsl:text>
                                        <hr/>
                                </center>
                        </h1>
                                <xsl:apply-templates/>
                        </body>
                </html>
        </xsl:template>	

        <xsl:template match="BBB">
                <p/><b><i><u><xsl:text>BBB</xsl:text></u></i></b>
                <xsl:apply-templates select="//DDD"/>
        </xsl:template>

        <xsl:template match="CCC">
                <p/><b><i><u><xsl:text>CCC</xsl:text></u></i></b>
                <xsl:apply-templates select="//DDD"/>
        </xsl:template>

	<xsl:template match="//DDD">
		<p/><u>
		<a href="cgi-bin/test.sh?{@eee},{parent::node()}"
		target="_blank">DDD <xsl:value-of select="@eee"/>
		</a></u>
	</xsl:template>
</xsl:stylesheet>

Now what I'm hoping for in the output is something like;

<a href="cgi-bin/test.sh?Bar1,BBB" target="_blank">DDD Bar1</a>

But all I get is;

<a href="cgi-bin/test.sh?Bar1, " target="_blank">DDD Bar1</a>

So the @eee works, but there's something wrong with the use of XPath
parent::node() ?

I'd be grateful if someone could give me a prod in the right direction.

Oh, I'm just running thttpd with files in my /var/www dir and using
Mozilla Firefox pointed at http://localhost for testing.

Regards,
James.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.