Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] Extracting XPath stuff for an href.

From: James Steward <jamessteward@--------------->
To:
Date: 7/2/2006 10:33:00 PM
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.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent