Article View: pl.comp.xml
Article #10090Nazwa węzła z parametru?
From: ant
Date: Wed, 04 Mar 2009 02:47
Date: Wed, 04 Mar 2009 02:47
82 lines
3104 bytes
3104 bytes
Witam,
Mam taki prosty problem, z którego jednak nie potrafię wybrnąć ;-]
--%<-----%<-----%<-----%<-----%<-----%<-----%<-----%<-----%<-----%<-----%<----
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="activenode">0</xsl:param>
<xsl:param name="ChildcountKey">childcount</xsl:param>
<xsl:template match="nodes">
<ul>
<xsl:apply-templates select="node" />
</ul>
</xsl:template>
<xsl:template match="node">
<li>
<xsl:apply-templates select="title|nodes"/>
</li>
</xsl:template>
<xsl:template match="node/title">
<xsl:choose>
<xsl:when test="../@id = $activenode">
<a href="?id={../@id}"><b><xsl:apply-templates /></b></a>
<xsl:choose>
<xsl:when test="../childcount > 0">
(<xsl:value-of select="../childcount" />)
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<a href="?id={../@id}"><xsl:apply-templates /></a>
<xsl:choose>
<xsl:when test="childcount > 0">
(<xsl:value-of select="../childcount" />)
</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
--%<-----%<-----%<-----%<-----%<-----%<-----%<-----%<-----%<-----%<-----%<----
<nodes>
<node id="2">
<title>AAAAAAAAAAAAA</title>
</node>
<node id="3">
<title>BBBBBBBBBBBBB</title>
<childcount>3</childcount>
<nodes>
<node id="5">
<title>CCCCCCCCCCCCC</title>
</node>
</nodes>
</node>
</nodes>
--%<-----%<-----%<-----%<-----%<-----%<-----%<-----%<-----%<-----%<-----%<----
I to mi działa. Problem w tym, że w tym XMLu gałąź "childcount" może
przyjmować różne nazwy - nazwy które chcę podawać w postaci parametru
(<xsl:param name="ChildcountKey">childcount</xsl:param>).
Mój problem polega na tym, że kombinowałem już na wiele sposobów,
ale nie wiem jak poprawić te wiersze:
<xsl:when test="../childcount > 0">
(<xsl:value-of select="../childcount" />)
żeby sprawdzał nie w ../childcount, a w czymś w stylu ../$ChildcountKey,
tylko to mi nie działa właśnie ;p i nie działa mi też wstawianie wartości
../$ChildcountKey.
Jak to poprawić?
Dziękuję z góry za wszelkie wskazówki :-)
Technical Details
Message-ID:
<gokqie$8i5$1@nemesis.news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!newsfeed.neostrada.pl!atlantis.news.neostrada.pl!news.neostrada.pl!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!newsfeed.neostrada.pl!atlantis.news.neostrada.pl!news.neostrada.pl!not-for-mail From: ant <ant@nowhere.tld> Newsgroups: pl.comp.xml Subject: Nazwa węzła z parametru? Date: Wed, 04 Mar 2009 03:47:43 +0100 Organization: TP - http://www.tp.pl/ Lines: 82 Message-ID: <gokqie$8i5$1@nemesis.news.neostrada.pl> NNTP-Posting-Host: 79.189.151.30 Mime-Version: 1.0 X-Trace: nemesis.news.neostrada.pl 1236135311 8773 79.189.151.30 (4 Mar 2009 02:55:11 GMT) X-Complaints-To: usenet@news.neostrada.pl NNTP-Posting-Date: Wed, 4 Mar 2009 02:55:11 +0000 (UTC) User-Agent: Thunderbird 2.0.0.17 (X11/20080927) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit