This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Trouble writing .xsl
- From: "Sullivan, Dan" <dsullivan at develop dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Sat, 12 Jan 2002 19:16:39 -0800
- Subject: RE: [xsl] Trouble writing .xsl
- Reply-to: xsl-list at lists dot mulberrytech dot com
You need to make use of an identity transform like this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:ABC="org.jason">
<!-- identity transform, for everything you don't care about changing
-->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- transform for jason, the only element you care about changing -->
<xsl:template match="ABC:jason.Smith">
<ABC:Smith>
<!-- process children, atrs, if any -->
<xsl:apply-templates select="@*|node()"/>
</ABC:Smith>
</xsl:template>
</xsl:stylesheet>
Also your source file had a typo in it (XMI Content).
Dan
-----Original Message-----
From: Jason Rizer [mailto:jasonriz@yahoo.com]
Sent: Saturday, January 12, 2002 8:54 PM
To: XSL-List@lists.mulberrytech.com
Subject: [xsl] Trouble writing .xsl
Hello,
I've just recently begun using xslt and I'm kind of
stuck on something pretty simple. I've worked through
parts of a couple of tutorials but I still can't seem
to handle this problem. I'd like to convert (for
example) the following chunk of xml:
<?xml version="1.0" encoding="UTF-8" ?>
<XMI xmlns:ABC="org.jason">
<XMI.content>
<ABC:jason.Smith>
<LL/>
</ABC:jason.Smith>
<Smith/>
<XMI content>
</XMI>
to this chunk:
<?xml version="1.0" encoding="UTF-8" ?>
<XMI xmlns:ABC="org.jason">
<XMI.content>
<ABC:Smith>
<LL/>
</ABC:Smith>
<Smith/>
<XMI content>
</XMI>
In other words I want to replace each elament named
jason.Smith with an identical element (ie not affect
any of it's children or it's attributes) named Smith
but only when It occurs in the Namespace ABC. I want
all other elements in the output file to remain
unchanged. I think I need to use the XPATH namespace(
) function in my match expression but I can't quite
seem to get it to work. Any help with creating this
stylesheet would be greatly appreciated. Thanks in
advance!
-Jason
ps - What would a style sheet look like which created
an output xml document identical to the source xml
document?
__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list