473,396 Members | 1,970 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.

XML-Stylesheet declaration in DTD causing issues

I have a few questions about this problem I'm having involving XML,
DTD, and XSL.

I'm working with this DTD which defines a stylesheet, as such...

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="abc-xsl.xsl"?>
<!ELEMENT ABCMessage (Tag1, Tag2, Tag3, Tag4, Tag5, Tag6, Tag7,
Tag8*)>
<!ATTLIST ABCMessage
version CDATA #REQUIRED
release CDATA #REQUIRED

etc...

What does it mean that this DTD has an xml-stylesheet tag in it? Is
this a valid or meaningful tag for a DTD?

It's causing me a problem because I'm using Java code and XSL to
"print" an XML document which complies with this DTD. My Java code
looks something like this...

TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();

transformer.setOutputProperty("indent", indent ? "yes" : "no");
transformer.setOutputProperty("method", methodType);

// if ommitting xml declaration, omit_xml_declaration will be "yes"
// otherwise, omit_xml_declaration will not be provided, "no" is the
default
if (omitXMLDeclaration)
{
transformer.setOutputProperty("omit-xml-declaration", "yes");
}

DocumentType docType = doc.getDoctype();
if (docType != null)
{
transformer.setOutputProperty("doctype-system",
docType.getSystemId());
}

DOMSource source = new DOMSource(doc);
StringWriter resultWriter = new StringWriter();
StreamResult result = new StreamResult(resultWriter);
transformer.transform(source, result);
return resultWriter.getBuffer().toString();

The Transformer stuff is from the javax.xml.transformer package. What
I'm seeing in my result is that xml-stylesheet tag. It even appears
multiple times, like this...

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="abc-xsl.xsl"?>
<?xml-stylesheet type="text/xsl" href="abc-xsl.xsl"?>
<!DOCTYPE ABCMessage SYSTEM "abc-xml.dtd">
<ABCMessage release="3" version="2">
....
</ABCMessage>
What is causing this stylesheet tag to appear at all in my resulting
XML? Should I try to remove it? I also don't exactly know why its
appearing more than once, but I suspect it could have to do with the
fact that I call the code snippet above more than once.

Any theories or information about xml-stylesheet in DTD would be
greatly appreciated.
Jul 20 '05 #1
3 3060
Sarah Haskins wrote:
I have a few questions about this problem I'm having involving XML,
DTD, and XSL.

I'm working with this DTD which defines a stylesheet, as such...

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="abc-xsl.xsl"?>
<!ELEMENT ABCMessage (Tag1, Tag2, Tag3, Tag4, Tag5, Tag6, Tag7,
Tag8*)>
<!ATTLIST ABCMessage
version CDATA #REQUIRED
release CDATA #REQUIRED
etc...

What does it mean that this DTD has an xml-stylesheet tag in it? Is
this a valid or meaningful tag for a DTD?

It's causing me a problem because I'm using Java code and XSL to
"print" an XML document which complies with this DTD. My Java code
looks something like this...

TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();

transformer.setOutputProperty("indent", indent ? "yes" : "no");
transformer.setOutputProperty("method", methodType);

// if ommitting xml declaration, omit_xml_declaration will be "yes"
// otherwise, omit_xml_declaration will not be provided, "no" is the
default
if (omitXMLDeclaration)
{
transformer.setOutputProperty("omit-xml-declaration", "yes");
}

DocumentType docType = doc.getDoctype();
if (docType != null)
{
transformer.setOutputProperty("doctype-system",
docType.getSystemId());
}

DOMSource source = new DOMSource(doc);
StringWriter resultWriter = new StringWriter();
StreamResult result = new StreamResult(resultWriter);
transformer.transform(source, result);
return resultWriter.getBuffer().toString();

The Transformer stuff is from the javax.xml.transformer package. What
I'm seeing in my result is that xml-stylesheet tag. It even appears
multiple times, like this...

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="abc-xsl.xsl"?>
<?xml-stylesheet type="text/xsl" href="abc-xsl.xsl"?>
<!DOCTYPE ABCMessage SYSTEM "abc-xml.dtd">
<ABCMessage release="3" version="2">
...
</ABCMessage>
What is causing this stylesheet tag to appear at all in my resulting
XML? Should I try to remove it? I also don't exactly know why its
appearing more than once, but I suspect it could have to do with the
fact that I call the code snippet above more than once.

Any theories or information about xml-stylesheet in DTD would be
greatly appreciated.

Depending in the way your XSLT stylesheet is written in may be caused by
the transformer not using default template for Processing Instrictions
that omits them.

--
J. D. Addison

Jul 20 '05 #2
Puff Addison <pu**@theaddisons.demon.co.uk> wrote in message news:<bu*******************@news.demon.co.uk>...
Sarah Haskins wrote:
I have a few questions about this problem I'm having involving XML,
DTD, and XSL.

I'm working with this DTD which defines a stylesheet, as such...

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="abc-xsl.xsl"?>
<!ELEMENT ABCMessage (Tag1, Tag2, Tag3, Tag4, Tag5, Tag6, Tag7,
Tag8*)>
<!ATTLIST ABCMessage
version CDATA #REQUIRED
release CDATA #REQUIRED
etc...

What does it mean that this DTD has an xml-stylesheet tag in it? Is
this a valid or meaningful tag for a DTD?

It's causing me a problem because I'm using Java code and XSL to
"print" an XML document which complies with this DTD. My Java code
looks something like this...

TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();

transformer.setOutputProperty("indent", indent ? "yes" : "no");
transformer.setOutputProperty("method", methodType);

// if ommitting xml declaration, omit_xml_declaration will be "yes"
// otherwise, omit_xml_declaration will not be provided, "no" is the
default
if (omitXMLDeclaration)
{
transformer.setOutputProperty("omit-xml-declaration", "yes");
}

DocumentType docType = doc.getDoctype();
if (docType != null)
{
transformer.setOutputProperty("doctype-system",
docType.getSystemId());
}

DOMSource source = new DOMSource(doc);
StringWriter resultWriter = new StringWriter();
StreamResult result = new StreamResult(resultWriter);
transformer.transform(source, result);
return resultWriter.getBuffer().toString();

The Transformer stuff is from the javax.xml.transformer package. What
I'm seeing in my result is that xml-stylesheet tag. It even appears
multiple times, like this...

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="abc-xsl.xsl"?>
<?xml-stylesheet type="text/xsl" href="abc-xsl.xsl"?>
<!DOCTYPE ABCMessage SYSTEM "abc-xml.dtd">
<ABCMessage release="3" version="2">
...
</ABCMessage>
What is causing this stylesheet tag to appear at all in my resulting
XML? Should I try to remove it? I also don't exactly know why its
appearing more than once, but I suspect it could have to do with the
fact that I call the code snippet above more than once.

Any theories or information about xml-stylesheet in DTD would be
greatly appreciated.

Depending in the way your XSLT stylesheet is written in may be caused by
the transformer not using default template for Processing Instrictions
that omits them.


I don't actually use a XSLT file. As you can see in the code snippet
above, I don't pass a DOMSource when I call
tFactory.newTransformer();. So I'm basically creating a blank XSL in
memory, in order to do a full copy of the XML into a Stream. If
there's a way to omit xml-stylesheet in an XSL doc, then there's got
to be a way to do this in the Java code too. Any idea which attribute
that would be? I'm familiar with "omit-xml-declaration", but I don't
think there's an "omit-xml-stylesheet" option.

Or even a better way to get a String value from an XML Document. I'm
open to suggestions.
Jul 20 '05 #3
Sarah Haskins wrote:
Puff Addison <pu**@theaddisons.demon.co.uk> wrote in message news:<bu*******************@news.demon.co.uk>...

Sarah Haskins wrote:
I have a few questions about this problem I'm having involving XML,
DTD, and XSL.

I'm working with this DTD which defines a stylesheet, as such...

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="abc-xsl.xsl"?>
<!ELEMENT ABCMessage (Tag1, Tag2, Tag3, Tag4, Tag5, Tag6, Tag7,
Tag8*)>
<!ATTLIST ABCMessage
version CDATA #REQUIRED
release CDATA #REQUIRED
etc...

What does it mean that this DTD has an xml-stylesheet tag in it? Is
this a valid or meaningful tag for a DTD?

It's causing me a problem because I'm using Java code and XSL to
"print" an XML document which complies with this DTD. My Java code
looks something like this...

TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();

transformer.setOutputProperty("indent", indent ? "yes" : "no");
transformer.setOutputProperty("method", methodType);

// if ommitting xml declaration, omit_xml_declaration will be "yes"
// otherwise, omit_xml_declaration will not be provided, "no" is the
default
if (omitXMLDeclaration)
{
transformer.setOutputProperty("omit-xml-declaration", "yes");
}

DocumentType docType = doc.getDoctype();
if (docType != null)
{
transformer.setOutputProperty("doctype-system",
docType.getSystemId());
}

DOMSource source = new DOMSource(doc);
StringWriter resultWriter = new StringWriter();
StreamResult result = new StreamResult(resultWriter);
transformer.transform(source, result);
return resultWriter.getBuffer().toString();

The Transformer stuff is from the javax.xml.transformer package. What
I'm seeing in my result is that xml-stylesheet tag. It even appears
multiple times, like this...

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="abc-xsl.xsl"?>
<?xml-stylesheet type="text/xsl" href="abc-xsl.xsl"?>
<!DOCTYPE ABCMessage SYSTEM "abc-xml.dtd">
<ABCMessage release="3" version="2">
...
</ABCMessage>
What is causing this stylesheet tag to appear at all in my resulting
XML? Should I try to remove it? I also don't exactly know why its
appearing more than once, but I suspect it could have to do with the
fact that I call the code snippet above more than once.

Any theories or information about xml-stylesheet in DTD would be
greatly appreciated.

Depending in the way your XSLT stylesheet is written in may be caused by
the transformer not using default template for Processing Instrictions
that omits them.


I don't actually use a XSLT file. As you can see in the code snippet
above, I don't pass a DOMSource when I call
tFactory.newTransformer();. So I'm basically creating a blank XSL in
memory, in order to do a full copy of the XML into a Stream. If
there's a way to omit xml-stylesheet in an XSL doc, then there's got
to be a way to do this in the Java code too. Any idea which attribute
that would be? I'm familiar with "omit-xml-declaration", but I don't
think there's an "omit-xml-stylesheet" option.

Or even a better way to get a String value from an XML Document. I'm
open to suggestions.

Oops! I did not read the code very carefully. As the Transformer does a
simple copy the question is why does the stylesheet processing
instuction occur twice? If you want to get rid of the style sheet
processing instruction you will need to use a simple stylesheet to do
the transformation.

<xsl:stylesheet xmlns:xls=http://www.w3.org/1999/XSL/Transform"
version="1.0 >
</xsl:stylesheet>

Should remove the processing instrunctions and copy the markup.
Puff

--
J. D. Addison
email pu**@theaddisons.demon.co.uk
Jul 20 '05 #4

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

Similar topics

0
by: Phil Powell | last post by:
// PROCESS XML CONTENT INTO DYNAMICALLY-NAMED ARRAYS foreach (array('mime', 'state', 'country') as $val) { $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);...
8
by: Robert J Egan | last post by:
Hi i'm trying to search a remote website page. The form returns xml information, though the page extension is missing. I retrieve the information and write it to the screen. So far so good -...
1
by: felipe_azv | last post by:
a got this code in asp to construct a xml , to export it to a url this is de asp code: <% SQL = "Select * from User where CodeUser in ("& request.form("C1" &")" set rs =...
0
by: MarionEll | last post by:
Premier XML Industry Event Slated for Dec. 7-12 in Philadelphia; Presenters Include Adobe, BEA, Microsoft, IBM, Sun, Hewlett-Packard, Oracle Alexandria, Va. Sept. 30, 2003 - IDEAlliance, a...
0
by: Stylus Studio | last post by:
World's Most Advanced XML Schema Editor Adds Support for IBM AlphaWorks XML Schema Quality Checker to Improve XML Schema Style and Quality BEDFORD, MA -- 09/13/2005 -- Stylus Studio...
5
by: Kurt Bauer | last post by:
I have an ASP group calendar application which pulls calendar data from Exchange via webdav into an XML string. I then loop the XML nodes to populate a collection of appointments. Finally I use...
0
by: jts2077 | last post by:
I am trying to create a large nested XML object using E4X methods. The problem is the, the XML I am trying to create can only have xmlns set at the top 2 element levels. Such as: <store ...
9
by: Lie | last post by:
Why this generates AttributeError, then not? Python 2.5.2 (r252:60911, Apr 21 2008, 11:17:30) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most...
10
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I had a program and it always works fine and suddenly it gives me the following message when a pass a xml file to our server program: error code: -1072896680 reason: XML document must...
0
by: Jacker | last post by:
Xpress Author for MS Word XML Documents In.vision Research empowers knowledge workers to create complex XML documents in Microsoft Word (2000-2003) with a normal Word experience. Deploy XML...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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.