|
UTF-X, Unit Testing Framework - Xslt | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
utfx.util.CanonicalForm
public class CanonicalForm
Transforms an XML document into its canonical form according to the W3C Canonical XML specification. This class also has a mode which removes whitespace outside of an element and whitespace in an element if it is only whitespace.
Copyright © 2004 - University of Southern Queensland.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
$Source: /cvs/utf-x/framework/src/java/utfx/util/CanonicalForm.java,v $
| Field Summary | |
|---|---|
protected boolean |
accumulating
Set true when character data is being accumulated into a buffer. |
protected java.lang.StringBuffer |
characterData
Buffer where character data is accumulated |
protected static java.lang.String |
DEFAULT_PARSER_NAME
Default parser name. |
protected int |
elementDepth
Element depth. |
protected java.io.PrintWriter |
fOut
Print writer. |
protected boolean |
inEntity
whether we are within an entity |
protected org.xml.sax.XMLReader |
parser
SAX Parser. |
protected boolean |
trailingNewLine
True to put trailing new lines, false for preceding new lines. |
protected boolean |
useW3CSpec
Set true to use W3C specification. |
| Constructor Summary | |
|---|---|
CanonicalForm()
Default constructor. |
|
CanonicalForm(boolean useW3CSpec)
Constructs a CanonicalForm. |
|
| Method Summary | |
|---|---|
void |
characters(char[] ch,
int start,
int length)
Characters. |
void |
comment(char[] ch,
int start,
int length)
Comment. |
void |
endCDATA()
End CDATA section. |
void |
endDocument()
End document. |
void |
endDTD()
End DTD. |
void |
endElement(java.lang.String uri,
java.lang.String local,
java.lang.String raw)
End element. |
void |
endEntity(java.lang.String name)
End entity. |
void |
error(org.xml.sax.SAXParseException ex)
Error. |
void |
fatalError(org.xml.sax.SAXParseException ex)
Fatal error. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Ignorable whitespace. |
protected void |
normalizeAndPrint(char c)
Normalizes and print the given character. |
protected void |
normalizeAndPrint(char[] ch,
int offset,
int length)
Normalizes and prints the given array of characters. |
protected void |
normalizeAndPrint(java.lang.String s)
Normalizes and prints the given string. |
protected void |
normalizeAndPrintNewline(char c)
Normalizes newline characters and prints the given character |
protected void |
normalizeAndPrintNewline(java.lang.String s)
Normalizes newline characters and prints the given string |
protected void |
outputCharacterData()
Outputs any character data that was being accumulated in the characters method. |
protected void |
printError(java.lang.String type,
org.xml.sax.SAXParseException ex)
Prints the error message. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Processing instruction. |
protected void |
setDefaultFeatures()
Set the XML parser features for Canonical XML. |
void |
setOutputStream(java.io.OutputStream stream)
Sets the output stream for printing. |
protected void |
setParserAndHandlers(org.xml.sax.helpers.DefaultHandler handler)
set the various handlers to the handler passed in |
protected org.xml.sax.Attributes |
sortAttributes(org.xml.sax.Attributes attrs)
Returns a sorted list of attributes. |
void |
startCDATA()
Start CDATA section. |
void |
startDocument()
Start document. |
void |
startDTD(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Start DTD. |
void |
startElement(java.lang.String uri,
java.lang.String local,
java.lang.String raw,
org.xml.sax.Attributes attrs)
Default Implementation of start element. |
void |
startEntity(java.lang.String name)
Start entity. |
void |
transform(java.io.InputStream is,
java.io.OutputStream os)
Transform an XML input stream into its canonical XML form. |
void |
warning(org.xml.sax.SAXParseException ex)
Warning. |
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
|---|
endPrefixMapping, notationDecl, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.lang.String DEFAULT_PARSER_NAME
protected java.io.PrintWriter fOut
protected int elementDepth
protected org.xml.sax.XMLReader parser
protected boolean useW3CSpec
protected boolean trailingNewLine
protected boolean accumulating
protected boolean inEntity
protected java.lang.StringBuffer characterData
| Constructor Detail |
|---|
public CanonicalForm()
public CanonicalForm(boolean useW3CSpec)
useW3CSpec - true to use the W3C Canonical XML spec, set to false so
that whitespace between elements is considered insignificant.
Default is false.| Method Detail |
|---|
protected void setParserAndHandlers(org.xml.sax.helpers.DefaultHandler handler)
throws java.lang.Exception
java.lang.Exception
protected void setDefaultFeatures()
throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void transform(java.io.InputStream is,
java.io.OutputStream os)
throws java.io.IOException,
org.xml.sax.SAXException
is - input stream representing an XML document.os - output stream which contains the canonical form
java.io.IOException
org.xml.sax.SAXExceptionpublic void setOutputStream(java.io.OutputStream stream)
stream - an OutputStream to which the output will be
printed.public void startDocument()
startDocument in interface org.xml.sax.ContentHandlerstartDocument in class org.xml.sax.helpers.DefaultHandlerpublic void endDocument()
endDocument in interface org.xml.sax.ContentHandlerendDocument in class org.xml.sax.helpers.DefaultHandler
public void processingInstruction(java.lang.String target,
java.lang.String data)
throws org.xml.sax.SAXException
processingInstruction in interface org.xml.sax.ContentHandlerprocessingInstruction in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void startElement(java.lang.String uri,
java.lang.String local,
java.lang.String raw,
org.xml.sax.Attributes attrs)
throws org.xml.sax.SAXException
startElement in interface org.xml.sax.ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandleruri - a String valuelocal - a String valueraw - a String valueattrs - an Attributes value
org.xml.sax.SAXException - if an error occurs
public void characters(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
characters in interface org.xml.sax.ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void ignorableWhitespace(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
ignorableWhitespace in interface org.xml.sax.ContentHandlerignorableWhitespace in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void endElement(java.lang.String uri,
java.lang.String local,
java.lang.String raw)
throws org.xml.sax.SAXException
endElement in interface org.xml.sax.ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void warning(org.xml.sax.SAXParseException ex)
throws org.xml.sax.SAXException
warning in interface org.xml.sax.ErrorHandlerwarning in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void error(org.xml.sax.SAXParseException ex)
throws org.xml.sax.SAXException
error in interface org.xml.sax.ErrorHandlererror in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void fatalError(org.xml.sax.SAXParseException ex)
throws org.xml.sax.SAXException
fatalError in interface org.xml.sax.ErrorHandlerfatalError in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void startDTD(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
throws org.xml.sax.SAXException
startDTD in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXException
public void endDTD()
throws org.xml.sax.SAXException
endDTD in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXException
public void startEntity(java.lang.String name)
throws org.xml.sax.SAXException
startEntity in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXException
public void endEntity(java.lang.String name)
throws org.xml.sax.SAXException
endEntity in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXException
public void startCDATA()
throws org.xml.sax.SAXException
startCDATA in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXException
public void endCDATA()
throws org.xml.sax.SAXException
endCDATA in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXException
public void comment(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
comment in interface org.xml.sax.ext.LexicalHandlerorg.xml.sax.SAXExceptionprotected org.xml.sax.Attributes sortAttributes(org.xml.sax.Attributes attrs)
protected void normalizeAndPrint(java.lang.String s)
protected void normalizeAndPrint(char[] ch,
int offset,
int length)
protected void normalizeAndPrint(char c)
protected void normalizeAndPrintNewline(java.lang.String s)
s - protected void normalizeAndPrintNewline(char c)
c -
protected void printError(java.lang.String type,
org.xml.sax.SAXParseException ex)
protected void outputCharacterData()
|
UTF-X, Unit Testing Framework - Xslt | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||