J
John
I have an input document that contains a large base64 encoded
document. This document also declares a schema location in the root
element. I want to write an XSL stylesheet that makes an exact copy
(including the namespace and schema location) of the input document
except that it removes the base64 encoding and replaces it with the
text 'REMOVED'.
I have a stylesheet that does just that except that it drops the
schemaLocation attribute. Where that attribute is supposed to be I
get a ="" which then gives me an error when I parse the result because
it is not well formed XML.
I am using Xalan (not sure of the version) on Solaris with Java 1.3.1
on SunOS 5.8
Can anyone please tell me what I am doing wrong?
Thanks much,
-John
INPUT DOCUMENT:
<?xml version="1.0" encoding="UTF-8"?>
<abcocumentInfo xmlns:abc="http://abc.com/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://abc.com/schema abc.xsd ">
<BunchOfElements>....</BunchOfElements>
<Attachment Encoding="BASE64"
FileType="PDF">biglongbase64stringgoeshere</Attachment>
</abcocumentInfo>
XSL STYLESHEET:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:abc="http://www.abc.com/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0">
<xslutput indent='yes' encoding='UTF-8' method='xml'/>
<xsl:template match="/abc:TitleInfo">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Attachment" priority="10">
<Attachment>
<xsl:attribute name="Encoding"><xsl:value-of
select="./@Encoding" /></xsl:attribute>
<xsl:attribute name="FileType"><xsl:value-of
select="./@FileType" /></xsl:attribute>
<xsl:text>REMOVED</xsl:text>
</Attachment>
</xsl:template>
<xsl:template match="@*|node()" priority="1">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
<?xml version="1.0" encoding="UTF-8"?>
<abcocumentInfo xmlns:abc="http://abc.com/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ="">
<BunchOfElements>....</BunchOfElements>
<Attachment xmlns:abc="http://www.abc.com/schema" Encoding="BASE64"
FileType="PDF">REMOVED</Attachment>
</abcocumentInfo>
document. This document also declares a schema location in the root
element. I want to write an XSL stylesheet that makes an exact copy
(including the namespace and schema location) of the input document
except that it removes the base64 encoding and replaces it with the
text 'REMOVED'.
I have a stylesheet that does just that except that it drops the
schemaLocation attribute. Where that attribute is supposed to be I
get a ="" which then gives me an error when I parse the result because
it is not well formed XML.
I am using Xalan (not sure of the version) on Solaris with Java 1.3.1
on SunOS 5.8
Can anyone please tell me what I am doing wrong?
Thanks much,
-John
INPUT DOCUMENT:
<?xml version="1.0" encoding="UTF-8"?>
<abcocumentInfo xmlns:abc="http://abc.com/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://abc.com/schema abc.xsd ">
<BunchOfElements>....</BunchOfElements>
<Attachment Encoding="BASE64"
FileType="PDF">biglongbase64stringgoeshere</Attachment>
</abcocumentInfo>
XSL STYLESHEET:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:abc="http://www.abc.com/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0">
<xslutput indent='yes' encoding='UTF-8' method='xml'/>
<xsl:template match="/abc:TitleInfo">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Attachment" priority="10">
<Attachment>
<xsl:attribute name="Encoding"><xsl:value-of
select="./@Encoding" /></xsl:attribute>
<xsl:attribute name="FileType"><xsl:value-of
select="./@FileType" /></xsl:attribute>
<xsl:text>REMOVED</xsl:text>
</Attachment>
</xsl:template>
<xsl:template match="@*|node()" priority="1">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
OUTPUT:
<?xml version="1.0" encoding="UTF-8"?>
<abcocumentInfo xmlns:abc="http://abc.com/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ="">
<BunchOfElements>....</BunchOfElements>
<Attachment xmlns:abc="http://www.abc.com/schema" Encoding="BASE64"
FileType="PDF">REMOVED</Attachment>
</abcocumentInfo>