home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML in Action / Dynamicke-HTML-v-akci-covermount.bin / XML / PARSER / XMLINST.EXE / classes / com / ms / xml / om / Document.java < prev    next >
Encoding:
Java Source  |  1998-05-22  |  23.0 KB  |  819 lines

  1. /*
  2.  * @(#)Document.java 1.0 6/3/97
  3.  * 
  4.  * Copyright (c) 1997 Microsoft, Corp. All Rights Reserved.
  5.  * 
  6.  */
  7.  
  8. package com.ms.xml.om;
  9.  
  10. import com.ms.xml.parser.ElementDeclEnumeration;
  11. import com.ms.xml.parser.Parser;
  12. import com.ms.xml.parser.ParseException;
  13. import com.ms.xml.parser.DTD;
  14. import com.ms.xml.parser.ElementDecl;
  15. import com.ms.xml.parser.Entity;
  16. import com.ms.xml.util.Name;
  17. import com.ms.xml.util.Attributes;
  18. import com.ms.xml.util.XMLOutputStream;
  19. import com.ms.xml.util.Attribute;
  20. import com.ms.xml.util.EnumWrapper;
  21. import com.ms.xml.util.Atom;
  22.  
  23. import java.util.Vector;
  24. import java.lang.String;
  25. import java.util.Hashtable;
  26. import java.util.Enumeration;
  27. import java.io.*;
  28. import java.net.URL;
  29. import java.net.MalformedURLException;
  30. import java.net.URLConnection;
  31.  
  32. /**
  33.  * This class implements an XML document, which can be thought of as the root of a tree.
  34.  * Each XML tag can either represent a node or a leaf of this tree.  
  35.  * The <code>Document</code> class allows you to load an XML document, manipulate it, 
  36.  * and then save it back out again. The document can be loaded by specifying 
  37.  * a URL or an input stream. 
  38.  * <P>
  39.  * According to the XML specification, the root of the tree consists of any combination
  40.  * of comments and processing instructions, but only one root element.
  41.  * A helper method <code>getRoot</code> is provided
  42.  * as a short cut to finding the root element.
  43.  *
  44.  * @version 1.0, 6/3/97
  45.  * @see Element
  46.  */
  47. public class Document extends ElementImpl implements ElementFactory
  48. {
  49.     /**
  50.      * Constructs a new empty document using the default
  51.      * element factory.
  52.      */
  53.     public Document()
  54.     {        
  55.         outputStyle = XMLOutputStream.DEFAULT;
  56.         factory = new ElementFactoryImpl();
  57.         dtd = new DTD();
  58.         caseInsensitive = false;
  59.         loadExternal = true;
  60.     }
  61.  
  62.     /**
  63.      * Constructs a new empty document using the given
  64.      * <code>ElementFactory</code> object when building the XML element
  65.      * hierarchy.
  66.      * @param f The <code>ElementFactory</code> to use.
  67.      */
  68.     public Document(ElementFactory f)
  69.     {
  70.         outputStyle = XMLOutputStream.DEFAULT;
  71.         factory = f;
  72.         dtd = new DTD();
  73.         caseInsensitive = false;
  74.         loadExternal = true;
  75.     }
  76.  
  77.     /**
  78.      * Retrieves the document type.
  79.      * @return the value defined by <code>Element.DOCUMENT</code>.
  80.      */
  81.     public int getType()
  82.     {
  83.         return DOCUMENT;
  84.     }
  85.  
  86.     /**
  87.      * Retrieves the document text.
  88.      * @return a plain text (that is, not marked-up) representation of the entire document.
  89.      */
  90.     public String getText()
  91.     {
  92.         return (root != null) ? root.getText() : null;
  93.     }
  94.  
  95.     /**
  96.      * Passes the text through to the root node, if there is a root node. 
  97.      * @param text The text to be set.
  98.      */
  99.     public void setText(String text)
  100.     {
  101.         if (root != null) root.setText(text);
  102.     }
  103.  
  104.     /**
  105.      * Retrieves the parent element. There is no parent element for <code>Document</code>, so this method
  106.      * always returns null. 
  107.       
  108.      * @return null.      
  109.     */
  110.     public Element getParent()
  111.     {
  112.         return null;
  113.     }
  114.  
  115.     /**  
  116.      * Adds a child <code>Element</code> to the document. 
  117.      * This is an override of the <code>Element.addChild</code> method that 
  118.       * stores 
  119.      * the new child and stores the last element of type <code>Element.ELEMENT</code>, 
  120.      * so that <code>getRoot</code> can be used as a short cut to find a particular element.
  121.      * @param elem  The child element to add.
  122.      * @param after  The element after which to add the <i>elem</i> element.
  123.      */
  124.     public void addChild(Element elem, Element after)
  125.     {
  126.         if (elem.getType() == Element.ELEMENT) 
  127.         {
  128.             root = elem;
  129.         } 
  130.         else if (elem.getType() == Element.PI && 
  131.                     elem.getTagName() == nameXML) 
  132.         {
  133.             XML = elem;
  134.         } 
  135.         else if (elem.getType() == Element.DTD) 
  136.         {
  137.             DTDnode = elem;
  138.         }
  139.         
  140.         super.addChild(elem,after);
  141.     }
  142.  
  143.     /**
  144. * Removes the specified child <code>Element</code> from the Document. 
  145. * @param elem The child element to remove.
  146.      */
  147.     public void removeChild(Element elem)
  148.     {
  149.         super.removeChild(elem);
  150.  
  151.         if (root == elem) 
  152.         {
  153.             root = null;
  154.         } 
  155.         else if (XML == elem) 
  156.         {
  157.             XML = null;
  158.         } 
  159.         else if (XML == DTDnode) 
  160.         {
  161.             DTDnode = null;
  162.         }
  163.     }
  164.  
  165.     /**  
  166.      * Retrieves the root node of the XML parse tree. This is
  167.      * guaranteed to be of type <code>Element.ELEMENT</code>.
  168.      * @return the root node.
  169.      */
  170.     public final Element getRoot()
  171.     {
  172.         return root;
  173.     }
  174.  
  175.     /**
  176.      * Returns the information stored in the <?XML ...?> tag
  177.      * as an Element.  Typically this has two attributes
  178.      * named VERSION and ENCODING.
  179.      * It is a private function because users should not be able to mess around
  180.      * with the XML element.  Set/getVersion and set/getEncoding are available 
  181.      * for those purposes.
  182.      */
  183.     private final Element getXML()
  184.     {
  185.         return XML;
  186.     }
  187.  
  188.     /**
  189.      * Retrieves the version information.
  190.      * @return the version number stored in the <?XML ...?> tag. 
  191.      */
  192.     public final String getVersion()
  193.     {
  194.         if (getXML() != null) 
  195.         {
  196.             Object v = getXML().getAttribute(nameVERSION);
  197.             if (v != null)
  198.                 return v.toString();
  199.         }
  200.         return defaultVersion;
  201.     }
  202.  
  203.     /**
  204.      * Sets the version number stored in the <?XML ...?> tag.      
  205.      * @param version The version information to set.
  206.       * @return No return value.
  207.      */
  208.     public final void setVersion( String version )
  209.     {
  210.         if (XML == null)
  211.         {
  212.             XML = createElement(this, Element.PI, nameXML, null);
  213.         }
  214.         XML.setAttribute(nameVERSION, version );
  215.     }
  216.  
  217.     /**
  218.      * Retrieves the character encoding information.
  219.      * @return the encoding information  stored in the <?XML ...?> tag or the user-defined output encoding 
  220.      * if it has been more recently set.
  221.      */
  222.     public final String getEncoding()
  223.     {
  224.         if( outputEncoding != null )
  225.             return outputEncoding;
  226.         else
  227.         {
  228.             if (getXML() != null) 
  229.             {
  230.                 Object v = getXML().getAttribute(nameENCODING);
  231.                 if (v != null)
  232.                     return v.toString();
  233.             }
  234.             return defaultEncoding;
  235.         }
  236.     }
  237.  
  238.     /**
  239.      * Sets the character encoding for output. Eventually it sets the ENCODING 
  240.      * stored in the <?XML ...?> tag, but not until the document is saved.
  241.      * You should not call this method until the Document has been loaded.
  242.       * @return No return value.
  243.      */
  244.     public final void setEncoding( String encoding )
  245.     {
  246.         outputEncoding = encoding;        
  247.         if (XML == null)
  248.         {
  249.             XML = createElement(this, Element.PI, nameXML, null);
  250.             XML.setAttribute(nameENCODING, encoding);
  251.         }
  252.     }
  253.  
  254.     /**
  255.      * Retrieves the character set. This is
  256.      * an alias for the <code>setEncoding</code> method and exists for 
  257.       * compatibility
  258.      * reasons only. 
  259.      * @return  the character set. 
  260.      */
  261.     public final String getCharset()
  262.     {
  263.         return getEncoding();
  264.     }
  265.  
  266.     /**
  267.      * Sets the character set.
  268.      * This is an alias for the <code>getEncoding</code> method and exists for compatibility
  269.      * reasons only.
  270.      * @param encoding The encoding information.
  271.      * 
  272.       * @return No return value.
  273.      */
  274.     public final void setCharset(String encoding)
  275.     {
  276.         setEncoding(encoding);
  277.     }
  278.  
  279.     /**
  280.      * Retrieves the standalone information.
  281.      * @return the standalone attribute stored in the <?XML ...?> tag. 
  282.      */
  283.     public final String getStandalone()
  284.     {
  285.         if (getXML() != null) 
  286.         {
  287.             Object v = getXML().getAttribute(nameStandalone);
  288.             if (v != null)
  289.                 return v.toString();
  290.         }
  291.         return null;
  292.     }
  293.  
  294.     /**
  295.      * Sets the RMD stored in the <?XML ...?> tag.      
  296.      * @param value The attribute value ('yes' or 'no').
  297.      * @return No return value.
  298.      */
  299.     public final void setStandalone( String value )
  300.     {
  301.         if (XML == null)
  302.         {
  303.             XML = createElement(this, Element.PI, nameXML, null);
  304.         }
  305.         XML.setAttribute(nameStandalone, value );
  306.     }
  307.  
  308.     /**
  309.      * Returns the name specified in the <!DOCTYPE> tag.
  310.      */
  311.     public final Name getDocType()
  312.     {
  313.         if (DTDnode == null)
  314.             return null;
  315.         Object v = DTDnode.getAttribute(nameNAME);
  316.         if (v != null)
  317.             return (Name)v;
  318.         return null;
  319.     }
  320.  
  321.     /**
  322.      * Retrieves the document type URL.
  323.      * @return the URL specified in the <!DOCTYPE> tag or null 
  324.      * if an internal DTD was specified.
  325.      */
  326.     public final String getDTDURL()
  327.     {
  328.         if (DTDnode == null) 
  329.             return null;
  330.         Object v = DTDnode.getAttribute(nameURL);
  331.         if (v != null)
  332.             return v.toString();
  333.         return null;
  334.     }
  335.  
  336.     /**
  337.      * Retrieves the URL.
  338.      * @return the last URL sent to the load() method  or null 
  339.      * if an input stream was used.
  340.      */
  341.     public final String getURL()
  342.     {
  343.         return URLdoc.toString();
  344.     }
  345.  
  346.  
  347.     /**
  348.      * Retrieves the last modified date on the source of the URL.
  349.      * @return the modified date.
  350.      */
  351.     public long getFileModifiedDate()
  352.     {
  353.         if (URLdoc != null)
  354.         {
  355.             if (URLdoc.getProtocol().equals("file"))
  356.             {
  357.                 File f = new File(URLdoc.getFile());
  358.                 return f.lastModified();
  359.             }
  360.             else
  361.             {
  362.                 try
  363.                 {
  364.                     URLConnection URLcon = URLdoc.openConnection();
  365.                     URLcon.connect();
  366.                     return URLcon.getLastModified();
  367.                 }
  368.                 catch(IOException ie)
  369.                 {
  370.                     return 0;
  371.                 }
  372.             }
  373.         }
  374.         else
  375.         {
  376.             return 0;
  377.         }
  378.     }
  379.  
  380.     /**
  381.      * Retrieves the external identifier. 
  382.      * @return the external identifier specified in the <!DOCTYPE> tag 
  383.      * or null if no <!DOCTYPE> tag was specified. 
  384.      */
  385.     public final String getId()
  386.     {
  387.         if (DTDnode == null)
  388.             return null;
  389.         Object v = DTDnode.getAttribute(namePUBLICID);
  390.         if (v != null)
  391.             return v.toString();
  392.         return null;
  393.     }
  394.  
  395.     /**
  396.      * Creates a new element for the given element type and tag name using
  397.      * the <code>ElementFactory</code> for this <code>Document</code>. 
  398.      * This method allows the <code>Document</code> class to be used as an 
  399.      * <code>ElementFactory</code> itself.
  400.      * @param type The element type.
  401.      * @param tag The element tag.
  402.      */    
  403.     public final Element createElement(Element parent, int type, Name tag, String text)
  404.     {
  405.         return factory.createElement(parent,type,tag,text);
  406.     }
  407.  
  408.     /**
  409.      * Creates a new element for the given element type and tag name.
  410.      * tag is case sensitive.
  411.      * @param type The element type.
  412.      * @param tag The element tag name.
  413.      */
  414.     public final Element createElement(int type, String tag)
  415.     {
  416.         return factory.createElement(null,type, Name.create(tag),null);
  417.     }
  418.  
  419.     /**
  420.      * Creates a new element for a given element type with
  421.      * a null tag name. 
  422.      * @param type The element type.
  423.      * @return the element created.
  424.      * 
  425.      */
  426.     public final Element createElement(int type)
  427.     {
  428.         return factory.createElement(null,type,null,null);
  429.     }
  430.  
  431.     /**
  432.      * Called when the given element is completely parsed.
  433.      * @param e The Element that has been parsed.
  434.       * @return No return value.
  435.      */
  436.     public void parsed(Element e)
  437.     {
  438.         factory.parsed(e);
  439.     }
  440.  
  441.     /**
  442.      * delegate to contained element factory 
  443.      */
  444.     public void parsedAttribute(Element e, Name name, Object value)
  445.     {
  446.         factory.parsedAttribute(e,name,value);
  447.     }
  448.  
  449.     /** 
  450.      * Switch to determine whether next XML loaded will be treated
  451.      * as case sensitive or not.  If not, names are folded to uppercase.
  452.      */
  453.     public void setCaseInsensitive(boolean yes)
  454.     {
  455.         caseInsensitive = yes;
  456.     }
  457.  
  458.     /**
  459.      * Return whether we're case insensitive.
  460.      */
  461.     public boolean isCaseInsensitive()
  462.     {
  463.         return caseInsensitive;
  464.     }
  465.  
  466.     /** 
  467.      * Switch to determine whether to load external DTD's
  468.      * or entities.
  469.      */
  470.     public void setLoadExternal(boolean yes)
  471.     {
  472.         loadExternal = yes;
  473.     }
  474.  
  475.     /**
  476.      * Return whether to load external DTD's or entities.
  477.      */
  478.     public boolean loadExternal()
  479.     {
  480.         return loadExternal;
  481.     }
  482.  
  483.     /**
  484.      * Loads the document from the given URL string.
  485.      * @param urlstr The URL specifying the address of the document.
  486.      * @exception ParseException if the file contains errors.
  487.       * @return No return value.
  488.      */
  489.     public void load(String urlstr) throws ParseException
  490.     {
  491.         URL url;
  492.         try {
  493.             url = new URL( urlstr );
  494.         } catch( MalformedURLException e ) {
  495.             throw new ParseException("MalformedURLException: " + e);
  496.         }        
  497.         load(url);
  498.     }
  499.    
  500.     /**
  501.      * An alias for load and is here for compatibility
  502.      * reasons only. 
  503.      * @param urlstr The URL string.
  504.       * 
  505.       * @return No return value.
  506.       * @exception ParseException if an error occurs while parsing the URL string.
  507.       * 
  508.      */
  509.     public void setURL( String urlstr ) throws ParseException
  510.     {
  511.         load( urlstr);
  512.     }
  513.  
  514.     /**
  515.      * Loads the document from the given URL.
  516.       * 
  517.      * @param url The URL string.
  518.      * @return No return value.
  519.      * @exception ParseException if a syntax error is found.
  520.      */
  521.     public void load(URL url) throws ParseException
  522.     {
  523.         clear();
  524.         URLdoc = url;
  525.         parser = new Parser();
  526.         parser.parse(url,this,dtd,this,caseInsensitive,loadExternal);
  527.     }
  528.  
  529.     /**
  530.      * Loads the document using the given input stream.
  531.      * This is useful if you have the XML data already in memory.
  532.      * @param in The input stream.
  533.      * 
  534.      * @return No return value.
  535.      * @exception ParseException when a syntax error is found.
  536.      */
  537.     public void load(InputStream in) throws ParseException
  538.     {
  539.         clear();
  540.         parser = new Parser();
  541.         parser.parse(in,this,dtd,this,caseInsensitive,loadExternal);
  542.     }
  543.  
  544.     /**
  545.      * Returns information about the given parse exception that
  546.      * was generated during the load.
  547.      *  
  548.      * @param e The exception to report on. 
  549.      * @param out The output stream to report to. 
  550.      * @return No return value.
  551.      */
  552.     public void reportError(ParseException e, OutputStream out)
  553.     {
  554.         if (parser != null)
  555.             parser.report(e,out);
  556.     }
  557.  
  558.     /**
  559.      * Sets the style for writing to an output stream.
  560.      * Use XMLOutputStream.PRETTY or .COMPACT.
  561.      * 
  562.      * @param int The style to set.
  563.      * @return No return value.
  564.      * @see XMLOutputStream
  565.      */
  566.     public void setOutputStyle(int style)
  567.     {
  568.         outputStyle = style;
  569.     }
  570.  
  571.     /**
  572.      * Retrieves the current output style.  
  573.      * @return the output style. The default style is XMLOutputStream.PRETTY.
  574.      */
  575.     public int getOutputStyle()
  576.     {
  577.         return outputStyle;
  578.     }
  579.  
  580.     /**
  581.      * Creates an XML output stream matching the format found on <code>load()</code>.
  582.      * @param out The output stream. 
  583.       * 
  584.      * @exception IOException if the output stream cannot be created.
  585.      * @return the XML output stream.
  586.      */
  587.     public XMLOutputStream createOutputStream(OutputStream out) throws IOException
  588.     {
  589.         XMLOutputStream o = null;
  590.  
  591.         if( outputEncoding == null )
  592.         {
  593.             // Create an output stream that will save in same format as
  594.             // was found in input stream.
  595.  
  596.             if (parser != null)
  597.                 o = parser.createOutputStream( out );
  598.         }
  599.         if (o == null)
  600.         {
  601.             // Create an output stream that is appropriate for
  602.             // encoding specified in the setEncoding method.
  603.             o = new XMLOutputStream( out );
  604.             String encoding = getEncoding();
  605.             if (encoding != null)
  606.             {
  607.                 o.setEncoding( encoding, true, true );
  608.             }
  609.         }
  610.         
  611.         o.setOutputStyle(outputStyle);
  612.         o.dtd = getDTD();
  613.         return o;
  614.     }
  615.  
  616.     /**
  617.      * Saves the document to the given output stream.
  618.      * @param o  The output stream.
  619.       * @return No return value.
  620.      * @exception IOException if there is a problem saving the output.
  621.      */
  622.     public void save(XMLOutputStream o) throws IOException 
  623.     {
  624.         o.dtd = dtd; // make sure dtd is set correctly.
  625.  
  626.         for (ElementEnumeration ee = new ElementEnumeration(this); ee.hasMoreElements(); )
  627.         {
  628.             Element e = (Element)ee.nextElement();
  629.             if (e == DTDnode) 
  630.             {
  631.                 // Make sure we write the DOCTYPE in correct syntax and in
  632.                 // the correct location - relative to surrounding COMMENT
  633.                 // and PI elements.
  634.                 o.writeChars("<!DOCTYPE ");
  635.                 Name docType = getDocType();
  636.                 if (docType.getNameSpace() != null)
  637.                     o.writeQualifiedName(getDocType(),Atom.create(""));
  638.                 else
  639.                     o.writeChars(docType.getName());
  640.  
  641.                 if (getDTDURL() != null) 
  642.                 {
  643.                     if (getId() != null) 
  644.                     {
  645.                         o.writeChars(" PUBLIC ");
  646.                         o.writeQuotedString(getId());
  647.                         o.write(' ');
  648.                     } 
  649.                     else 
  650.                     {
  651.                         o.writeChars(" SYSTEM ");
  652.                     }
  653.                     o.writeQuotedString(getDTDURL());
  654.                 } 
  655.  
  656.                 // If we have children then there was an internal
  657.                 // subset that also needs to be written out.
  658.                 if (e.numElements() > 0) 
  659.                 {
  660.                     o.writeChars(" [");
  661.                     o.writeNewLine();
  662.                     o.addIndent(1);
  663.                     o.savingDTD = true;
  664.                     for (ElementEnumeration en = new ElementEnumeration(e); 
  665.                         en.hasMoreElements();)
  666.                     {
  667.                         Element child = (Element)en.nextElement();
  668.                         child.save(o);
  669.                     }
  670.                     o.savingDTD = false;
  671.                     o.addIndent(-1);
  672.                     o.write(']');
  673.                 }
  674.                 o.write('>');
  675.                 o.writeNewLine();
  676.             } 
  677.             else if (e == XML) 
  678.             {
  679.                 o.writeChars("<?xml version=\"1.0\""); // version is fixed.
  680.                 // The following attributes must be stored in the following
  681.                 // order, otherwise the parser complains:
  682.                 // ENCODING, RMD
  683.                 Name names[] = new Name[2];
  684.                 names[0] = nameENCODING;
  685.                 names[1] = nameStandalone;
  686.                 for (int i = 0; i < names.length; i++)
  687.                 {
  688.                     Name n = names[i];
  689.                     Object a = e.getAttribute(n);
  690.                     if (a != null)
  691.                     {
  692.                         o.writeChars(" " + n + "=");
  693.                         o.writeQuotedString(a.toString());
  694.                     }
  695.                 }
  696.                 o.writeChars("?>");
  697.                 o.writeNewLine();
  698.             }
  699.             else
  700.             {
  701.                 e.save(o);
  702.             }
  703.         }
  704.     }
  705.  
  706.     /**
  707.      * Retrieves an enumeration of the element declarations
  708.      * from the DTD. These are returned as <code>ElementDecl</code> objects.
  709.      * @return the element declarations enumeration object. 
  710.      
  711.      */
  712.     public final Enumeration elementDeclarations()
  713.     {
  714.         return (Enumeration)(new ElementDeclEnumeration(dtd.elementDeclarations()));
  715.     }
  716.  
  717.     /**
  718.      * Returns the XML-DATA specification for the named element.
  719.      * This is DTD information represented in an XML Object Model.
  720.      * See <a href="http://www.microsoft.com/standards/xml/xmldata.htm">Specification for XML-Data</a> for details.
  721.      */
  722.     public Element getElementDecl( Name name )
  723.     {
  724.         ElementDecl ed = dtd.findElementDecl(name);
  725.         if (ed == null) return null;
  726.         return ed.toSchema();
  727.     }
  728.  
  729.     /**
  730.      * Returns the XML-DATA specification for the named entity.
  731.      * This is DTD information represented in an XML Object Model.
  732.      * See <a href="http://www.microsoft.com/standards/xml/xmldata.htm">Specification for XML-Data</a> for details.
  733.      */
  734.     public Element findEntity( Name name )
  735.     {
  736.         Entity ent = dtd.findEntity(name);
  737.         if (ent == null) return null;
  738.         return ent.toSchema();
  739.     }
  740.  
  741.     /**
  742.      * Sets the Document back to its initial empty state retaining 
  743.      * only the <code>ElementFactory</code> association.
  744.       * @return No return value.
  745.      */
  746.     public void clear()
  747.     {
  748.         DTDnode = null;
  749.         dtd = new DTD(); // use DTD clear when reusing a DTD
  750.         root = null;
  751.         XML = null;
  752.         URLdoc = null;
  753.         outputEncoding = null;
  754.         super.clear();
  755.     }
  756.  
  757.     /**
  758.      * Retrieves the document's DTD. 
  759.      * @return the DTD.
  760.      */
  761.  
  762.     public DTD getDTD()
  763.     {
  764.         return dtd;
  765.     }
  766.  
  767.     /** 
  768.      * URL if passed in.
  769.      */
  770.     URL URLdoc;
  771.  
  772.     /**
  773.      * Root of External DTD tree.
  774.      */
  775.     Element DTDnode;
  776.  
  777.     /**
  778.      * Root of element tree.
  779.      */
  780.     Element root;
  781.  
  782.     /**
  783.      * XML declaration
  784.      */
  785.     Element XML;
  786.     
  787.     /**
  788.      * The Document Type Definition (DTD). 
  789.      */    
  790.     protected DTD dtd;
  791.  
  792.     /**
  793.      * character encoding of output.
  794.      */
  795.     String outputEncoding;
  796.  
  797.     /**
  798.      * The factory used to create the elements in the document.
  799.      */
  800.     protected ElementFactory factory;
  801.  
  802.     Parser parser;
  803.     int outputStyle;
  804.     boolean caseInsensitive;
  805.     boolean loadExternal;
  806.  
  807.     static Name nameVERSION = Name.create("version");
  808.     static Name nameENCODING = Name.create("encoding");
  809.     static Name nameStandalone = Name.create("standalone");
  810.     static Name nameDOCTYPE = Name.create("DOCTYPE");
  811.     static Name nameNAME = Name.create("NAME");
  812.     static Name nameURL = Name.create("URL");
  813.     static Name namePUBLICID = Name.create("PUBLICID");
  814.     static Name nameXML = Name.create("xml");
  815.     static String defaultEncoding = "UTF-8";
  816.     static String defaultVersion = "1.0";
  817. }
  818.  
  819.