de.bsd.x2svg.parsers
Class XsdParser

java.lang.Object
  extended by de.bsd.x2svg.parsers.XsdParser
All Implemented Interfaces:
InputParser

public class XsdParser
extends java.lang.Object
implements InputParser

Parser for XML Schema files

Author:
hwr@pilhuhn.de

Field Summary
private  boolean alsoAttributes
           
private  boolean debug
           
private  int depth
           
private static java.lang.String FILE_SUFFIX_STRING
           
private  boolean limitSubstitutions
           
private  boolean limitTypes
           
private  org.apache.commons.logging.Log log
           
private static java.lang.String MODE_STRING
           
private  org.apache.xerces.xs.XSModel model
           
private  java.lang.String rootElementName
           
private  boolean startIsType
           
private  int treeDepth
           
private  java.io.File xsdFile
           
 
Constructor Summary
XsdParser()
           
 
Method Summary
private  java.lang.String getCompositorForModelGroup(short compositor)
           
 java.lang.String getFileSuffix()
          Return the file suffix for this parser (.xsd)
 java.lang.String getMode()
          Return the mode string for this parser (xsd)
 java.lang.String getSpecificHelp()
          Return a String that gives help for this specific parser.
private  boolean isDebug()
          Return if the debug flag got passed in and debug logging is enabled in the logging framework
private  void parseDefinition(org.apache.xerces.xs.XSTypeDefinition rootDefinition, Container root)
          Start parsing from a given Type Definition
private  void parseElement(org.apache.xerces.xs.XSElementDeclaration rootElement, Container root)
          Parses an Element recursively
 Container parseInput()
          Parse the input.
private  void parseModelGroup(org.apache.xerces.xs.XSModelGroup group, Container container)
           
private  void setContentModelForModelGroup(Container root, org.apache.xerces.xs.XSModelGroup mg)
          Set the content model for the passed container
 void setDebug()
          Tells the parer to set the debug mode.
 void setInputFile(java.io.File inputFile)
          Pass in the input file to parse
 void setParserOptions(java.lang.String[] options)
          Pass in options that are parser specific.
 void setWithAttributes(boolean value)
          Tells the parser that parsing attributes of elements is wanted.
 void setWithElementComments(boolean value)
          Tells the parser that parsing comments for elements (and possibly attributes) is desired.
private  java.lang.String termTypeToString(int type)
          Return the TermType as a String instead of a number.
private  void workOnParticlesForModelGroup(Container container, org.apache.xerces.xs.XSModelGroup modelGroup)
           
private  void workOnTypeDefinition(Container root, org.apache.xerces.xs.XSTypeDefinition tdef)
          Parse a type definition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_STRING

private static final java.lang.String MODE_STRING
See Also:
Constant Field Values

FILE_SUFFIX_STRING

private static final java.lang.String FILE_SUFFIX_STRING
See Also:
Constant Field Values

xsdFile

private java.io.File xsdFile

rootElementName

private java.lang.String rootElementName

model

private org.apache.xerces.xs.XSModel model

treeDepth

private int treeDepth

limitTypes

private boolean limitTypes

depth

private int depth

startIsType

private boolean startIsType

limitSubstitutions

private boolean limitSubstitutions

debug

private boolean debug

alsoAttributes

private boolean alsoAttributes

log

private final org.apache.commons.logging.Log log
Constructor Detail

XsdParser

public XsdParser()
Method Detail

parseInput

public Container parseInput()
                     throws java.lang.Exception
Parse the input. This can work on elements and types

Specified by:
parseInput in interface InputParser
Returns:
A Container that is the root of the parsed input.
Throws:
java.lang.Exception - if anything goes wrong.
See Also:
InputParser.parseInput()

parseDefinition

private void parseDefinition(org.apache.xerces.xs.XSTypeDefinition rootDefinition,
                             Container root)
Start parsing from a given Type Definition

Parameters:
rootDefinition - The definition to start with
root - The Container that is the root of the tree

parseElement

private void parseElement(org.apache.xerces.xs.XSElementDeclaration rootElement,
                          Container root)
Parses an Element recursively

Parameters:
rootElement - The root element with which parsing starts
root - The container on which children and attributes gets added.

workOnTypeDefinition

private void workOnTypeDefinition(Container root,
                                  org.apache.xerces.xs.XSTypeDefinition tdef)
Parse a type definition. This can be directly be used as starting point or from within parsing elements

Parameters:
root - the starting container to which attributes and children will be added.
tdef - the type definition to start with

workOnParticlesForModelGroup

private void workOnParticlesForModelGroup(Container container,
                                          org.apache.xerces.xs.XSModelGroup modelGroup)

parseModelGroup

private void parseModelGroup(org.apache.xerces.xs.XSModelGroup group,
                             Container container)

getCompositorForModelGroup

private java.lang.String getCompositorForModelGroup(short compositor)

setContentModelForModelGroup

private void setContentModelForModelGroup(Container root,
                                          org.apache.xerces.xs.XSModelGroup mg)
Set the content model for the passed container

Parameters:
root - The container
mg - The XSModelGroup of the XSModel

getFileSuffix

public java.lang.String getFileSuffix()
Return the file suffix for this parser (.xsd)

Specified by:
getFileSuffix in interface InputParser
Returns:
file suffix for this parser
See Also:
InputParser.getFileSuffix()

getMode

public java.lang.String getMode()
Return the mode string for this parser (xsd)

Specified by:
getMode in interface InputParser
Returns:
mode String for this parser (xsd)
See Also:
InputParser.getMode()

getSpecificHelp

public java.lang.String getSpecificHelp()
Description copied from interface: InputParser
Return a String that gives help for this specific parser. This string should list valid command line options.

Specified by:
getSpecificHelp in interface InputParser
Returns:
a help string or null if no help is available.

setInputFile

public void setInputFile(java.io.File inputFile)
Description copied from interface: InputParser
Pass in the input file to parse

Specified by:
setInputFile in interface InputParser
Parameters:
inputFile - a File object

setParserOptions

public void setParserOptions(java.lang.String[] options)
Description copied from interface: InputParser
Pass in options that are parser specific. The DtdParser as an example needs a root element, while the PropertiesParser doesn't

Specified by:
setParserOptions in interface InputParser
Parameters:
options - array of individual option parts as passed on the command line.

setDebug

public void setDebug()
Description copied from interface: InputParser
Tells the parer to set the debug mode. It depends on the individual parser if it actually has a debug mode.

Specified by:
setDebug in interface InputParser

isDebug

private boolean isDebug()
Return if the debug flag got passed in and debug logging is enabled in the logging framework

Returns:
true if debug is enabled by the logger and the user.

termTypeToString

private java.lang.String termTypeToString(int type)
Return the TermType as a String instead of a number. The Java language bindings for XML Schema don't use Enums *sigh*

Parameters:
type - A XSTerm type
Returns:
a string representing the term

setWithAttributes

public void setWithAttributes(boolean value)
Description copied from interface: InputParser
Tells the parser that parsing attributes of elements is wanted. It depends on the individual parser if it acutally can parse them. For example the DtdParser is able to do this, while the PropertiesParser is not.

Specified by:
setWithAttributes in interface InputParser
Parameters:
value - The value to set this to.

setWithElementComments

public void setWithElementComments(boolean value)
Description copied from interface: InputParser
Tells the parser that parsing comments for elements (and possibly attributes) is desired.
It depends on the individual parser if it actually can parse them

Specified by:
setWithElementComments in interface InputParser
Parameters:
value - The value to set this to.


x2svg version 1.2.1