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[color=blue]
>[/color]
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.
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[color=blue]
>[/color]
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.
Comment