Renamed 'process' to 'processorData' #251
| @@ -29,13 +29,13 @@ def process_xml(request: request, type: str) -> str: | ||||
|     try: | ||||
|         request_data = json.loads(request.get_data(as_text=True)) | ||||
|         data = request_data['data'] | ||||
|         process = request_data['process'] | ||||
|         processorData = request_data['processorData'] | ||||
|         if (type == "xsd"): | ||||
|             response_json['result'] = Parser.xsd(data, process) | ||||
|             response_json['result'] = Parser.xsd(data, processorData) | ||||
|         elif (type == "xslt"): | ||||
|             response_json['result'] = Parser.xslt(data, process) | ||||
|             response_json['result'] = Parser.xslt(data, processorData) | ||||
|         elif (type == "xpath"): | ||||
|             response_json['result'], response_json['type'] = Parser.xpath(data, process) | ||||
|             response_json['result'], response_json['type'] = Parser.xpath(data, processorData) | ||||
|         elif (type == "prettify"): | ||||
|             response_json['result'] = Parser.formatXML(data, True) | ||||
|         elif (type == "minimize"): | ||||
| @@ -45,7 +45,7 @@ def process_xml(request: request, type: str) -> str: | ||||
|         elif (type == "minimizeHtml"): | ||||
|             response_json['result'] = Parser.formatHTML(data, False) | ||||
|         elif (type == "convertHTML"): | ||||
|             response_json['result'] = Parser.convertHTML(data, process) | ||||
|             response_json['result'] = Parser.convertHTML(data, processorData) | ||||
|         else: | ||||
|             raise ValueError("Valid operation types are: xsd, xslt, xpath") | ||||
|  | ||||
|   | ||||
| @@ -117,7 +117,7 @@ public class XmlController implements RestController { | ||||
|         XMLRequestBody requestBody = xmlJob.getRequestBody(); | ||||
|  | ||||
|         XPathQueryResult xPathQueryResult = | ||||
|                 engine.processXPath(requestBody.getData(), requestBody.getProcess(), requestBody.getVersion()); | ||||
|                 engine.processXPath(requestBody.getData(), requestBody.getProcessorData(), requestBody.getVersion()); | ||||
|  | ||||
|         return new XMLResponseBody(xPathQueryResult.getData().trim(), | ||||
|                 "OK", engine.getVersion(), xPathQueryResult.getType()); | ||||
| @@ -130,14 +130,14 @@ public class XmlController implements RestController { | ||||
|         String result = null; | ||||
|         switch (xmlJob.getXmlJobType()) { | ||||
|             case XSLT: | ||||
|                 result = engine.processXSLT(requestBody.getData(), requestBody.getProcess()); | ||||
|                 result = engine.processXSLT(requestBody.getData(), requestBody.getProcessorData()); | ||||
|                 break; | ||||
|             case XSD: | ||||
|                 result = engine.validate(requestBody.getData(), requestBody.getProcess()).trim(); | ||||
|                 result = engine.validate(requestBody.getData(), requestBody.getProcessorData()).trim(); | ||||
|                 break; | ||||
|             case XQuery: | ||||
|                 result = engine.executeXQuery(requestBody.getData(), | ||||
|                         requestBody.getProcess(), | ||||
|                         requestBody.getProcessorData(), | ||||
|                         requestBody.getVersion()); | ||||
|                 break; | ||||
|         } | ||||
|   | ||||
| @@ -4,13 +4,13 @@ import com.google.gson.annotations.SerializedName; | ||||
|  | ||||
| /** | ||||
|  * POJO class used to contain body of XML related requests | ||||
|  * @author Adam | ||||
|  * @author Adam Bem | ||||
|  */ | ||||
| public class XMLRequestBody { | ||||
|     @SerializedName("data") | ||||
|     private String data; | ||||
|     @SerializedName("process") | ||||
|     private String process; | ||||
|     @SerializedName("processorData") | ||||
|     private String processorData; | ||||
|     @SerializedName("processor") | ||||
|     private String processor; | ||||
|     @SerializedName("version") | ||||
| @@ -20,8 +20,8 @@ public class XMLRequestBody { | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
|     public String getProcess() { | ||||
|         return process; | ||||
|     public String getProcessorData() { | ||||
|         return processorData; | ||||
|     } | ||||
|  | ||||
|     public String getProcessor() { | ||||
|   | ||||
| @@ -100,7 +100,7 @@ function prepareURL(): string { | ||||
| function prepareRequestBody():string { | ||||
|     var requestBody = JSON.stringify({ | ||||
|         "data": props.xml, | ||||
|         "process": props.query, | ||||
|         "processorData": props.query, | ||||
|         "processor": engine.value, | ||||
|         "version": version.value | ||||
|     }); | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| { | ||||
|     "data": "<b:books xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.demo.com' xmlns:b='http://www.book.com' xmlns:a='http://www.author.com'><b:book id='1'><b:name>Hamlet</b:name><b:date>2001-05-04</b:date><a:authorId>1</a:authorId><b:availability>false</b:availability></b:book><b:book id='2'><b:name>Macbeth</b:name><b:date>2000-12-13</b:date><a:authorId>1</a:authorId><b:availability>false</b:availability></b:book><b:book id='3'><b:name>Harry Potter and the Sorcerer's Stone</b:name><b:date>2005-04-29</b:date><a:authorId>2</a:authorId><b:availability>true</b:availability></b:book><b:book id='4'><b:name>The Long Walk</b:name><b:date>2018-07-01</b:date><a:authorId>4</a:authorId><b:availability>true</b:availability></b:book><b:book id='5'><b:name>Misery</b:name><b:date>2018-01-31</b:date><a:authorId>4</a:authorId><b:availability>true</b:availability></b:book><b:book id='6'><b:name>Think and Grow Rich</b:name><b:date>2004-09-10</b:date><a:authorId>6</a:authorId><b:availability>true</b:availability></b:book><b:book id='7'><b:name>The Law of Success</b:name><b:date>1982-05-09</b:date><a:authorId>6</a:authorId><b:availability>false</b:availability></b:book><b:book id='8'><b:name>Patriot Games</b:name><b:date>1995-10-21</b:date><a:authorId>5</a:authorId><b:availability>false</b:availability></b:book><b:book id='9'><b:name>The Sum of All Fears</b:name><b:date>1992-09-19</b:date><a:authorId>5</a:authorId><b:availability>false</b:availability></b:book><b:book id='10'><b:name>The Alchemist</b:name><b:date>2017-02-20</b:date><a:authorId>3</a:authorId><b:availability>false</b:availability></b:book><b:book id='11'><b:name>Hamlet</b:name><b:date>1994-06-01</b:date><a:authorId>1</a:authorId><b:availability>false</b:availability></b:book><b:book id='12'><b:name>Measure for Measure</b:name><b:date>1990-03-23</b:date><a:authorId>1</a:authorId><b:availability>false</b:availability></b:book><b:book id='13'><b:name>Hamlet</b:name><b:date>1989-05-05</b:date><a:authorId>1</a:authorId><b:availability>true</b:availability></b:book><b:book id='14'><b:name>Hamlet</b:name><b:date>1999-05-30</b:date><a:authorId>1</a:authorId><b:availability>true</b:availability></b:book><b:book id='15'><b:name>The Law of Success</b:name><b:date>2004-11-26</b:date><a:authorId>6</a:authorId><b:availability>true</b:availability></b:book><b:book id='16'><b:name>Romeo and Juliet</b:name><b:date>1997-02-08</b:date><a:authorId>1</a:authorId><b:availability>true</b:availability></b:book><b:book id='17'><b:name>The Alchemist</b:name><b:date>2009-08-21</b:date><a:authorId>3</a:authorId><b:availability>true</b:availability></b:book></b:books>", | ||||
|     "processorData": "N/A", | ||||
|     "processor": "libxml", | ||||
|     "version": "1.0" | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|     "data": "<b:books xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.demo.com' xmlns:b='http://www.book.com' xmlns:a='http://www.author.com'><b:book id='1'><b:name>Hamlet</b:name><b:date>2001-05-04</b:date><a:authorId>1</a:authorId><b:availability>false</b:availability></b:book><b:book id='2'><b:name>Macbeth</b:name><b:date>2000-12-13</b:date><a:authorId>1</a:authorId><b:availability>false</b:availability></b:book><b:book id='3'><b:name>Harry Potter and the Sorcerer's Stone</b:name><b:date>2005-04-29</b:date><a:authorId>2</a:authorId><b:availability>true</b:availability></b:book><b:book id='4'><b:name>The Long Walk</b:name><b:date>2018-07-01</b:date><a:authorId>4</a:authorId><b:availability>true</b:availability></b:book><b:book id='5'><b:name>Misery</b:name><b:date>2018-01-31</b:date><a:authorId>4</a:authorId><b:availability>true</b:availability></b:book><b:book id='6'><b:name>Think and Grow Rich</b:name><b:date>2004-09-10</b:date><a:authorId>6</a:authorId><b:availability>true</b:availability></b:book><b:book id='7'><b:name>The Law of Success</b:name><b:date>1982-05-09</b:date><a:authorId>6</a:authorId><b:availability>false</b:availability></b:book><b:book id='8'><b:name>Patriot Games</b:name><b:date>1995-10-21</b:date><a:authorId>5</a:authorId><b:availability>false</b:availability></b:book><b:book id='9'><b:name>The Sum of All Fears</b:name><b:date>1992-09-19</b:date><a:authorId>5</a:authorId><b:availability>false</b:availability></b:book><b:book id='10'><b:name>The Alchemist</b:name><b:date>2017-02-20</b:date><a:authorId>3</a:authorId><b:availability>false</b:availability></b:book><b:book id='11'><b:name>Hamlet</b:name><b:date>1994-06-01</b:date><a:authorId>1</a:authorId><b:availability>false</b:availability></b:book><b:book id='12'><b:name>Measure for Measure</b:name><b:date>1990-03-23</b:date><a:authorId>1</a:authorId><b:availability>false</b:availability></b:book><b:book id='13'><b:name>Hamlet</b:name><b:date>1989-05-05</b:date><a:authorId>1</a:authorId><b:availability>true</b:availability></b:book><b:book id='14'><b:name>Hamlet</b:name><b:date>1999-05-30</b:date><a:authorId>1</a:authorId><b:availability>true</b:availability></b:book><b:book id='15'><b:name>The Law of Success</b:name><b:date>2004-11-26</b:date><a:authorId>6</a:authorId><b:availability>true</b:availability></b:book><b:book id='16'><b:name>Romeo and Juliet</b:name><b:date>1997-02-08</b:date><a:authorId>1</a:authorId><b:availability>true</b:availability></b:book><b:book id='17'><b:name>The Alchemist</b:name><b:date>2009-08-21</b:date><a:authorId>3</a:authorId><b:availability>true</b:availability></b:book></b:books>", | ||||
|     "process": "whatever", | ||||
|     "processorData": "N/A", | ||||
|     "processor": "libxml", | ||||
|     "version": "1.0" | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "data": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<books><book id='1'><name>Hamlet</name><date>2001-05-04</date><authorId>1</authorId><availability>false</availability></book><book id='2'><name>Macbeth</name><date>2000-12-13</date><authorId>1</authorId><availability>false</availability></book><book id='3'><name>Harry Potter and the Sorcerer's Stone</name><date>2005-04-29</date><authorId>2</authorId><availability>true</availability></book><book id='4'><name>The Long Walk</name><date>2018-07-01</date><authorId>4</authorId><availability>true</availability></book><book id='5'><name>Misery</name><date>2018-01-31</date><authorId>4</authorId><availability>true</availability></book><book id='6'><name>Think and Grow Rich</name><date>2004-09-10</date><authorId>6</authorId><availability>true</availability></book><book id='7'><name>The Law of Success</name><date>1982-05-09</date><authorId>6</authorId><availability>false</availability></book><book id='8'><name>Patriot Games</name><date>1995-10-21</date><authorId>5</authorId><availability>false</availability></book><book id='9'><name>The Sum of All Fears</name><date>1992-09-19</date><authorId>5</authorId><availability>false</availability></book><book id='10'><name>The Alchemist</name><date>2017-02-20</date><authorId>3</authorId><availability>false</availability></book><book id='11'><name>Hamlet</name><date>1994-06-01</date><authorId>1</authorId><availability>false</availability></book><book id='12'><name>Measure for Measure</name><date>1990-03-23</date><authorId>1</authorId><availability>false</availability></book><book id='13'><name>Hamlet</name><date>1989-05-05</date><authorId>1</authorId><availability>true</availability></book><book id='14'><name>Hamlet</name><date>1999-05-30</date><authorId>1</authorId><availability>true</availability></book><book id='15'><name>The Law of Success</name><date>2004-11-26</date><authorId>6</authorId><availability>true</availability></book><book id='16'><name>Romeo and Juliet</name><date>1997-02-08</date><authorId>1</authorId><availability>true</availability></book><book id='17'><name>The Alchemist</name><date>2009-08-21</date><authorId>3</authorId><availability>true</availability></book></books>", | ||||
|   "process": "/books/book[name = 'The Law of Success']", | ||||
|   "processorData": "/books/book[name = 'The Law of Success']", | ||||
|   "processor": "saxon", | ||||
|   "version": "2.0" | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "data": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<b:books xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.demo.com' xmlns:b='http://www.book.com' xmlns:a='http://www.author.com'><b:book id='1'><b:name>Hamlet</b:name><b:date>2001-05-04</b:date><a:authorId>1</a:authorId><b:availability>false</b:availability></b:book><b:book id='2'><b:name>Macbeth</b:name><b:date>2000-12-13</b:date><a:authorId>1</a:authorId><b:availability>false</b:availability></b:book><b:book id='3'><b:name>Harry Potter and the Sorcerer's Stone</b:name><b:date>2005-04-29</b:date><a:authorId>2</a:authorId><b:availability>true</b:availability></b:book><b:book id='4'><b:name>The Long Walk</b:name><b:date>2018-07-01</b:date><a:authorId>4</a:authorId><b:availability>true</b:availability></b:book><b:book id='5'><b:name>Misery</b:name><b:date>2018-01-31</b:date><a:authorId>4</a:authorId><b:availability>true</b:availability></b:book><b:book id='6'><b:name>Think and Grow Rich</b:name><b:date>2004-09-10</b:date><a:authorId>6</a:authorId><b:availability>true</b:availability></b:book><b:book id='7'><b:name>The Law of Success</b:name><b:date>1982-05-09</b:date><a:authorId>6</a:authorId><b:availability>false</b:availability></b:book><b:book id='8'><b:name>Patriot Games</b:name><b:date>1995-10-21</b:date><a:authorId>5</a:authorId><b:availability>false</b:availability></b:book><b:book id='9'><b:name>The Sum of All Fears</b:name><b:date>1992-09-19</b:date><a:authorId>5</a:authorId><b:availability>false</b:availability></b:book><b:book id='10'><b:name>The Alchemist</b:name><b:date>2017-02-20</b:date><a:authorId>3</a:authorId><b:availability>false</b:availability></b:book><b:book id='11'><b:name>Hamlet</b:name><b:date>1994-06-01</b:date><a:authorId>1</a:authorId><b:availability>false</b:availability></b:book><b:book id='12'><b:name>Measure for Measure</b:name><b:date>1990-03-23</b:date><a:authorId>1</a:authorId><b:availability>false</b:availability></b:book><b:book id='13'><b:name>Hamlet</b:name><b:date>1989-05-05</b:date><a:authorId>1</a:authorId><b:availability>true</b:availability></b:book><b:book id='14'><b:name>Hamlet</b:name><b:date>1999-05-30</b:date><a:authorId>1</a:authorId><b:availability>true</b:availability></b:book><b:book id='15'><b:name>The Law of Success</b:name><b:date>2004-11-26</b:date><a:authorId>6</a:authorId><b:availability>true</b:availability></b:book><b:book id='16'><b:name>Romeo and Juliet</b:name><b:date>1997-02-08</b:date><a:authorId>1</a:authorId><b:availability>true</b:availability></b:book><b:book id='17'><b:name>The Alchemist</b:name><b:date>2009-08-21</b:date><a:authorId>3</a:authorId><b:availability>true</b:availability></b:book></b:books>", | ||||
|   "process": "/b:books/b:book[b:name = 'The Law of Success']", | ||||
|   "processorData": "/b:books/b:book[b:name = 'The Law of Success']", | ||||
|   "processor": "saxon", | ||||
|   "version": "2.0" | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|     "data": "<people><person><name>John</name><age>67</age></person><person><name>Anna</name><age>69</age></person></people>", | ||||
|     "process": "for $x in //person return string($x/name)", | ||||
|     "processorData": "for $x in //person return string($x/name)", | ||||
|     "processor": "saxon", | ||||
|     "version": "3.1" | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|     "data": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ns0:values xmlns:ns0 = \"http://www.tibco.com/schemas/test/Test/Resources/Schema.xsd\"><ns0:value>Test</ns0:value><ns0:value>Test3</ns0:value></ns0:values>", | ||||
|     "process": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.tibco.com/schemas/test/Test/Resources/Schema.xsd\" targetNamespace=\"http://www.tibco.com/schemas/test/Test/Resources/Schema.xsd\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"> <xs:element name=\"values\"><xs:complexType><xs:sequence><xs:element name=\"value\" type=\"xs:string\" minOccurs=\"0\" maxOccurs=\"unbounded\"/></xs:sequence></xs:complexType></xs:element></xs:schema>", | ||||
|     "processorData": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.tibco.com/schemas/test/Test/Resources/Schema.xsd\" targetNamespace=\"http://www.tibco.com/schemas/test/Test/Resources/Schema.xsd\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"> <xs:element name=\"values\"><xs:complexType><xs:sequence><xs:element name=\"value\" type=\"xs:string\" minOccurs=\"0\" maxOccurs=\"unbounded\"/></xs:sequence></xs:complexType></xs:element></xs:schema>", | ||||
|     "processor": "saxon", | ||||
|     "version": "1.0" | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|     "data": "<?xml version=\"1.0\" encoding=\"utf-8\"?><l:library xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.release11.com\" xmlns:l=\"http://www.release11.com/library\" xmlns:p=\"http://www.release11.com/person\" xmlns:b=\"http://www.release11.com/book\"><l:libraryName>City library</l:libraryName><l:libraryID>345123</l:libraryID><l:readerList><p:person><p:readerID>7321</p:readerID><p:name>Adam</p:name><p:surname>Choke</p:surname></p:person><p:person><p:readerID>5123</p:readerID><p:name>Lauren</p:name><p:surname>Wong</p:surname></p:person></l:readerList><l:bookList><b:book><b:bookID>6422</b:bookID><b:title>Harry Potter</b:title><p:readerID>7542</p:readerID></b:book><b:book><b:bookID>1234</b:bookID><b:title>Macbeth</b:title><p:readerID>5123</p:readerID></b:book><b:book><b:bookID>9556</b:bookID><b:title>Romeo and Juliet</b:title></b:book></l:bookList></l:library>", | ||||
|     "process": "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:b=\"http://www.demo.com\" xmlns:p=\"http://www.release11.com/person\" xmlns:l=\"http://www.release11.com/library\" version=\"1.0\"><xsl:template match=\"/\"><Library><ReaderCount><xsl:value-of select=\"count(//p:person)\"/></ReaderCount><BookCount><xsl:value-of select=\"count(/l:library/l:bookList/b:book)\"/></BookCount></Library></xsl:template></xsl:stylesheet>", | ||||
|     "processorData": "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:b=\"http://www.demo.com\" xmlns:p=\"http://www.release11.com/person\" xmlns:l=\"http://www.release11.com/library\" version=\"1.0\"><xsl:template match=\"/\"><Library><ReaderCount><xsl:value-of select=\"count(//p:person)\"/></ReaderCount><BookCount><xsl:value-of select=\"count(/l:library/l:bookList/b:book)\"/></BookCount></Library></xsl:template></xsl:stylesheet>", | ||||
|     "processor": "saxon", | ||||
|     "version": "1.0" | ||||
| } | ||||
|   | ||||
| @@ -895,7 +895,7 @@ | ||||
|           "example": "<values><value>2</value><value>8</value></values>", | ||||
|           "description": "The XML data to be processed" | ||||
|         }, | ||||
|         "process": { | ||||
|         "processorData": { | ||||
|           "type": "string", | ||||
|           "example": "count(//value)", | ||||
|           "description": "XPath tranform to be executed" | ||||
| @@ -925,7 +925,7 @@ | ||||
|           "example": "<values><value>2</value><value>8</value></values>", | ||||
|           "description": "The XML data to be processed" | ||||
|         }, | ||||
|         "process": { | ||||
|         "processorData": { | ||||
|           "type": "string", | ||||
|           "example": "count(//value)", | ||||
|           "description": "XSLT tranform to be executed" | ||||
| @@ -955,7 +955,7 @@ | ||||
|           "example": "<values><value>2</value><value>8</value></values>", | ||||
|           "description": "The XML data to be processed" | ||||
|         }, | ||||
|         "process": { | ||||
|         "processorData": { | ||||
|           "type": "string", | ||||
|           "example": "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://www.tibco.com/schemas/test/Test/Resources/Schema.xsd\" targetNamespace=\"http://www.tibco.com/schemas/test/Test/Resources/Schema.xsd\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\"> <xs:element name=\"values\"><xs:complexType><xs:sequence><xs:element name=\"value\" type=\"xs:string\" minOccurs=\"0\" maxOccurs=\"unbounded\"/></xs:sequence></xs:complexType></xs:element></xs:schema>", | ||||
|           "description": "XSD to perform verification with" | ||||
| @@ -1130,7 +1130,7 @@ | ||||
|           "example": "<values><value>2</value><value>8</value></values>", | ||||
|           "description": "The XML data to be prettified" | ||||
|         }, | ||||
|         "process": { | ||||
|         "processorData": { | ||||
|           "type": "string", | ||||
|           "example": "", | ||||
|           "description": "Unused here, required only to use same json for whole project" | ||||
| @@ -1157,7 +1157,7 @@ | ||||
|           "example": "<values><value>2</value><value>8</value></values>", | ||||
|           "description": "The XML data to be minimized" | ||||
|         }, | ||||
|         "process": { | ||||
|         "processorData": { | ||||
|           "type": "string", | ||||
|           "example": "", | ||||
|           "description": "Unused here, required only to use same json for whole project" | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user