org.xqdoc.conversion
Class XQDocXML

java.lang.Object
  extended by org.xqdoc.conversion.XQDocXML

public class XQDocXML
extends java.lang.Object

This class has the responsibility for generating xqDoc XML. It contains member variables that hold the main sections of the xqDoc XML. Then, when the xqDoc XML is requested, it combines all of the sections into the final xqDoc XML output. Since a namespace can be specified when this object is created, it should be easy to support different versions of xqDoc XML without necessarily adjusting the xqDoc conversion programs.

Version:
1.0
Author:
Darin McBeath

Constructor Summary
XQDocXML(java.lang.String xqDocNamespace)
          Constructor.
 
Method Summary
static java.lang.String buildBeginTag(java.lang.String name)
          Helper method to build a begin XML tag name for the specified name.
static java.lang.String buildBeginTagWithNamespace(java.lang.String name, java.lang.String namespace)
          Helper method to build a begin XML tag name for the specified name and namespace.
 void buildControlSection(java.lang.String version)
          Build the control section for xqDoc XML.
static java.lang.String buildEndTag(java.lang.String name)
          Helper method to build an end XML tag name for the specified name.
 void buildFunctionSection(java.lang.String functionName, java.lang.String functionSignature, XQDocComment comment, java.lang.String functionBody, java.util.HashSet invokedFunctions, java.util.HashSet referencedVariables)
          Construct the snippet of serialized xqDoc XML for the function.
 void buildImportSection(java.lang.String uri, XQDocComment comment)
          Append information to the import section of the returned xqDoc XML.
 void buildLibraryModuleSection(java.lang.String uri, java.lang.String commonName, XQDocComment comment, java.lang.String moduleBody)
          Build the library module section for the xqDoc XML (for library modules).
 void buildMainModuleSection(java.lang.String uri, java.lang.String commonName, XQDocComment comment, java.lang.String moduleBody)
          Build the main module section of the returned xqDoc XML (for main modules).
 void buildVariableSection(java.lang.String uri, XQDocComment comment)
          Append information to the variable section of the returned xqDoc XML.
static java.lang.String encodeXML(java.lang.String input)
          Encode the string.
 java.lang.String getXML()
          Construct the xqDoc XML and return the XML as a serialized string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XQDocXML

public XQDocXML(java.lang.String xqDocNamespace)
Constructor.

Parameters:
xqDocNamespace - Namespace of xqDoc XML to create
Method Detail

buildControlSection

public void buildControlSection(java.lang.String version)
Build the control section for xqDoc XML. This will consist of the date when the xqDoc conversion package generated the XML as well as the version of the xqDoc conversion package used to generate the XML. This method will be invoked once for each module processed.

Parameters:
version - The xqDoc conversion program version

buildLibraryModuleSection

public void buildLibraryModuleSection(java.lang.String uri,
                                      java.lang.String commonName,
                                      XQDocComment comment,
                                      java.lang.String moduleBody)
Build the library module section for the xqDoc XML (for library modules). This will consist of the library module uri, friendly name, xqDoc comment block, and the source code for the entire library module. Either this method (or the one for main modules) will be invoked once for each module processed.

Parameters:
uri - The library module uri.
commonName - The 'user-friendly' name for the library module
comment - The XQDocComment block
moduleBody - The source code for the library module

buildMainModuleSection

public void buildMainModuleSection(java.lang.String uri,
                                   java.lang.String commonName,
                                   XQDocComment comment,
                                   java.lang.String moduleBody)
Build the main module section of the returned xqDoc XML (for main modules). This will consist of the main module uri, friendly name, xqDoc comment block, and the source code for the entire main module. Either this method (or the one for library modules) will be invoked once for each module processed.

Parameters:
uri - The main module uri.
commonName - The 'user-friendly' name for the main module
comment - The XQDocComment block
moduleBody - The source code for the main module

buildImportSection

public void buildImportSection(java.lang.String uri,
                               XQDocComment comment)
Append information to the import section of the returned xqDoc XML. This information will include the uri for the import as well as the xqDoc comment block associated with the import. This method will be called once for each module imported by either a library or main module.

Parameters:
uri - The uri for the module imported.
comment - The XQDocComment block

buildVariableSection

public void buildVariableSection(java.lang.String uri,
                                 XQDocComment comment)
Append information to the variable section of the returned xqDoc XML. This information will include the defined global variable uri as well as the xqDoc comment block associated with the global variable. This method will be called once for each global variable declared by either a library or main module.

Parameters:
uri - The uri for the global variable.
comment - The XQDocComment block

buildFunctionSection

public void buildFunctionSection(java.lang.String functionName,
                                 java.lang.String functionSignature,
                                 XQDocComment comment,
                                 java.lang.String functionBody,
                                 java.util.HashSet invokedFunctions,
                                 java.util.HashSet referencedVariables)
Construct the snippet of serialized xqDoc XML for the function. This information will consist of the function name, function signature, xqDoc comment block, source code for the function, global variables used by this function, and functions invoked from within this function. This method will be called once for each function declared in a library or main module.

Parameters:
functionName - The local name for the current function
functionSignature - The signature for the function
comment - The XQDocComment associated with the function
functionBody - The source code for the function
invokedFunctions - The list of functions invoked by this function
referencedVariables - The list of global variables referenced by this function

getXML

public java.lang.String getXML()
Construct the xqDoc XML and return the XML as a serialized string. The XML will consist of the following sections:

Returns:
Serialized string of xqDoc XML

buildBeginTagWithNamespace

public static java.lang.String buildBeginTagWithNamespace(java.lang.String name,
                                                          java.lang.String namespace)
Helper method to build a begin XML tag name for the specified name and namespace.

Parameters:
name - XML Element name
namespace - The namespace for this element and it's descendants
Returns:
Begin XML tag for the specified element name

buildBeginTag

public static java.lang.String buildBeginTag(java.lang.String name)
Helper method to build a begin XML tag name for the specified name.

Parameters:
name - XML Element name
Returns:
Begin XML tag for the specified element name

buildEndTag

public static java.lang.String buildEndTag(java.lang.String name)
Helper method to build an end XML tag name for the specified name.

Parameters:
name - XML Element name
Returns:
End XML tag for the specified element name

encodeXML

public static java.lang.String encodeXML(java.lang.String input)
Encode the string. In particular, the following characters will be replaced with the corresponding entity.

Parameters:
input - The string to encode
Returns:
The encoded string