Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl transformation 1

Status
Not open for further replies.

wow1977

Technical User
May 13, 2007
14
DE
Hello @ all

well I am new to XML/XSLT and have problem with transforming an xml document. I need to delete the content of an element and to copy the rest of the file.

For example:

<Name>
<Barbie>
</Name>
<Age>
<21>
</Age>
<Location>
<Japan>
</Location>


I need this result:
<Name>
<Barbie>
</Name>
<Age>
<>
</Age>
<Location>
<Japan>
</Location>

it would be great if someone could help me out.

THX

 
The forum in principle can help, but not do the assignment for you. What have you done with it?
 
Hi there...sorry for not giving more informations,
actually I haven´t a methóde to delte certain elements, I am only able to copy the whole document applying:

<xsl:template match="RootElement">
<xsl:copy-of select="*"/>
</xsl:template>
, so far i dont know, how to copy-and-delete certain elements.

thx
 
With "deep copy" (xs:copy-of) and template like that where do you put up the RootElement? You result only in a document fragment without a single root element.

The general idea is to set up an identity transformation (or some reduced form of it) and set up a concrete template especially for Age making use of the priority rule of templates. Like this.
[tt]
<xsl:template match="/">
<xsl:apply-templates select="node()|text()|@*" />
</xsl:template>
<xsl:template match="node()|text()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|text()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="Age">
<xsl:copy />
</xsl:template>
[/tt]
I am sure you have to dismentle it to understand how every part of it works together.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top