469,611 Members | 1,933 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,611 developers. It's quick & easy.

XSLT: small changes to xml from XPath

Hello

How do I copy most of a xml file, but change a few attributes and/or
elements based on a xpath?
How do I make the xslt file?
I know this description isn't much, but here is a small example

<root>
...
<element atr="value"/>
...
</root>

to

<root>
...
<element atr="*new value*"/>
...
</root>
Sep 14 '07 #1
1 1456
Like below:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

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

<xsl:template match="element">
<xsl:copy>
<xsl:attribute name="atr">*new value*</xsl:attribute>
<xsl:apply-templates select="node|@*[not(name()='atr')]"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina - http://aboutxml.blogspot.com/
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Sep 15 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jeff Kish | last post: by
4 posts views Thread by Son KwonNam | last post: by
2 posts views Thread by Matt Frame | last post: by
2 posts views Thread by Pawel | last post: by
3 posts views Thread by Ian Roddis | last post: by
1 post views Thread by Sergey Dubinets | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.