|
Subject: AW: [xsl] not having all the children of an element in the output From: christof.hoeke@xxxxxxx Date: Tue, 30 Dec 2003 13:24:55 +0100 |
hi,
the trick is to define an empty stylesheet for "note":
<xsl:template match="p | term">
<xsl:element name="{name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="note"/>
the first template simply copies (or better constructs anew) the elements p and term and then processes all contained elements/text. the 2nd does nothing, so effectively the "note" elements and all their children elements/text will be stripped from the output.
i used the following xml and hope its what you meant, your example was not wellformed:
<p>some text <term>some phrase</term><note><term>basic form of the phrase><gloss>explanation of the phrase</gloss>some text.</term></note>
</p>
chris
> -----Ursprüngliche Nachricht-----
> Von: Toma Tasovac [mailto:ttasovac@xxxxxxxxxxxxx]
> Gesendet: Dienstag, 30. Dezember 2003 13:05
> An: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Betreff: [xsl] not having all the children of an element in the output
>
>
> Hi! This is a pretty basic question, so I hope you won't mind me
> posting it here.
>
> I have an XML doc which contains certain marked terms and has notes
> attached next to them, like this:
>
> <p>some text <term>some phrase</term><note><term>basic
> form of the
> phrase><gloss>explanation of the phrase</gloss>some text.</p>
>
> In other words, <p> element can have two children: <term> marking the
> phrase as it appears in the text and being part of the text
> itslef, and
> <note> which attaches a note explaining the term in some detail.
>
> I am having problems designing an xsl template which will output:
>
> <p>some text<term>some phrase</term>some text</p>
>
> i.e. which will include only one of the two possible children
> elements... Everything I do outputs either both <term> and <note> OR
> neither one of them... What's the trick?
>
> Many thanks in advance,
>
> Toma
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] not having all the childr, Vasu Chakkera | Thread | [xsl] Embedded xsl:for-each, Mark Williams |
| [xsl] not having all the children o, Toma Tasovac | Date | RE: [xsl] count and write number of, Andreas L. Delmelle |
| Month |