Skip to Content.
Sympa Menu

xom-interest - RE: [XOM-interest] XSLTransform

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Jacobs, Robert A." <ra.jacobs AT ngc.com>
  • To: "Michael Kay" <mike AT saxonica.com>, "XOM (E-mail)" <xom-interest AT lists.ibiblio.org>
  • Cc:
  • Subject: RE: [XOM-interest] XSLTransform
  • Date: Thu, 31 Mar 2005 10:01:22 -0600


>> I thought I followed the guidance in "XML in a Nutshell"
>> fairly well, but
>> perhaps I didn't. Here are some fragments from my XMLSchema-instance
>> document and my XMLSchema document. Anything stand out as erroneous?

> No, but you haven't shown us any stylesheet code.

Here you go:

--------------------- code -----------------------

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<!-- CONFIGURATION -->
<xsl:output method="html" />

<!-- GLOBAL VARIABLES -->
<xsl:key name="task.id" match="task" use="@id" />
<xsl:param name="selected.task.id"> </xsl:param>
<xsl:param name="selected.mode"> </xsl:param>

<!-- TEMPLATES -->

<!-- The "driver". Based upon the submitted parameters, the driver
directs the Transformer to the appropriate processing template -->
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$selected.mode = 'task_list'">
<xsl:apply-templates select="//task[@id = $selected.task.id]"
mode="task_list" />
</xsl:when>
<xsl:when test="$selected.mode = 'task_desc'">
<xsl:apply-templates select="//task[@id = $selected.task.id]"
mode="task_desc" />
</xsl:when>
</xsl:choose>
</xsl:template>

<!-- This template is used to build a list of task titles based upon the
ID
of a discrete- or meta-task selected either from the search results
or from
an existing list of tasks.
-->
<xsl:template match="task" mode="task_list">
<xsl:choose>

<xsl:when test="@task_type='meta'">
<xsl:value-of select="title"/><br/>
<ol>
<xsl:for-each select="node()">
<!-- DEBUG: Looking at: <xsl:value-of
select="local-name()" /> -->
<xsl:choose>

<xsl:when test="local-name() = 'option'">
<li>Select one of the following:<br/>
<ul>
<xsl:for-each select="current()/step">
<xsl:variable name="step_idref"
select="current()" />
<li>
<a><xsl:attribute name="href">

<xsl:text>javascript:get_explanation('</xsl:text>
<xsl:value-of
select="$step_idref" />
<xsl:text>');</xsl:text>
</xsl:attribute>
<xsl:value-of
select="//task[@id=$step_idref]/title"/>
</a>
</li>
</xsl:for-each>
</ul>
</li>
</xsl:when>

<xsl:when test="local-name() = 'step'">
<xsl:variable name="step_idref"
select="current()" />
<li>
<a><xsl:attribute name="href">

<xsl:text>javascript:get_explanation('</xsl:text>
<xsl:value-of select="$step_idref" />
<xsl:text>');</xsl:text>
</xsl:attribute>
<xsl:value-of
select="//task[@id=$step_idref]/title"/>
</a>
</li>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</ol>
</xsl:when>

<xsl:when test="@task_type='discrete'">
<a><xsl:attribute name="href">
<xsl:text>javascript:get_explanation('</xsl:text>
<xsl:value-of select='@id' />
<xsl:text>');</xsl:text>
</xsl:attribute>
<xsl:value-of select="title"/>
</a>
</xsl:when>

</xsl:choose>
</xsl:template>


<!-- This template is used to retrieve the contents of the <task_text>
element of the <task> with the @id that matches the value provided in
the $selected.task.id param. The contents of a single <task_text>
element should be returned.
-->
<xsl:template match="task" mode="task_desc">
<xsl:value-of select="task_text" />
</xsl:template>

</xsl:stylesheet>




Archive powered by MHonArc 2.6.24.

Top of Page