473,654 Members | 3,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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...

TransformerFact ory tFactory = TransformerFact ory.newInstance ();
Transformer transformer = tFactory.newTra nsformer();

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

// if ommitting xml declaration, omit_xml_declar ation will be "yes"
// otherwise, omit_xml_declar ation will not be provided, "no" is the
default
if (omitXMLDeclara tion)
{
transformer.set OutputProperty( "omit-xml-declaration", "yes");
}

DocumentType docType = doc.getDoctype( );
if (docType != null)
{
transformer.set OutputProperty( "doctype-system",
docType.getSyst emId());
}

DOMSource source = new DOMSource(doc);
StringWriter resultWriter = new StringWriter();
StreamResult result = new StreamResult(re sultWriter);
transformer.tra nsform(source, result);
return resultWriter.ge tBuffer().toStr ing();

The Transformer stuff is from the javax.xml.trans former 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 3095
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...

TransformerFact ory tFactory = TransformerFact ory.newInstance ();
Transformer transformer = tFactory.newTra nsformer();

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

// if ommitting xml declaration, omit_xml_declar ation will be "yes"
// otherwise, omit_xml_declar ation will not be provided, "no" is the
default
if (omitXMLDeclara tion)
{
transformer.set OutputProperty( "omit-xml-declaration", "yes");
}

DocumentType docType = doc.getDoctype( );
if (docType != null)
{
transformer.set OutputProperty( "doctype-system",
docType.getSys temId());
}

DOMSource source = new DOMSource(doc);
StringWriter resultWriter = new StringWriter();
StreamResult result = new StreamResult(re sultWriter);
transformer.tra nsform(source, result);
return resultWriter.ge tBuffer().toStr ing();

The Transformer stuff is from the javax.xml.trans former 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**@theaddiso ns.demon.co.uk> wrote in message news:<bu******* ************@ne ws.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...

TransformerFact ory tFactory = TransformerFact ory.newInstance ();
Transformer transformer = tFactory.newTra nsformer();

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

// if ommitting xml declaration, omit_xml_declar ation will be "yes"
// otherwise, omit_xml_declar ation will not be provided, "no" is the
default
if (omitXMLDeclara tion)
{
transformer.set OutputProperty( "omit-xml-declaration", "yes");
}

DocumentType docType = doc.getDoctype( );
if (docType != null)
{
transformer.set OutputProperty( "doctype-system",
docType.getSys temId());
}

DOMSource source = new DOMSource(doc);
StringWriter resultWriter = new StringWriter();
StreamResult result = new StreamResult(re sultWriter);
transformer.tra nsform(source, result);
return resultWriter.ge tBuffer().toStr ing();

The Transformer stuff is from the javax.xml.trans former 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.newTra nsformer();. 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**@theaddiso ns.demon.co.uk> wrote in message news:<bu******* ************@ne ws.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...

TransformerFact ory tFactory = TransformerFact ory.newInstance ();
Transformer transformer = tFactory.newTra nsformer();

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

// if ommitting xml declaration, omit_xml_declar ation will be "yes"
// otherwise, omit_xml_declar ation will not be provided, "no" is the
default
if (omitXMLDeclara tion)
{
transformer.set OutputProperty( "omit-xml-declaration", "yes");
}

DocumentType docType = doc.getDoctype( );
if (docType != null)
{
transformer.set OutputProperty( "doctype-system",
docType.getS ystemId());
}

DOMSource source = new DOMSource(doc);
StringWriter resultWriter = new StringWriter();
StreamResult result = new StreamResult(re sultWriter);
transformer.tra nsform(source, result);
return resultWriter.ge tBuffer().toStr ing();

The Transformer stuff is from the javax.xml.trans former 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">
<ABCMessag e 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.newTr ansformer();. 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:styleshe et 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**@theaddison s.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
2250
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); xml_parse_into_struct($parser, ${$val . 'XML'}, ${$val . 'XMLArray'}, $tags); xml_parser_free($parser); $myXMLArray = ${$val . 'XMLArray'}; for ($i = 1; $i < @sizeof($myXMLArray) - 1; $i++) { if ($myXMLArray) {
8
2342
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 - However i cannot format this information in anyway. A copy of the returned information saved to my server results in the xml data being formatted and displayed as intended! Can anyone explain to me why one would work but not the other. Regards ...
1
2159
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 = server.CreateObject("ADODB.Recordset") rs.CursorType = 3
0
1550
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 leading trade association dedicated to fostering XML and other information technology standards, today announced the full program for XML Conference and Exposition 2003, being held Dec. 7-12, at the Pennsylvania Convention Center in Philadelphia,...
0
1748
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 (http://www.stylusstudio.com), the industry-leading provider of XML development tools for advanced data integration, today announced new support for IBM's alphaWorks XML Schema Quality Checker, furthering solidifying its position as the provider of the...
5
2721
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 the appointment collection to populate the calendar control. The performance getting the XML data is fine, but loading the data into the collection is slow. My question/problem is should I be using the collection, a dataset, or something else to...
0
2783
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 xmlns="http://www.store.com/xml/1.1.0.0/impex/catalog"> <product sku="10050-1653" xmlns="http://www.store.com/xml/1.1.0.0/impex/catalog"> <sku>10050-1653</sku> <name xml:lang="x-default">shop's Foie Gras</name> <online>1</online> ...
9
2476
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 recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'dom' <module 'xml.dom' from '/usr/lib/python2.5/xml/dom/__init__.pyc'>
10
15562
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 have a top level element. line #: 0 I don't know if it is my xml file or it is something else? Here is my client side program: <%@ Language=vbScript%>
0
2165
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 authoring across the enterprise. http://e.goozw.com/xml.htm Powerful XML Editing Tool - XMLSPY XMLSPY is a powerful XML tool for editing XML documents, XML schema, DTDs, XSL/XSLT stylesheets, SOAP applications, debugging Web services and more....
0
8294
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8709
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8494
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7309
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1597
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.