473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 2945
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Naresh Agarwal | last post by:
Hi I'm using SAX Parser of Xerces Java v2.4.0 for XML Parsing. I want to perform schema validations on the xml. The problem is that root element of XML document does not have...
0
by: Sarah Tegtmeier | last post by:
Hi I have a question about the correct use of the attribute xsi:schemaLocation. My programm has to process XML files where the value of this attribute causes some problems. The programm is...
0
by: Ron James | last post by:
I'm developing a GUI application in C#. I have a schema file (.XSD) and am able to serialize and deserialize the applications data using the schema file to an .XML file. (I'm using xsd.exe to...
0
by: Mythran | last post by:
I have an xsd file that I wrote and testing in a .Net application. It works fine. Now I want to be able to create XML files based on this xsd that are not part of a .Net project. I want to edit...
2
by: kaush | last post by:
Hi all, I am trying to serialize a C# object into a XML document using "XmlSerializer" class. One of the elements of the XML document needs a "xsi:schemaLocation" attribute. I am not sure how to...
1
by: techie | last post by:
Hi, I am using an xml schema (Schema1.xsd) which refers to two other Schemas as follows. <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:plcm-s="http://www.mycompany.com/plcm"...
2
by: grochmal | last post by:
I am trying to use XmlSerializer to serialize a class I have created specifically for generating an XML file. The problem is that the XML file must contain a xsi:schemaLocation attribute in my...
0
by: spiceworm | last post by:
Hi all, I'm getting really confused how to solve this. I've got this class generated from XSD with xsd (from visual studio 2005) namespace gpx { using System.Xml.Serialization;
1
by: boetke | last post by:
Hi all, I am attempting to create an xslt transformation which I am having trouble with. I am fairly new to xslt and am having a hard time getting my head around it. The original xml file looks...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.