When is XSLT not appropriate?

T

ted

Was wondering if XSLT alone is appropriate for the following situation.

From XML, I'm creating a small website (around 50 pages) with pages that
link to each other through a nav menu and a "crumb-trail" of links. I'm
transforming the XML with XSLT through Saxon.

The nav menu and "crumb-trail" show the user where they are within the site
and is made by reflecting the XML tree structure.

My problem now is that when I want to generate a page that references
information that lies in another context in the XML (referenced with an
IDREF), I go into that other context to get it. But this makes my nav menu
and "crumb trail" reflect that other context - not the one the user is
currently in (the one where the IDREF is). I can't figure out how to get
around this.

Would using Java and XSLT be more appropriate for jobs like this?

TIA,
Ted
 
A

Andy Dingley

Was wondering if XSLT alone is appropriate for the following situation.
Yes.

From XML, I'm creating a small website (around 50 pages) with pages that
link to each other through a nav menu and a "crumb-trail" of links.

I did this a few years back. As I don't reckon much to XML's IDREF for
representing graph structures, I used RDF instead.

To handle the "context switching", I used a good many variables, most
of which were passed as parameters to named templates.

For the breadcrumb trail itself, I just used an axis of
ancestor-or-self::



<!-- Breadcrumb trails -->

<xslt:template name="breadcrumbs" >
<xslt:param name="Application" select="/.." />
<!-- Display a "breadcrumb" trail (as described by Nielsen) to show
where the Application is in the overall hierarchy -->

<div id="divBreadcrumbs" >
<xslt:for-each
select="$Application/ancestor-or-self::*[substring-after(@rdf:type,
'#')='Application']" >
<xslt:if test="position()!=1" > -&gt; </xslt:if>
<span class="application" ><xslt:choose>
<xslt:when test="m:menu-item" >
<xslt:call-template name="menu-item-as-nav-link" >
<xslt:with-param name="menu-item" select="m:menu-item" />
</xslt:call-template>
</xslt:when>
<xslt:eek:therwise><xslt:value-of select="./@rdf:ID"
/></xslt:eek:therwise>
</xslt:choose></span>
</xslt:for-each>
</div>
</xslt:template>
 
T

ted

I'm using a lot of named template and variables. Stopped working with XSL
for a couple of months. Came back and it took me a while to figure out what
I originally wrote. Probably bad code (and commenting), but was wondering
if larger jobs are better served using XSLT in conjuction with Java. I find
myself wanting to put things in arrays and hashes sometimes. But maybe it's
because I don't know my XSL well enough.



Andy Dingley said:
Was wondering if XSLT alone is appropriate for the following situation.
Yes.

From XML, I'm creating a small website (around 50 pages) with pages that
link to each other through a nav menu and a "crumb-trail" of links.

I did this a few years back. As I don't reckon much to XML's IDREF for
representing graph structures, I used RDF instead.

To handle the "context switching", I used a good many variables, most
of which were passed as parameters to named templates.

For the breadcrumb trail itself, I just used an axis of
ancestor-or-self::



<!-- Breadcrumb trails -->

<xslt:template name="breadcrumbs" >
<xslt:param name="Application" select="/.." />
<!-- Display a "breadcrumb" trail (as described by Nielsen) to show
where the Application is in the overall hierarchy -->

<div id="divBreadcrumbs" >
<xslt:for-each
select="$Application/ancestor-or-self::*[substring-after(@rdf:type,
'#')='Application']" >
<xslt:if test="position()!=1" > -&gt; </xslt:if>
<span class="application" ><xslt:choose>
<xslt:when test="m:menu-item" >
<xslt:call-template name="menu-item-as-nav-link" >
<xslt:with-param name="menu-item" select="m:menu-item" />
</xslt:call-template>
</xslt:when>
<xslt:eek:therwise><xslt:value-of select="./@rdf:ID"
/></xslt:eek:therwise>
</xslt:choose></span>
</xslt:for-each>
</div>
</xslt:template>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top