Re: [xsl] Transforming a Loose Structure

Subject: Re: [xsl] Transforming a Loose Structure
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 21 Mar 2007 09:48:41 GMT
> how can i make my output so that will conform to the restrictions?

That tepends totally on the part that you haven't specified, namely

>  will not have correct counter part from the output, but i think i'll
> have to default them in someway. 

a stylesheet that just has
<xsl:template match="/">
  <xsl:value-of select="."/>

will produce conforming output but presumably isn't the behaviour you

In general it seems like you want the idenity transform

<xsl:template match="*">

Then add templates for things you don't want to copy, but you need to
say what you do want to do.

Also your restrictions are not clear, for example when you say
<sup> - can only contain <i>, <b>
do you mena by contain, that they are the only children, or only

so for example if you have
<sup> a <sup>b</sup></sup>
then that isn't allowed, but is
<sup> a <i><sup>b</sup></i></sup>
If it is, then that's an easy fix, just wrap any non-allowed element in
i and it becomes allowed. Assuming that thi sis not allowed and you only
allow 1 and b as descendants of sup then
For example

<xsl:template match="sup//*[not(self::i|self::b]">

matches any element that is not allowed in sup, so you need to say what
to do with it.

<xsl:template match="sup//*[not(self::i|self::b]">

just loses the element, and processes its content

<xsl:template match="sup//*[not(self::i|self::b]"/>

loses the element and all its content

<xsl:template match="sup//*[not(self::i|self::b]">
<i original="{name()}">

turns the banned element into an allowed <i> element together with an
attribute that records the original name



Current Thread