Re: [xsl] tags and elements

Subject: Re: [xsl] tags and elements
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Mon, 02 Sep 2002 19:25:08 +0200
Hello Elke,

if you want to copy all the elements, you have to tell it the processor. You can't manipulate the input document. At http://www.w3.org/TR/xslt#copying you can find a template that copies everything to the output. If you want to add some elements, you must add some more template so that these elements will not be matched with the general one, but with the specific one:

identity transformation template:

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

specific template:

<xsl:template match="entries">
  <xsl:copy>
    <xsl:appply-templates select="@*|node()"/>
    <entry>a new entry</entry>
  </xsl:copy>
</xsl:template>

Hope this helps a bit,

Joerg


Naraschewski, E. wrote:
Hello,

I am just at the beginning using xslt. Right now I am doubting my comprehension of xslt. I am trying to transform an xml file into another xml file just wishing to be able to add a new element into my result file. I thought I should be able to keep all my already existing tags in the result file. Am I wrong? They all vanish. Is there a way to keep them?

While adding a new element I only get the result <entry/>. Actually I would like to enclose some more elements like this <entry>...</entry>.

The last question is, whether it is possible to ask wether an element is filled or not when using <xsl:if> or <xsl:choose>.

I am hoping to hearing from you soon.

Best regards
Elke Naraschewski


--

System Development
VIRBUS AG
Fon  +49(0)341-979-7419
Fax  +49(0)341-979-7409
joerg.heinicke@xxxxxxxxx
www.virbus.de


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



Current Thread