Main Page | Packages | Class Hierarchy | Class List | File List | Class Members

xmlexpr.DocumentFactory Class Reference

List of all members.

Detailed Description

DocumentFactory.

Author:
Ian Kaplan, iank@bearcave.com, Jul 8, 2004
Support for creating a new XML DOM Document object. Such an object is useful when building a new XML document.


Static Public Member Functions

Document newDocument (String docTag, String prefix, String nameSpace, String schemaLoc)
 Create a new XML DOM Document object.

Static Private Member Functions

Document getNewDocument (String topTag, String prefix, String nameSpace)
void addSchemaAttributes (Document doc, String prefix, String nameSpace, String schemaLoc)
 Set the attributes of the Document.


Member Function Documentation

void xmlexpr.DocumentFactory.addSchemaAttributes Document  doc,
String  prefix,
String  nameSpace,
String  schemaLoc
[static, private]
 

Set the attributes of the Document.

00064 { 00065 final String W3_SCHEMA_DEF = "http://www.w3.org/2001/XMLSchema-instance"; 00066 Element docElem = doc.getDocumentElement(); 00067 docElem.setAttribute("xmlns:xsi", W3_SCHEMA_DEF ); 00068 docElem.setAttribute("xmlns", nameSpace ); 00069 if (prefix != null) { 00070 docElem.setAttribute("xmlns:" + prefix, nameSpace ); 00071 } 00072 docElem.setAttribute("xsi:schemaLocation", nameSpace + " " + schemaLoc ); 00073 } // addSchemaAttributes

Document xmlexpr.DocumentFactory.getNewDocument String  topTag,
String  prefix,
String  nameSpace
[static, private]
 

00039 { 00040 Document newDoc = null; 00041 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); 00042 try { 00043 DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); 00044 DOMImplementation docImp = docBuilder.getDOMImplementation(); 00045 if (prefix != null) { 00046 topTag = prefix + ":" + topTag; 00047 } 00048 newDoc = docImp.createDocument( nameSpace, topTag, null ); 00049 } 00050 catch (ParserConfigurationException builderExcept) { 00051 System.out.println("ParserConfigurationException: " + builderExcept ); 00052 } 00053 return newDoc; 00054 } // getNewDocument

Document xmlexpr.DocumentFactory.newDocument String  docTag,
String  prefix,
String  nameSpace,
String  schemaLoc
[static]
 

Create a new XML DOM Document object.

Parameters:
docTag the top tag for the document.
prefix the XML tag prefix. This paramter may be null.
nameSpace the name space for the document. For example http://www.bearcave.com/expression
schemaLoc the location of the schema
00089 { 00090 Document doc = getNewDocument( docTag, prefix, nameSpace ); 00091 if (schemaLoc != null) { 00092 addSchemaAttributes( doc, prefix, nameSpace, schemaLoc ); 00093 } 00094 return doc; 00095 } // newDocument


The documentation for this class was generated from the following file:
Generated on Sat Aug 28 13:09:43 2004 for XmlExpr by doxygen 1.3.8