uk.apl.jxc
Class XMLSchema

java.lang.Object
  extended by uk.apl.jxc.XMLSchema

public class XMLSchema
extends java.lang.Object

Provides methods for interrogating a W3C XML schema.

Author:
Andrew Leigh

Constructor Summary
XMLSchema(java.io.File file)
          Constructs a new XMLSchema.
 
Method Summary
 java.util.Set<java.lang.String> getChildPaths(java.lang.String elementName)
          Returns the child elements and attributes for a given element (i.e.
 javax.swing.tree.TreeModel getChildTree(java.lang.String elementName)
          Returns a TreeModel of all of child elements and attributes for a given element (i.e.
 java.lang.String getDocumentNSPrefix()
          Returns the XML schema documents name space prefix.
 java.util.Set<java.lang.String> getElementNames()
          Returns a set of all element names valid in the XML schema in alphabetical order.
 int getRecursion()
          Returns the number of times recursive elements will be included.
 java.util.Set<java.lang.String> getTopLevelElementNames()
          Returns a list of the top level element names in alphabetical order.
 void setDocumentNSPrefix(java.lang.String documentNSPrefix)
          Sets the XML schema documents name space prefix.
 void setRecursion(int recursion)
          Sets the number of times to include recursive elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLSchema

public XMLSchema(java.io.File file)
          throws org.xml.sax.SAXException,
                 java.io.IOException,
                 javax.xml.parsers.ParserConfigurationException,
                 javax.xml.transform.TransformerConfigurationException,
                 javax.xml.transform.TransformerException
Constructs a new XMLSchema.

Parameters:
file - an XSD file containing the XML schema
Throws:
org.xml.sax.SAXException - when an error occurs parsing the schema file
java.io.IOException - when an error occurs reading the schema file
javax.xml.parsers.ParserConfigurationException - when a parser configuration error occurs
javax.xml.transform.TransformerConfigurationException - when a transformer configuration error occurs
javax.xml.transform.TransformerException
Method Detail

setRecursion

public void setRecursion(int recursion)
Sets the number of times to include recursive elements.

Parameters:
recursion - the number of times to recurse

getRecursion

public int getRecursion()
Returns the number of times recursive elements will be included.

Returns:
number of times to recurse

getTopLevelElementNames

public java.util.Set<java.lang.String> getTopLevelElementNames()
Returns a list of the top level element names in alphabetical order.

Returns:
list of top level element names

getElementNames

public java.util.Set<java.lang.String> getElementNames()
Returns a set of all element names valid in the XML schema in alphabetical order.

Returns:
list of all valid element names

getChildPaths

public java.util.Set<java.lang.String> getChildPaths(java.lang.String elementName)
Returns the child elements and attributes for a given element (i.e. all the element and attributes that may sit below the named element according to the XML schema). The items returned will be prefixed with their path inclusive of the element argument.

Parameters:
elementName - name of the element whose children should be returned
Returns:
the elements valid child elements and attributes

getChildTree

public javax.swing.tree.TreeModel getChildTree(java.lang.String elementName)
Returns a TreeModel of all of child elements and attributes for a given element (i.e. all the element and attributes that may sit below the named element according to the XML schema).

Parameters:
elementName - name of the element whose children should be returned
Returns:
a TreeModel of the elements valid child elements and attributes

setDocumentNSPrefix

public void setDocumentNSPrefix(java.lang.String documentNSPrefix)
Sets the XML schema documents name space prefix.

Parameters:
documentNSPrefix - the schema documents name space prefix

getDocumentNSPrefix

public java.lang.String getDocumentNSPrefix()
Returns the XML schema documents name space prefix.

Returns:
the schema documents name space prefix


Copyright 2010 Andrew Leigh. All Rights Reserved.