XBRLAPI

A Java API for XBRL


org.xbrlapi.xlink
Class Validator

java.lang.Object
  extended by org.xbrlapi.xlink.XLinkHandlerDefaultImpl
      extended by org.xbrlapi.xlink.Validator
All Implemented Interfaces:
Serializable, XLinkHandler

public class Validator
extends XLinkHandlerDefaultImpl

Utility handler to perform validation of XLink content in XML documents

Author:
Geoffrey Shuetrim (geoff@galexy.net)
See Also:
Serialized Form

Constructor Summary
Validator(File file)
          Constructor that is given the URI of the document to be validated
Validator(InputSource is)
          Constructor that is given the URI of the document to be validated.
Validator(URI uri)
          Constructor that is given the URI of the document to be validated
 
Method Summary
protected static void badUsage(String message)
          Report incorrect usage of the command line XLink validator
 void endArc(String namespaceURI, String sName, String qName)
          Handles straight pass through of SAX event for the end of simple link elements.
 void endExtendedLink(String namespaceURI, String sName, String qName)
          Handles straight pass through of SAX event for the end of extended link elements.
 void endLocator(String namespaceURI, String sName, String qName)
          Handles straight pass through of SAX event for the end of locators.
 void endResource(String namespaceURI, String sName, String qName)
          Handles straight pass through of SAX event for the end of local resources.
 void endSimpleLink(String namespaceURI, String sName, String qName)
          Handles straight pass through of SAX event for the end of simple link elements.
 void endTitle(String namespaceURI, String sName, String qName)
          Handles straight pass through of SAX event for the end of simple title elements.
 void error(String namespaceURI, String lName, String qName, Attributes attrs, String message)
          Record the error message
 Document getResults()
          Returns an XML DOM document that contains one message element (as a child of the root message element) for each of the errors and warnings generated during the validation process.
static void main(String[] args)
          Enable commandline usage of the XLink validator
 void printMessages()
          Print the errors and warnings to System out
 void startArc(String namespaceURI, String lName, String qName, Attributes attrs, String from, String to, String arcrole, String title, String show, String actuate)
          Handles the start of processing an arc.
 void startExtendedLink(String namespaceURI, String lName, String qName, Attributes attrs, String role, String title)
          Handles the start of processing an extended link.
 void startLocator(String namespaceURI, String lName, String qName, Attributes attrs, String href, String role, String title, String label)
          Handles the start of processing a locator.
 void startResource(String namespaceURI, String lName, String qName, Attributes attrs, String role, String title, String label)
          Handles the start of processing a local resource.
 void startSimpleLink(String namespaceURI, String lName, String qName, Attributes attrs, String href, String role, String arcrole, String title, String show, String actuate)
          Handles the start of processing a simple link (and custom links).
 void startTitle(String namespaceURI, String lName, String qName, Attributes attrs)
          Handles straight pass through of SAX event for XLink title elements
 void titleCharacters(char[] buf, int offset, int len)
          Handles the character content of a title element
 void warning(String namespaceURI, String lName, String qName, Attributes attrs, String message)
          Record the warning
 void xmlBaseEnd()
          Handles end of an element so that XML base related operations can to done
 void xmlBaseStart(String value)
          Handles the start of an element, providing any XML Base attribute value.
 
Methods inherited from class org.xbrlapi.xlink.XLinkHandlerDefaultImpl
equals, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Validator

public Validator(URI uri)
Constructor that is given the URI of the document to be validated

Parameters:
uri - The URI of the document to be validated

Validator

public Validator(File file)
Constructor that is given the URI of the document to be validated

Parameters:
file - The file to be validated

Validator

public Validator(InputSource is)
Constructor that is given the URI of the document to be validated.

Parameters:
is - The input source for the XML to be validated
Method Detail

getResults

public Document getResults()
Returns an XML DOM document that contains one message element (as a child of the root message element) for each of the errors and warnings generated during the validation process. The message elements contain a

Returns:
The DOM document containing the error messages and warning messages

startSimpleLink

public void startSimpleLink(String namespaceURI,
                            String lName,
                            String qName,
                            Attributes attrs,
                            String href,
                            String role,
                            String arcrole,
                            String title,
                            String show,
                            String actuate)
                     throws XLinkException
Description copied from interface: XLinkHandler
Handles the start of processing a simple link (and custom links).

Specified by:
startSimpleLink in interface XLinkHandler
Overrides:
startSimpleLink in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.startSimpleLink(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

endSimpleLink

public void endSimpleLink(String namespaceURI,
                          String sName,
                          String qName)
                   throws XLinkException
Description copied from interface: XLinkHandler
Handles straight pass through of SAX event for the end of simple link elements.

Specified by:
endSimpleLink in interface XLinkHandler
Overrides:
endSimpleLink in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.endSimpleLink(java.lang.String, java.lang.String, java.lang.String)

startTitle

public void startTitle(String namespaceURI,
                       String lName,
                       String qName,
                       Attributes attrs)
                throws XLinkException
Description copied from interface: XLinkHandler
Handles straight pass through of SAX event for XLink title elements

Specified by:
startTitle in interface XLinkHandler
Overrides:
startTitle in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.startTitle(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endTitle

public void endTitle(String namespaceURI,
                     String sName,
                     String qName)
              throws XLinkException
Description copied from interface: XLinkHandler
Handles straight pass through of SAX event for the end of simple title elements.

Specified by:
endTitle in interface XLinkHandler
Overrides:
endTitle in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.endTitle(java.lang.String, java.lang.String, java.lang.String)

titleCharacters

public void titleCharacters(char[] buf,
                            int offset,
                            int len)
                     throws XLinkException
Description copied from interface: XLinkHandler
Handles the character content of a title element

Specified by:
titleCharacters in interface XLinkHandler
Overrides:
titleCharacters in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.titleCharacters(char[], int, int)

startExtendedLink

public void startExtendedLink(String namespaceURI,
                              String lName,
                              String qName,
                              Attributes attrs,
                              String role,
                              String title)
                       throws XLinkException
Description copied from interface: XLinkHandler
Handles the start of processing an extended link.

Specified by:
startExtendedLink in interface XLinkHandler
Overrides:
startExtendedLink in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.startExtendedLink(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String, java.lang.String)

endExtendedLink

public void endExtendedLink(String namespaceURI,
                            String sName,
                            String qName)
                     throws XLinkException
Description copied from interface: XLinkHandler
Handles straight pass through of SAX event for the end of extended link elements.

Specified by:
endExtendedLink in interface XLinkHandler
Overrides:
endExtendedLink in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.endExtendedLink(java.lang.String, java.lang.String, java.lang.String)

startResource

public void startResource(String namespaceURI,
                          String lName,
                          String qName,
                          Attributes attrs,
                          String role,
                          String title,
                          String label)
                   throws XLinkException
Description copied from interface: XLinkHandler
Handles the start of processing a local resource.

Specified by:
startResource in interface XLinkHandler
Overrides:
startResource in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.startResource(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String, java.lang.String, java.lang.String)

endResource

public void endResource(String namespaceURI,
                        String sName,
                        String qName)
                 throws XLinkException
Description copied from interface: XLinkHandler
Handles straight pass through of SAX event for the end of local resources.

Specified by:
endResource in interface XLinkHandler
Overrides:
endResource in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.endResource(java.lang.String, java.lang.String, java.lang.String)

startLocator

public void startLocator(String namespaceURI,
                         String lName,
                         String qName,
                         Attributes attrs,
                         String href,
                         String role,
                         String title,
                         String label)
                  throws XLinkException
Description copied from interface: XLinkHandler
Handles the start of processing a locator.

Specified by:
startLocator in interface XLinkHandler
Overrides:
startLocator in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.startLocator(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

endLocator

public void endLocator(String namespaceURI,
                       String sName,
                       String qName)
                throws XLinkException
Description copied from interface: XLinkHandler
Handles straight pass through of SAX event for the end of locators.

Specified by:
endLocator in interface XLinkHandler
Overrides:
endLocator in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.endLocator(java.lang.String, java.lang.String, java.lang.String)

startArc

public void startArc(String namespaceURI,
                     String lName,
                     String qName,
                     Attributes attrs,
                     String from,
                     String to,
                     String arcrole,
                     String title,
                     String show,
                     String actuate)
              throws XLinkException
Description copied from interface: XLinkHandler
Handles the start of processing an arc.

Specified by:
startArc in interface XLinkHandler
Overrides:
startArc in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.startArc(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

endArc

public void endArc(String namespaceURI,
                   String sName,
                   String qName)
            throws XLinkException
Description copied from interface: XLinkHandler
Handles straight pass through of SAX event for the end of simple link elements.

Specified by:
endArc in interface XLinkHandler
Overrides:
endArc in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.endArc(java.lang.String, java.lang.String, java.lang.String)

xmlBaseStart

public void xmlBaseStart(String value)
                  throws XLinkException
Description copied from interface: XLinkHandler
Handles the start of an element, providing any XML Base attribute value.

Specified by:
xmlBaseStart in interface XLinkHandler
Overrides:
xmlBaseStart in class XLinkHandlerDefaultImpl
Parameters:
value - The value of the XML Base attribute
Throws:
XLinkException
See Also:
XLinkHandler.xmlBaseStart(java.lang.String)

xmlBaseEnd

public void xmlBaseEnd()
                throws XLinkException
Description copied from interface: XLinkHandler
Handles end of an element so that XML base related operations can to done

Specified by:
xmlBaseEnd in interface XLinkHandler
Overrides:
xmlBaseEnd in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.xmlBaseEnd()

error

public void error(String namespaceURI,
                  String lName,
                  String qName,
                  Attributes attrs,
                  String message)
           throws XLinkException
Record the error message

Specified by:
error in interface XLinkHandler
Overrides:
error in class XLinkHandlerDefaultImpl
Parameters:
namespaceURI - Namespace of the element generating the error
lName - local name of the element generating the error
qName - qName of the element generating the error
attrs - attributes of the element generating the error
message - The text of the error message
Throws:
XLinkException - if the handler does not deal with the XLink problem internally
See Also:
XLinkHandler.error(java.lang.String,java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String)

warning

public void warning(String namespaceURI,
                    String lName,
                    String qName,
                    Attributes attrs,
                    String message)
             throws XLinkException
Record the warning

Specified by:
warning in interface XLinkHandler
Overrides:
warning in class XLinkHandlerDefaultImpl
Parameters:
namespaceURI - Namespace of the element generating the error
lName - local name of the element generating the error
qName - qName of the element generating the error
attrs - attributes of the element generating the error
message - The text of the warning message
Throws:
XLinkException - if the handler does not deal with the XLink warning internally
See Also:
XLinkHandler.warning(java.lang.String,java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String)

printMessages

public void printMessages()
Print the errors and warnings to System out


main

public static void main(String[] args)
Enable commandline usage of the XLink validator

Parameters:
args -

badUsage

protected static void badUsage(String message)
Report incorrect usage of the command line XLink validator

Parameters:
message - The error message describing why the commandline usage of the XLink validator failed.

Get Java XBRL API implementation at SourceForge.net.