472,955 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,955 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 2920
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.