first, you need to use XHTML (because you can apply XSLT only on XML documents)
very simple example
- <?xml version="1.0" encoding="UTF-8" ?>
-
<root>
-
<para>I was here</para>
-
</root>
- <?xml version="1.0" encoding="UTF-8" ?>
-
<xsl:stylesheet version="1.0"
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
-
<xsl:output
-
method="xml"
-
encoding="utf-8"
-
doctype-public="-//W3C//DTD XHTML 1.1//EN" />
-
-
<xsl:template match="/">
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-
<head>
-
<title>sample.xml transformed</title>
-
</head>
-
<body>
-
<p><xsl:value-of select="para[1]/text()"/></p>
-
</body>
-
</html>
-
</xsl:template>
-
</xsl:stylesheet>
- <?xml version="1.0" encoding="UTF-8" ?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-
<head>
-
<title>sample.xml transformed</title>
-
</head>
-
<body>
-
<p>I was here</p>
-
</body>
-
</html>
the reverse XSLT would be like:
- <?xml version="1.0" encoding="UTF-8" ?>
-
<xsl:stylesheet version="1.0"
-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
-
<xsl:output
-
method="xml"
-
encoding="utf-8" />
-
-
<xsl:template match="/">
-
<root>
-
<para><xsl:value-of select="//p[1]/text()"/></para>
-
</root>
-
</xsl:template>
-
</xsl:stylesheet>
needless to say, that the complexity of the reverse stylesheet will skyrocket, as you increase the complexity of the XML and XSL files.
maybe there is a possibility to track the changes, so that you can do a string replace directly in the XML file (requires a script/programm)