Subjects
Home
VOTE Move XML Commons to Xerces
Commented: (XERCESJ 589) Bug with pattern restriction on long strings
: Xerces J 2 8 1 Release on Wednesday, September 13th
: Xerces J 2 9 0 Release on Wednesday, November 22nd
Commented: (XERCESJ 1066) Restriction+choice+substitutionGroup error
Commented: (XERCESJ 1178) Error getting prefix for an attribute with no n
Updated: (XERCESJ 1244) XMLSchemaValidator does not contribute element 's
Some consideration about the xerces DOM implementation
Updated: (XERCESJ 1066) Restriction+choice+substitutionGroup error
Commented: (XERCESJ 1227) Poor performance / OutOfMemoryError for sequenc
retain exception stack traces
Updated: (XERCESJ 1193) NPE or hang when parsing using the "continue afte
Future of NekoHTML
Commented: (XERCESJ 1203) NPE in XMLDTDProcessor
DOM Level 3 APIs for Xalan J and a new Xalan release (2 7 1)
: xml commons external 1 3 04 Release on Wednesday, November 22nd
Commented: (XERCESJ 1247) Incorrect location information on SAX when usin
XInclude exceptions how to mirror Xerces J functionality into Xerces C++?
First proposal on SoC project "Add support for the StAX (JSR 173) cursor API
: xml commons resolver 1 2 Release on Wednesday, November 22nd
Typo in RangeToken java Please check
Validator features
java lang ClassCastException when adopting Node
using the org apache xerces impl xs identity package
Updated: (XERCESJ 1257) buffer overflow in UTF8Reader for characters out
Problem with ref attributes and schema validation
Updated: (XERCESJ 122) XMLSchemaValidator does not contribute element 's d
Performance problem under load Xerces with Weblogic 9 x
remove ignored memory allocation
Commented: (XERCESJ 1177) SAXXMLStreamReader doesn 't always report namesp
Commented: (XERCESJ 977) Null pointer exception during DOM parsing
Commented: (XERCESJ 1197) Code cleanup for org apache xml serialize
Commented: (XERCESJ 1201) Initial contribution for StAX Event API
Updated: (XERCESJ 1061) Regex "$ " and "^ " characters treated as special c
Commented: (XERCESJ 1199) SAXXMLStreamReader should attempt to register a
Commented: (XERCESJ 1061) Regex "$ " and "^ " characters treated as special
Updated: (XERCESJ 589) Bug with pattern restriction on long strings
StackOverflow
xerces Range unnecessarily not garbage collectable if not detached
Updated: (XERCESJ 1178) Error getting prefix for an attribute with no nam
Bug in xs:redefine
Commented: (XERCESJ 1204) Can not set XMLEntityResolver for LSParser
Updated: (XERCESJ 1253) Prototype for SoC2007 project "Add support for th
Updated: (XERCESJ 1259) Add SteamFilter Function to SoC2007 project "Add
Assigned: (XERCESJ 444) SAXException thrown by EntityResolver is reported
Google Summer of Code 2007
Xerces J and XInclude relative path issue
Assigned: (XERCESJ 206) Stack overflow when using a schema validation
Commented: (XERCESJ 1215) Restrictions involving two levels of substituti
Closed: (XERCESJ 1203) NPE in XMLDTDProcessor
non overriding equals methoda
Resolved: (XERCESJ 1079) invalid value returned for TOTALDIGITS facet in
Xerces AS3 port
Updated: (XERCESJ 325) Regular Expression; Pattern "| " clause order de
Updated: (XERCESJ 1196) Javadoc generation fails on Java SE 5 0
Closed: (XERCESJ 1202) DTD validation on XIncluded documents when the sch
Created: (XERCESJ 1124) Nonspecific schema error message
a bug in xerces
Updated: (XERCESJ 1201) Initial contribution for StAX Event API
Closed: (XERCESJ 1254) Empty uris in targetNamespace attribute not report
Links
Home
Oracle database error code
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Building DOM with DOCTYPE

Building DOM with DOCTYPE

2003-01-10       - By Greg Hess

Hi All,

I am new to this list and using Xerces. I am having trouble building a
DOM with a DOCTYPE declaration. No errors occur when I build the DOM but
when I serialize the DOM to file the DOCTYPE declaration is excluded
from the output. My code is as follows:

DOMImplementation domImpl = docBuilder.getDOMImplementation();
           DocumentType docType =
domImpl.createDocumentType(INVOCATION, null,
"http://localhost/webapplication/dtd/some.dtd");
                                                                       
           Document doc = domImpl.createDocument("", INVOCATION,
docType);
                                   
           Properties OP =
OutputProperties.getDefaultMethodProperties("xml");
           OP.setProperty(OutputKeys.METHOD,"xml");
           OP.setProperty(OutputKeys.INDENT,"yes");
            Serializer serializer = SerializerFactory.getSerializer
(OP);
            serializer.setOutputStream(os);
            serializer.asDOMSerializer().serialize(doc);

The result is as follows:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
 <invocation />


Any help would be greatly appreciated,

Greg


<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas
-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">


<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="cid:filelist.xml@(protected)">
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
 <o:DoNotRelyOnCSS/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
 <w:SpellingState>Clean</w:SpellingState>
 <w:GrammarState>Clean</w:GrammarState>
 <w:DocumentKind>DocumentEmail</w:DocumentKind>
 <w:EnvelopeVis/>
 <w:Compatibility>
  <w:BreakWrappedTables/>
  <w:SnapToGridInCell/>
  <w:WrapTextWithPunct/>
  <w:UseAsianBreakRules/>
 </w:Compatibility>
 <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@(protected)
  {font-family:Verdana;
  panose-1:2 11 6 4 3 5 4 4 2 4;
  mso-font-charset:0;
  mso-generic-font-family:swiss;
  mso-font-pitch:variable;
  mso-font-signature:536871559 0 0 0 415 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
  {mso-style-parent:"";
  margin:0in;
  margin-bottom:.0001pt;
  mso-pagination:widow-orphan;
  font-size:12.0pt;
  font-family:"Times New Roman";
  mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
  {color:blue;
  text-decoration:underline;
  text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
  {color:purple;
  text-decoration:underline;
  text-underline:single;}
span.EmailStyle17
  {mso-style-type:personal-compose;
  mso-style-noshow:yes;
  mso-ansi-font-size:10.0pt;
  mso-bidi-font-size:10.0pt;
  font-family:Arial;
  mso-ascii-font-family:Arial;
  mso-hansi-font-family:Arial;
  mso-bidi-font-family:Arial;
  color:windowtext;}
span.m1
  {mso-style-name:m1;
  color:blue;}
span.pi1
  {mso-style-name:pi1;
  color:blue;}
span.b1
  {mso-style-name:b1;
  font-family:"Courier New";
  mso-ascii-font-family:"Courier New";
  mso-hansi-font-family:"Courier New";
  mso-bidi-font-family:"Courier New";
  color:red;
  mso-text-animation:none;
  font-weight:bold;
  text-decoration:none;
  text-underline:none;
  text-decoration:none;
  text-line-through:none;}
span.t1
  {mso-style-name:t1;
  color:#990000;}
span.SpellE
  {mso-style-name:"";
  mso-spl-e:yes;}
span.GramE
  {mso-style-name:"";
  mso-gram-e:yes;}
@(protected) Section1
  {size:8.5in 11.0in;
  margin:1.0in 1.25in 1.0in 1.25in;
  mso-header-margin:.5in;
  mso-footer-margin:.5in;
  mso-paper-source:0;}
div.Section1
  {page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
  {mso-style-name:"Table Normal";
  mso-tstyle-rowband-size:0;
  mso-tstyle-colband-size:0;
  mso-style-noshow:yes;
  mso-style-parent:"";
  mso-padding-alt:0in 5.4pt 0in 5.4pt;
  mso-para-margin:0in;
  mso-para-margin-bottom:.0001pt;
  mso-pagination:widow-orphan;
  font-size:10.0pt;
  font-family:"Times New Roman";}
</style>
<![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>

<div class=Section1>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Hi All, <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I am new to this list and using <span class=SpellE>Xerces<
/span>.
I am having trouble building a DOM with a DOCTYPE declaration. No errors occur
when I build the DOM but when I serialize the DOM to file the DOCTYPE
declaration
is excluded from the output. My code is as follows:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-indent:.5in'><span class=SpellE><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>DOMImplementation<
/span></font></span><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> <span
class=SpellE>domImpl</span> = <span class=SpellE><span class=GramE>docBuilder
.getDOMImplementation</span></span><span
class=GramE>(</span>);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
class=SpellE>DocumentType</span> <span class=SpellE>docType</span> = <span
class=SpellE><span class=GramE>domImpl.createDocumentType</span></span><span
class=GramE>(</span>INVOCATION, null, &quot;http://localhost/webapplication/dtd
/some.dtd&quot;);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><span style='mso-tab-count:6'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; </span><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Document
doc = <span class=SpellE><span class=GramE>domImpl.createDocument</span></span>
<span
class=GramE>(</span>&quot;&quot;, INVOCATION, <span class=SpellE>docType</span>
);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; </span><o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Properties
OP <span class=GramE>=<span style='mso-spacerun:yes'>&nbsp; </span><span
class=SpellE>OutputProperties.getDefaultMethodProperties</span></span>(&quot
;xml&quot;);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><span
style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp; </span><span class=SpellE><span
class=GramE>OP.setProperty</span></span><span class=GramE>(</span><span
class=SpellE>OutputKeys.METHOD,&quot;xml</span>&quot;);<o:p></o:p></span></font
></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><span
style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp; </span><span class=SpellE><span
class=GramE>OP.setProperty</span></span><span class=GramE>(</span><span
class=SpellE>OutputKeys.INDENT,&quot;yes</span>&quot;);<o:p></o:p></span></font
></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><span
style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='mso-spacerun:yes'>&nbsp;</span><span class=SpellE>Serializer</span> <span
class=SpellE>serializer</span> = <span class=SpellE>SerializerFactory
.getSerializer</span>
(OP);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><span
style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='mso-spacerun:yes'>&nbsp;</span><span class=SpellE><span class=GramE
>serializer.setOutputStream</span></span><span
class=GramE>(</span><span class=SpellE>os</span>);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><span
style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='mso-spacerun:yes'>&nbsp;</span><span class=SpellE><span class=GramE
>serializer.asDOMSerializer</span></span><span
class=GramE>(</span>).serialize(doc);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>The result is as follows:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><span class=GramE><span class=m1><font size=2 color=blue
face=Verdana><span style='font-size:10.0pt;font-family:Verdana'>&lt;?</span><
/font></span><span
class=pi1><font size=2 color=blue face=Verdana><span style='font-size:10.0pt;
font-family:Verdana'>xml</span></font></span></span><span class=pi1><font
size=2 color=blue face=Verdana><span style='font-size:10.0pt;font-family
:Verdana'>
version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; <
/span></font></span><span
class=m1><font size=2 color=blue face=Verdana><span style='font-size:10.0pt;
font-family:Verdana'>?&gt;</span></font></span><font size=2 face=Verdana><span
style='font-size:10.0pt;font-family:Verdana'> <o:p></o:p></span></font></p>

<p class=MsoNormal><span class=b1><b><font size=2 color=red face="Courier New">
<span
style='font-size:10.0pt'>&nbsp;</span></font></b></span><font size=2
face=Verdana><span style='font-size:10.0pt;font-family:Verdana'> <span
class=m1><font color=blue>&lt;</font></span><span class=t1><font color="#990000
">invocation</font></span>
<span class=m1><font color=blue>/&gt;<o:p></o:p></font></span></span></font></p>

<p class=MsoNormal><span class=m1><font size=2 color=blue face=Verdana><span
style='font-size:10.0pt;font-family:Verdana'><o:p>&nbsp;</o:p></span></font><
/span></p>

<p class=MsoNormal><span class=m1><font size=2 color=blue face=Verdana><span
style='font-size:10.0pt;font-family:Verdana'><o:p>&nbsp;</o:p></span></font><
/span></p>

<p class=MsoNormal><span class=m1><font size=2 color=blue face=Verdana><span
style='font-size:10.0pt;font-family:Verdana'>Any help would be greatly
appreciated,<o:p></o:p></span></font></span></p>

<p class=MsoNormal><span class=m1><font size=2 color=blue face=Verdana><span
style='font-size:10.0pt;font-family:Verdana'><o:p>&nbsp;</o:p></span></font><
/span></p>

<p class=MsoNormal><span class=m1><font size=2 color=blue face=Verdana><span
style='font-size:10.0pt;font-family:Verdana'>Greg</span></font></span><font
size=2 face=Verdana><span style='font-size:10.0pt;font-family:Verdana'><o:p></o
:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>