com.sapportals.wcm.util.xml

Class SAXSerializer

java.lang.Object
  extended bycom.sapportals.wcm.util.xml.SAXSerializer
All Implemented Interfaces:
ContentHandler

public final class SAXSerializer
extends Object
implements ContentHandler

Simple SAX serializer. Only supports simple indentation (whitespace preservation not implemented - if whitespace preservation is required simply do not indent).

Copyright (c) SAP AG 2003-2005


Field Summary
static String NS_XML
          Namespace name for the namespace hardwired to the prefix "xml:"
static String NS_XMLNS
          Namespace name for the namespace hardwired to the prefix "xmlns:"
 
Method Summary
 void characters(char[] chars, int offset, int length)
           
 void endDocument()
           
 void endElement(String namespace, String localname, String qname)
           
 void endPrefixMapping(String prefix)
           
static String escape(String s, boolean escapeQuoteChar)
          Escape characters in a string for inclusion into XML text content.
static SAXSerializer getInstance(OutputStream out, String encoding, boolean indent)
           
static SAXSerializer getInstance(Writer writer, boolean indent)
           
 void ignorableWhitespace(char[] chars, int i, int i1)
           
 void processingInstruction(String target, String data)
           
 void setDocumentLocator(Locator locator)
           
 void skippedEntity(String s)
           
 void startDocument()
           
 void startElement(String namespace, String localname, String qname, Attributes attributes)
           
 void startPrefixMapping(String prefix, String namespace)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NS_XML

public static final String NS_XML
Namespace name for the namespace hardwired to the prefix "xml:"

See Also:
Constant Field Values

NS_XMLNS

public static final String NS_XMLNS
Namespace name for the namespace hardwired to the prefix "xmlns:"

See Also:
Constant Field Values
Method Detail

getInstance

public static SAXSerializer getInstance(Writer writer,
                                        boolean indent)

getInstance

public static SAXSerializer getInstance(OutputStream out,
                                        String encoding,
                                        boolean indent)
                                 throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String namespace)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Throws:
SAXException

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

startElement

public void startElement(String namespace,
                         String localname,
                         String qname,
                         Attributes attributes)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String namespace,
                       String localname,
                       String qname)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

characters

public void characters(char[] chars,
                       int offset,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] chars,
                                int i,
                                int i1)
                         throws SAXException
Specified by:
ignorableWhitespace in interface ContentHandler
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler

skippedEntity

public void skippedEntity(String s)
                   throws SAXException
Specified by:
skippedEntity in interface ContentHandler
Throws:
SAXException

escape

public static String escape(String s,
                            boolean escapeQuoteChar)
                     throws SAXException
Escape characters in a string for inclusion into XML text content. The generated string is guaranteed to only contain characters from the US-ASCII character set.

Parameters:
s - un-escaped string
escapeQuoteChar - whether to escape the quote character or not (for attribute values). Note that attributes are supposed to be quoted using double quotes, so apostroph characters are not replaced.
Returns:
escaped string
Throws:
SAXException - Exception raised in failure situation


Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.