I hope this is the right forum to bring this up... it's not really a bug, just an idea that I hope you like.
At my company, we have a lot of XML documents that are used to configure software (like Tomcat, log4j, etc.), so we often find ourselves making a small set of changes to a group of XML documents. We've found XSLT to be a bit of a hassle for small changes - XSL was designed to process every node in a document, whereas we want to output the bulk of the document by default, with only some minor changes. To address this, I've used Xalan to write a more sed-like processor that outputs the XML tree unchanged unless a rule is applied to a node.
So, for example, to change all of the priority values in a log4j configuration file to debug, we would apply a rule like:
Or, to change each web.xml file in a cluster of Tomcat servers to use digeset login authentication, we might apply a rule like:
//login-config/auth-method DIGEST
Both of which are tasks that we previously maintained long, complex XSLT "scripts" to perform. The left-hand side is a valid XPath, separated by whitespace from the right-hand side, which specifies the new value for the matched node (if any). If the left-hand node matches an element node, the right-hand side is a new or replacement text node; if the left-hand side matches an attribute node, the right-hand side is a new value for it. If no nodes match in the processed document, then nothing happens.
My questions to the group are:
a) am I duplicating effort?
b) if not, is this something that the Xalan community thinks is worthwhile/would like? I'd love to finally, after so many years of leeching off of you, be able to give something back to open source - right now, my processor is dirt-simple (all it does is find a node, replace its value, and output the whole document... I wrote it in a single morning under duress), but I was considering making it more sed-like, so that I could give it a set of rules like:
(I arbirtarialy chose the ~ character as a pattern-match delimiter; SED uses the / character, which is meaningful to XPath).
or even do some pattern-replacement like:
~//appender/[EMAIL PROTECTED]'File']/@value~s~../~~
In other words, match the XPath "//appender/[EMAIL PROTECTED]'File']/@value" (which resolves to an attribute node) and run the "substitute" command on its contents, substituting the string "../" for the empty string "". (Using the ~ as a separator for consistency).
This is something I use a *very* complex XSLT rule to do right now:
<xsl:template match="[EMAIL PROTECTED]'File']">
<xsl:copy>
<xsl:attribute name="name"><xsl:value-of select=./@name /></xsl:attribute>
<xsl:attribute anem="value">
<xsl:if test="substring( ./@value, 1, 2 ) = '..'">
<xsl:value-of select="substring( ./@value, 4 )" />
</xsl:if>
<xsl:if test="substring( ./@value, 1, 2 ) != '..'">
</xsl:if>
</xsl:attribute>
<xsl:aply-templates />
</xsl:copy>
</xsl:template>
Please let me know if anybody is interested in seeing this sort of program.