468,272 Members | 2,036 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

schemaLocation attribute dropped after XSL transformation

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"?>
<abc:DocumentInfo 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>
</abc:DocumentInfo>

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">
<xsl:output 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"?>
<abc:DocumentInfo 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>
</abc:DocumentInfo>
Jul 20 '05 #1
1 2709
I don't see you are doing anything wrong. Here is what I got running your
document and stylesheet through Saxon 7.5.2:

<?xml version="1.0" encoding="UTF-8"?>
<abc:DocumentInfo xmlns:abc="http://abc.com/schema"
xsi:schemaLocation="http://abc.com/schema abc.xsd "
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<BunchOfElements>....</BunchOfElements>

<Attachment Encoding="BASE64" FileType="PDF"
xmlns:abc="http://www.abc.com/schema">REMOVED</Attachment>
</abc:DocumentInfo>

I assume this is pretty much what you expected.

Bob Foster

"John" <mg*******@sneakemail.com> wrote in message
news:dc**************************@posting.google.c om...
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"?>
<abc:DocumentInfo 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>
</abc:DocumentInfo>

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">
<xsl:output 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"?>
<abc:DocumentInfo 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>
</abc:DocumentInfo>

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Sarah Tegtmeier | last post: by
reply views Thread by Ron James | last post: by
reply views Thread by Mythran | last post: by
2 posts views Thread by grochmal | last post: by
1 post views Thread by boetke | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.