Class XMLInputReader
- java.lang.Object
-
- org.wso2.carbon.mediator.datamapper.engine.input.readers.XMLInputReader
-
- All Implemented Interfaces:
InputReader
public class XMLInputReader extends Object implements InputReader
This class is capable of parsing XML through AXIOMS for the InputStream and build the respective JSON message
-
-
Constructor Summary
Constructors Constructor Description XMLInputReader()
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAttributeQName(org.apache.axiom.om.OMNamespace omNamespace, String localName)
String
getAttributeQName(org.apache.axiom.om.OMNamespace omNamespace, String localName, Map jsonSchemaMap)
This function will resolve prefix for given URI depending on the provided traversal level given by jsonSchemaMapSchema
getInputSchema()
void
read(InputStream input, Schema inputSchema, InputBuilder messageBuilder)
Read, parse the XML and notify with the output JSON messageString
xmlTraverse(org.apache.axiom.om.OMElement omElement, String prevElementName, Map jsonSchemaMap)
This method will perform a Depth First Search on the XML message and build the json message
-
-
-
Constructor Detail
-
XMLInputReader
public XMLInputReader() throws IOException
Constructor- Throws:
IOException
-
-
Method Detail
-
read
public void read(InputStream input, Schema inputSchema, InputBuilder messageBuilder) throws ReaderException
Read, parse the XML and notify with the output JSON message- Specified by:
read
in interfaceInputReader
- Parameters:
input
- XML message InputStreaminputSchema
- Schema of the input messagemessageBuilder
- Reference of the InputXMLMessageBuilder- Throws:
ReaderException
- Exceptions in the parsing stage
-
xmlTraverse
public String xmlTraverse(org.apache.axiom.om.OMElement omElement, String prevElementName, Map jsonSchemaMap) throws IOException, ReaderException, SchemaException, JSException, InvalidPayloadException
This method will perform a Depth First Search on the XML message and build the json message- Parameters:
omElement
- initially the root element will be passed-inprevElementName
- name of the previous element only if the previous element was an array, a null otherwisejsonSchemaMap
- reduced json input schema map that is applicable to this level- Returns:
- the name of the previous element if the element was an array element, null otherwise
- Throws:
IOException
ReaderException
SchemaException
JSException
InvalidPayloadException
-
getAttributeQName
public String getAttributeQName(org.apache.axiom.om.OMNamespace omNamespace, String localName)
-
getAttributeQName
public String getAttributeQName(org.apache.axiom.om.OMNamespace omNamespace, String localName, Map jsonSchemaMap) throws SchemaException
This function will resolve prefix for given URI depending on the provided traversal level given by jsonSchemaMap- Parameters:
omNamespace
-localName
-jsonSchemaMap
-- Returns:
- Throws:
SchemaException
-
getInputSchema
public Schema getInputSchema()
-
-