473,566 Members | 2,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:DocumentIn fo xmlns:abc="http ://abc.com/schema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://abc.com/schema abc.xsd ">
<BunchOfElement s>....</BunchOfElements >
<Attachment Encoding="BASE6 4"
FileType="PDF"> biglongbase64st ringgoeshere</Attachment>
</abc:DocumentInf o>

XSL STYLESHEET:
<?xml version="1.0"?>
<xsl:styleshe et 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="Attachme nt" priority="10">
<Attachment>
<xsl:attribut e name="Encoding" ><xsl:value-of
select="./@Encoding" /></xsl:attribute>
<xsl:attribut e name="FileType" ><xsl:value-of
select="./@FileType" /></xsl:attribute>
<xsl:text>REMOV ED</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:DocumentIn fo xmlns:abc="http ://abc.com/schema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" ="">
<BunchOfElement s>....</BunchOfElements >
<Attachment xmlns:abc="http ://www.abc.com/schema" Encoding="BASE6 4"
FileType="PDF"> REMOVED</Attachment>
</abc:DocumentInf o>
Jul 20 '05 #1
1 2958
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:DocumentIn fo xmlns:abc="http ://abc.com/schema"
xsi:schemaLocat ion="http://abc.com/schema abc.xsd "
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">

<BunchOfElement s>....</BunchOfElements >

<Attachment Encoding="BASE6 4" FileType="PDF"
xmlns:abc="http ://www.abc.com/schema">REMOVED </Attachment>
</abc:DocumentInf o>

I assume this is pretty much what you expected.

Bob Foster

"John" <mg*******@snea kemail.com> wrote in message
news:dc******** *************** ***@posting.goo gle.com...
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:DocumentIn fo xmlns:abc="http ://abc.com/schema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://abc.com/schema abc.xsd ">
<BunchOfElement s>....</BunchOfElements >
<Attachment Encoding="BASE6 4"
FileType="PDF"> biglongbase64st ringgoeshere</Attachment>
</abc:DocumentInf o>

XSL STYLESHEET:
<?xml version="1.0"?>
<xsl:styleshe et 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="Attachme nt" priority="10">
<Attachment>
<xsl:attribut e name="Encoding" ><xsl:value-of
select="./@Encoding" /></xsl:attribute>
<xsl:attribut e name="FileType" ><xsl:value-of
select="./@FileType" /></xsl:attribute>
<xsl:text>REMOV ED</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:DocumentIn fo xmlns:abc="http ://abc.com/schema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" ="">
<BunchOfElement s>....</BunchOfElements >
<Attachment xmlns:abc="http ://www.abc.com/schema" Encoding="BASE6 4"
FileType="PDF"> REMOVED</Attachment>
</abc:DocumentInf o>

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6357
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 "xsi:schemaLocation" attribute, which is used to specify the .xsd file. Is there any other way for specifying the name of .xsd file?
0
10710
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 written in C++ using Xerces C++ version 2.3.0. An older older version of the programm used Xerces C++ version 1.6.0. The XML files look like the...
0
2652
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 generate my serializable class, XmlSerializer to Serialize and DeSerialize and XMLValidatingReader to validate. My intention is that application...
0
1054
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 them in the .Net IDE as a separate file without having a project open. The xsd is located on my hard drive and the namespace is something like...
2
7477
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 add this to the XML element Please help me with if you can. Thanks, kaush
1
11262
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" targetNamespace="http://www.mycompany.com/plcm" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xsd:include...
2
18413
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 root node but I can't figure out any way to do it. Here is what the resulting XML file must look like (small sample): <TXLife...
0
6255
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
2202
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 like this: <DataSet ID="-5480"> <ObsGroup> <ClsItem name="AGE">2099</ClsItem> <ClsItem name="COMB_DATA">20</ClsItem> <ClsItem...
0
7666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7644
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6260
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.