com.sapportals.wcm.protocol.ice.protocol

Class PreparsedXML

java.lang.Object
  extended by com.sapportals.wcm.protocol.ice.protocol.PreparsedXML

public class PreparsedXML
extends Object

A very simple XML preparser that extracts the content information from an XML stream. This preparsing is necessary since:

  1. The ICE server should be stream-based.
  2. The ICE server should hold as few temporary data in memory as possible.
  3. The resource manager needs an InputStream to create or modify a resource, but the SAX parser only invokes the method characters of the registered content handler.
Whenever the preparser finds the content of an XML element it replaces the content by an <?preparsed-xml-content?> processing instruction for the SAX parser and opens a BufferedStream for the content.

E.g. the input

 
  
         <doc-element>
           <element1>Some content for element1</element1>
           <element2></element2>
           <element3>Some content for element3</element3>
           <element4/>
         </doc-element>
   
  
 
will be converted by the preparser to
 
  
         <doc-element>
            <element1><?preparsed-xml-content?></element1>
            <element2><?preparsed-xml-content?></element2>
            <element3><?preparsed-xml-content?></element3>
            <element4/><?preparsed-xml-content?>
         </doc-element>
   
  
 
for the SAX parser. The method processingInstruction of the SAX content handler has to invoke the method removeContentStream of the preparser once it encounters a <?preparsed-xml-content?> processing instruction.

Note that the content of the items is forwarded to the SAX parser in any case except if the method nextContentStream is invoked from within the method startElement of the SAX content handler to get an InputStream on the content element1 resp. element3 (the input streams of element2 and element4 are empty). Therefore, if the method nextContentStream is not invoked the SAX parser behaves as usual.

Copyright 2004 SAP AG


Constructor Summary
PreparsedXML(InputStream inputStream)
          Create a new XML preparser.
 
Method Summary
 InputStream getProcessorStream()
          Gets the InputStream that should be used by the SAX parser.
 InputStream nextContentStream()
          Gets the next element content stream from the stack.
 void removeContentStream()
          Removes the current content stream from the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreparsedXML

public PreparsedXML(InputStream inputStream)
Create a new XML preparser.

Parameters:
inputStream - The incomming XML stream
Method Detail

getProcessorStream

public InputStream getProcessorStream()
Gets the InputStream that should be used by the SAX parser.

In this stream the element content is replaced by a <?preparsed-xml-content?> processing instruction.

Returns:
the InputStream for the SAX parser

nextContentStream

public InputStream nextContentStream()
                              throws IOException
Gets the next element content stream from the stack.

Returns:
an InputStream of the content of an element
Throws:
IOException - on error

removeContentStream

public void removeContentStream()
Removes the current content stream from the stack.

This method has to be invoked by the SAX content handler once it encounters a <?preparsed-xml-content?> processing instruction.

Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] KMC-CM [sap.com] tc/km/frwk api EP-KM-CM
[sap.com] KMC-WPC [sap.com] tc/kmc/wpc/wpcfacade api EP-PIN-WPC-WCM


Copyright 2011 SAP AG Complete Copyright Notice