S
Sarah Haskins
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 #REQUIREDetc...
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.
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 #REQUIREDetc...
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.