Re: [xsl] XSL -XML to XSL reorienting node

Subject: Re: [xsl] XSL -XML to XSL reorienting node
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 27 Jun 2002 18:19:09 +0100
Hi Mike,

> What I am wondering is why I cannot seem to exclude the children
> nodes and still get the parent nodes when I reorient my
> apply-templates.

I found your description a little hard to follow, but perhaps it would
help to apply templates to everything, but have templates that match
the elements that you do not want to create templates for and do
nothing with them:

<xsl:template match="SCRGRP | SCRGRPX | NON-SCORE | SCORE" />

You might also find using xsl:namespace-alias useful. You could do
something like:

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

<xsl:namespace-alias stylesheet-prefix="#default"
                     result-prefix="xsl" />

<xsl:template match="*[*]">
  <template match="{name()}">
    <apply-templates select="{name(*)}" />
  </template>
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="SCRGRP | SCRGRPX | NON-SCORE | SCORE"
              priority="1" />

</xsl:stylesheet>

This will create a template for every element that contains another
element, and the template will apply templates to those children that
have the same name as the first child of that element.

The thing is that this will create a separate template for each
element, even if it has the same name as an element for which a
template has already been generated. Perhaps it would make more sense
to use your schema to create the stylesheet? And are you sure that you
only want the template to apply templates to those child elements that
are named the same as the first child element, rather than all
children?

If you'd supply an example source document and an example stylesheet
that you want generated from that source document, we might be able to
help more.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread