I need to iterate over a bunch of XML documents and simply change the value of one attribute using XSLT 2.0. The rest of the document as well as the document name need to be the same.
Is it possible to simply change an existing document without creating a new one as output of the transformation? Or do I need to copy the documents, change the attribute and name them the same as the original one?
EDIT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:fn='http://www.w3.org/2005/xpath-functions' exclude-result-prefixes='xsl xs fn' xmlns:h="http://java.sun.com/jsf/html">
<xsl:output method="xml" encoding="utf-8"/>
<xsl:strip-space elements="*"/>
<xsl:param name="files" select="collection('./output?select=*.html')"/>
<xsl:template match="/">
<xsl:for-each select="$files">
<xsl:variable name="fileName" select="tokenize(base-uri(), '/')[last()]"/>
<xsl:result-document method="xhtml" href="new/{$fileName}">
<div>
<h:selectBooleanCheckbox value="pubs"/>
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</div>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
<xsl:template match="@src">
<xsl:variable name="folderName" select="tokenize(base-uri(), '/')[last()-2]"/>
<xsl:text>http://localserver.com/</xsl:text>
<xsl:value-of select="$folderName"/>
<xsl:text>/output/</xsl:text>
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
It doesn't work. Only the textnodes are selected. How can I get this to work?