com.pnp.xfeature.documenttree
Class SchemaParser

java.lang.Object
  extended by com.pnp.xfeature.documenttree.SchemaParser
All Implemented Interfaces:
org.apache.xerces.dom3.DOMErrorHandler

public class SchemaParser
extends java.lang.Object
implements org.apache.xerces.dom3.DOMErrorHandler

This class represents an XML schema. The schema is loaded through the constructor. The method getElements returns elements which can be added.

Author:
Valerio B?rker

Constructor Summary
SchemaParser(java.lang.String filename)
          Loads an XML schema into memory.
 
Method Summary
 java.util.List getAttributes(java.lang.String element, java.lang.String parentElement)
          Returns a List of Strings containing the attributes for an element.
 boolean getAttributesThroughTree(org.apache.xerces.xs.XSParticle particle, java.lang.String name, java.util.Vector attributes)
          Traverses the tree recursively to find the element with the desired name.
 java.util.List getElements(java.lang.String parentElement, java.util.List children)
          Returns a Vector of Strings containing the elements that can be added to the XML tree.
 void getParticles(org.apache.xerces.xs.XSParticle particle, Node parent)
          Traverses the tree recursively and creates a tree of Nodes in order to handle the tree easier.
 java.lang.String getTargetNamespace()
          Not implemented yet
 boolean handleError(org.apache.xerces.dom3.DOMError error)
          Standard error handler.
 void loadModel(java.lang.String filename)
          Loads an XML schema into memory.
 java.util.Vector loop(int n, int nmax, int[] counter, java.util.Vector[] temp, java.util.Vector result)
          Used to nest loops.
 java.util.Vector traverseTree(Node node)
          Used to traverse the tree for a calculation.
 boolean validate(java.lang.String parentElement, java.util.List children)
          Checks a subtree with a parent element and its children.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaParser

public SchemaParser(java.lang.String filename)
Loads an XML schema into memory.

Parameters:
filename - absolute path of XML schema.
Method Detail

loadModel

public void loadModel(java.lang.String filename)
Loads an XML schema into memory.

Parameters:
filename - absolute path of the XML schema.

getTargetNamespace

public java.lang.String getTargetNamespace()
Not implemented yet

Returns:

getElements

public java.util.List getElements(java.lang.String parentElement,
                                  java.util.List children)
Returns a Vector of Strings containing the elements that can be added to the XML tree.

Parameters:
parentElement - element a child is added to
children - List of Strings containing the children elements which are already there
Returns:
List of Strings containing the possible elements to be added

validate

public boolean validate(java.lang.String parentElement,
                        java.util.List children)
Checks a subtree with a parent element and its children. The subtree does not have to be complete. This means as long as the existing children conform to the schema, the method returns true.

Parameters:
parentElement - parent Element of the subtree
children - List of Strings containing the children elements which are already there
Returns:
boolean value indicating whether the subtree is ok

getParticles

public void getParticles(org.apache.xerces.xs.XSParticle particle,
                         Node parent)
Traverses the tree recursively and creates a tree of Nodes in order to handle the tree easier.

Parameters:
particle - parent particle
parent - parent node

traverseTree

public java.util.Vector traverseTree(Node node)
Used to traverse the tree for a calculation. If the parameter value is set to 1, the branch is selected, otherwise not.

Parameters:
node - parent node
value - can be 1, if branch is selected, otherwise 0
Returns:
boolean is set to true, if a single calculation is complete and the values can be stored to the EntryTable

loop

public java.util.Vector loop(int n,
                             int nmax,
                             int[] counter,
                             java.util.Vector[] temp,
                             java.util.Vector result)
Used to nest loops.

Parameters:
n - current nesting depth
nmax - nesting depth
counter - array of int, which contains the loop counter for every loop
temp - Vector containing all combinations from every child node
result - Vector, where the newly created table will be written in
Returns:
Vector containing the newly created table

getAttributes

public java.util.List getAttributes(java.lang.String element,
                                    java.lang.String parentElement)
Returns a List of Strings containing the attributes for an element.

Parameters:
element - name of element
parentElement - name of parent element
Returns:
List of Strings containing the attributes

getAttributesThroughTree

public boolean getAttributesThroughTree(org.apache.xerces.xs.XSParticle particle,
                                        java.lang.String name,
                                        java.util.Vector attributes)
Traverses the tree recursively to find the element with the desired name.

Parameters:
particle - parent particle
name - name of the element
attributes - Vector of Attributes to be added
Returns:
boolean value indicating if bottom has been reached

handleError

public boolean handleError(org.apache.xerces.dom3.DOMError error)
Standard error handler.

Specified by:
handleError in interface org.apache.xerces.dom3.DOMErrorHandler


Copyright © 2004 - 2008 ETH Zurich and P&P Software GmbH, All Rights Reserved.