From 0425aadc78680e53000fd0108b540d6eca048516 Mon Sep 17 00:00:00 2001 From: gmcdonald Date: Sat, 13 Feb 2010 01:32:03 +0000 Subject: Moving axis svn, part of TLP move INFRA-2441 git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@909681 13f79535-47bb-0310-9956-ffa450edef68 --- axiom/AUTHORS | 0 axiom/COPYING | 203 + axiom/CREDITS | 0 axiom/ChangeLog | 6 + axiom/INSTALL | 14 + axiom/LICENSE | 203 + axiom/Makefile.am | 9 + axiom/NEWS | 7 + axiom/README | 57 + axiom/autogen.sh | 50 + axiom/build.sh | 7 + axiom/configure.ac | 179 + axiom/include/Makefile.am | 1 + axiom/include/axiom.h | 57 + axiom/include/axiom_attribute.h | 263 + axiom/include/axiom_child_element_iterator.h | 124 + axiom/include/axiom_children_iterator.h | 123 + axiom/include/axiom_children_qname_iterator.h | 107 + ...iom_children_with_specific_attribute_iterator.h | 128 + axiom/include/axiom_comment.h | 115 + axiom/include/axiom_data_handler.h | 260 + axiom/include/axiom_data_source.h | 111 + axiom/include/axiom_defines.h | 40 + axiom/include/axiom_doctype.h | 120 + axiom/include/axiom_document.h | 173 + axiom/include/axiom_element.h | 747 +++ axiom/include/axiom_mime_const.h | 56 + axiom/include/axiom_mime_parser.h | 220 + axiom/include/axiom_mime_part.h | 131 + axiom/include/axiom_mtom_caching_callback.h | 114 + axiom/include/axiom_mtom_sending_callback.h | 112 + axiom/include/axiom_namespace.h | 201 + axiom/include/axiom_navigator.h | 121 + axiom/include/axiom_node.h | 379 ++ axiom/include/axiom_output.h | 254 + axiom/include/axiom_processing_instruction.h | 136 + axiom/include/axiom_soap.h | 53 + axiom/include/axiom_soap_body.h | 184 + axiom/include/axiom_soap_builder.h | 253 + axiom/include/axiom_soap_const.h | 176 + axiom/include/axiom_soap_envelope.h | 244 + axiom/include/axiom_soap_fault.h | 215 + axiom/include/axiom_soap_fault_code.h | 120 + axiom/include/axiom_soap_fault_detail.h | 111 + axiom/include/axiom_soap_fault_node.h | 112 + axiom/include/axiom_soap_fault_reason.h | 139 + axiom/include/axiom_soap_fault_role.h | 109 + axiom/include/axiom_soap_fault_sub_code.h | 123 + axiom/include/axiom_soap_fault_text.h | 138 + axiom/include/axiom_soap_fault_value.h | 120 + axiom/include/axiom_soap_header.h | 205 + axiom/include/axiom_soap_header_block.h | 228 + axiom/include/axiom_stax_builder.h | 154 + axiom/include/axiom_text.h | 265 + axiom/include/axiom_util.h | 396 ++ axiom/include/axiom_xml_reader.h | 706 ++ axiom/include/axiom_xml_writer.h | 1014 +++ axiom/include/axiom_xpath.h | 407 ++ axiom/src/Makefile.am | 2 + axiom/src/attachments/Makefile.am | 15 + axiom/src/attachments/axiom_mime_body_part.h | 121 + axiom/src/attachments/data_handler.c | 572 ++ axiom/src/attachments/mime_body_part.c | 284 + axiom/src/attachments/mime_parser.c | 2304 +++++++ axiom/src/attachments/mime_part.c | 535 ++ axiom/src/om/Makefile.am | 35 + axiom/src/om/axiom_namespace_internal.h | 46 + axiom/src/om/axiom_node_internal.h | 165 + axiom/src/om/axiom_stax_builder_internal.h | 75 + axiom/src/om/om_attribute.c | 433 ++ axiom/src/om/om_child_element_iterator.c | 119 + axiom/src/om/om_children_iterator.c | 138 + axiom/src/om/om_children_qname_iterator.c | 190 + .../om_children_with_specific_attribute_iterator.c | 177 + axiom/src/om/om_comment.c | 142 + axiom/src/om/om_data_source.c | 133 + axiom/src/om/om_doctype.c | 131 + axiom/src/om/om_document.c | 263 + axiom/src/om/om_element.c | 1818 ++++++ axiom/src/om/om_namespace.c | 385 ++ axiom/src/om/om_navigator.c | 206 + axiom/src/om/om_node.c | 1455 +++++ axiom/src/om/om_output.c | 638 ++ axiom/src/om/om_processing_instruction.c | 187 + axiom/src/om/om_stax_builder.c | 1072 +++ axiom/src/om/om_text.c | 637 ++ axiom/src/parser/Makefile.am | 3 + axiom/src/parser/guththila/Makefile.am | 13 + .../guththila/guththila_xml_reader_wrapper.c | 613 ++ .../guththila/guththila_xml_writer_wrapper.c | 787 +++ axiom/src/parser/libxml2/Makefile.am | 17 + axiom/src/parser/libxml2/libxml2_reader_wrapper.c | 949 +++ axiom/src/parser/libxml2/libxml2_writer_wrapper.c | 1571 +++++ axiom/src/parser/xml_reader.c | 203 + axiom/src/parser/xml_writer.c | 337 + axiom/src/soap/Makefile.am | 33 + axiom/src/soap/_axiom_soap_body.h | 69 + axiom/src/soap/_axiom_soap_envelope.h | 84 + axiom/src/soap/_axiom_soap_fault.h | 105 + axiom/src/soap/_axiom_soap_fault_code.h | 91 + axiom/src/soap/_axiom_soap_fault_detail.h | 60 + axiom/src/soap/_axiom_soap_fault_node.h | 60 + axiom/src/soap/_axiom_soap_fault_reason.h | 87 + axiom/src/soap/_axiom_soap_fault_role.h | 60 + axiom/src/soap/_axiom_soap_fault_sub_code.h | 93 + axiom/src/soap/_axiom_soap_fault_text.h | 60 + axiom/src/soap/_axiom_soap_fault_value.h | 60 + axiom/src/soap/_axiom_soap_header.h | 77 + axiom/src/soap/_axiom_soap_header_block.h | 66 + axiom/src/soap/axiom_soap11_builder_helper.h | 71 + axiom/src/soap/axiom_soap12_builder_helper.h | 71 + axiom/src/soap/soap11_builder_helper.c | 340 + axiom/src/soap/soap12_builder_helper.c | 718 ++ axiom/src/soap/soap_body.c | 547 ++ axiom/src/soap/soap_builder.c | 1206 ++++ axiom/src/soap/soap_envelope.c | 631 ++ axiom/src/soap/soap_fault.c | 630 ++ axiom/src/soap/soap_fault_code.c | 308 + axiom/src/soap/soap_fault_detail.c | 160 + axiom/src/soap/soap_fault_node.c | 176 + axiom/src/soap/soap_fault_reason.c | 386 ++ axiom/src/soap/soap_fault_role.c | 180 + axiom/src/soap/soap_fault_sub_code.c | 298 + axiom/src/soap/soap_fault_text.c | 305 + axiom/src/soap/soap_fault_value.c | 237 + axiom/src/soap/soap_header.c | 655 ++ axiom/src/soap/soap_header_block.c | 460 ++ axiom/src/util/Makefile.am | 8 + axiom/src/util/om_util.c | 1181 ++++ axiom/src/xpath/Makefile.am | 22 + axiom/src/xpath/xpath.c | 462 ++ axiom/src/xpath/xpath_functions.c | 46 + axiom/src/xpath/xpath_functions.h | 47 + axiom/src/xpath/xpath_internals.c | 38 + axiom/src/xpath/xpath_internals.h | 199 + axiom/src/xpath/xpath_internals_engine.c | 1203 ++++ axiom/src/xpath/xpath_internals_engine.h | 265 + axiom/src/xpath/xpath_internals_iterators.c | 588 ++ axiom/src/xpath/xpath_internals_iterators.h | 298 + axiom/src/xpath/xpath_internals_parser.c | 1245 ++++ axiom/src/xpath/xpath_internals_parser.h | 421 ++ axiom/src/xpath/xpath_streaming.c | 213 + axiom/src/xpath/xpath_streaming.h | 126 + axiom/test/Makefile.am | 3 + axiom/test/om/Makefile.am | 13 + axiom/test/om/test_om.c | 402 ++ axiom/test/resources/wsdl/Attachment1.wsdl | 76 + axiom/test/resources/wsdl/AttachmentService.wsdl | 139 + axiom/test/resources/wsdl/AxisBench.wsdl | 108 + axiom/test/resources/wsdl/BasicAllTest.wsdl | 102 + axiom/test/resources/wsdl/BasicChoice.wsdl | 104 + axiom/test/resources/wsdl/Calculator.wsdl | 135 + axiom/test/resources/wsdl/CalculatorDoc.wsdl | 255 + axiom/test/resources/wsdl/Choice.wsdl | 104 + axiom/test/resources/wsdl/CombinedAllTest.wsdl | 109 + axiom/test/resources/wsdl/CombinedChoice.wsdl | 110 + axiom/test/resources/wsdl/ComplexLists.wsdl | 192 + axiom/test/resources/wsdl/ComplexTypeAll.wsdl | 81 + axiom/test/resources/wsdl/DIClientDoc.wsdl | 96 + axiom/test/resources/wsdl/DataHandlerService.wsdl | 291 + axiom/test/resources/wsdl/Enumeration.wsdl | 108 + axiom/test/resources/wsdl/ExceptionTest.wsdl | 97 + axiom/test/resources/wsdl/ExceptionTestDoc.wsdl | 160 + axiom/test/resources/wsdl/ExtensibilityQuery.wsdl | 154 + axiom/test/resources/wsdl/FaultMapping.wsdl | 97 + axiom/test/resources/wsdl/FaultMappingDoc.wsdl | 160 + axiom/test/resources/wsdl/FourLevelTestDoc.wsdl | 73 + axiom/test/resources/wsdl/InOut.wsdl | 429 ++ axiom/test/resources/wsdl/InteropTestRound1.wsdl | 333 + .../test/resources/wsdl/InteropTestRound1Doc.wsdl | 774 +++ .../test/resources/wsdl/LargeReturningString.wsdl | 95 + axiom/test/resources/wsdl/LimitedAllTest.wsdl | 103 + axiom/test/resources/wsdl/ManyTypeRefRoot.wsdl | 89 + axiom/test/resources/wsdl/MathOps.wsdl | 71 + axiom/test/resources/wsdl/MathOpsDoc.wsdl | 118 + axiom/test/resources/wsdl/MinOccurTest.wsdl | 107 + axiom/test/resources/wsdl/MultiOut.wsdl | 139 + axiom/test/resources/wsdl/NestedArrays.wsdl | 105 + axiom/test/resources/wsdl/NestedComplex.wsdl | 130 + axiom/test/resources/wsdl/NillableArrays.wsdl | 266 + axiom/test/resources/wsdl/OtherFaultException.wsdl | 97 + axiom/test/resources/wsdl/PlainTextAttachment.wsdl | 69 + axiom/test/resources/wsdl/PrimitiveAndArray.wsdl | 155 + axiom/test/resources/wsdl/RPCAllTest.wsdl | 101 + axiom/test/resources/wsdl/RecurseTypes.wsdl | 101 + axiom/test/resources/wsdl/RpcHttpHeaderTest1.wsdl | 333 + axiom/test/resources/wsdl/RpcHttpHeaderTest2.wsdl | 333 + axiom/test/resources/wsdl/RpcHttpHeaderTest3.wsdl | 333 + axiom/test/resources/wsdl/RpcHttpHeaderTest4.wsdl | 333 + axiom/test/resources/wsdl/RpcHttpHeaderTest5.wsdl | 333 + axiom/test/resources/wsdl/RpcHttpHeaderTest7.wsdl | 333 + axiom/test/resources/wsdl/RpcHttpHeaderTest8.wsdl | 333 + axiom/test/resources/wsdl/RpcSoapHeaderTest1.wsdl | 333 + axiom/test/resources/wsdl/RpcSoapHeaderTest10.wsdl | 333 + axiom/test/resources/wsdl/RpcSoapHeaderTest2.wsdl | 333 + axiom/test/resources/wsdl/RpcSoapHeaderTest3.wsdl | 333 + axiom/test/resources/wsdl/RpcSoapHeaderTest4.wsdl | 333 + axiom/test/resources/wsdl/RpcSoapHeaderTest6.wsdl | 333 + axiom/test/resources/wsdl/RpcSoapHeaderTest8.wsdl | 333 + axiom/test/resources/wsdl/RpcSoapHeaderTest9.wsdl | 333 + axiom/test/resources/wsdl/SimpleArray.wsdl | 64 + axiom/test/resources/wsdl/SimpleArrayDoc.wsdl | 85 + axiom/test/resources/wsdl/SimpleArrays.wsdl | 299 + axiom/test/resources/wsdl/SimpleChoice.wsdl | 104 + axiom/test/resources/wsdl/SimpleRef.wsdl | 114 + axiom/test/resources/wsdl/SimpleRefDoc.wsdl | 100 + axiom/test/resources/wsdl/SimpleTypeArray.wsdl | 75 + .../resources/wsdl/SimpleTypeInnerUnbounded.wsdl | 113 + .../wsdl/SimpleTypeInnerUnboundedInOutput.wsdl | 113 + axiom/test/resources/wsdl/StockQuotes.wsdl | 48 + .../test/resources/wsdl/TestTransportTimeout.wsdl | 255 + axiom/test/resources/wsdl/UDDI.wsdl | 32 + axiom/test/resources/wsdl/UnboundedChoice.wsdl | 104 + .../test/resources/wsdl/UnboundedStringChoice.wsdl | 104 + axiom/test/resources/wsdl/XSDAttribute.wsdl | 1046 +++ axiom/test/resources/wsdl/XSDElement.wsdl | 1422 ++++ axiom/test/resources/wsdl/XSDElementNil.wsdl | 1414 ++++ axiom/test/resources/wsdl/XSD_ENTITIES.wsdl | 285 + axiom/test/resources/wsdl/XSD_ENTITY.wsdl | 285 + axiom/test/resources/wsdl/XSD_ID.wsdl | 285 + axiom/test/resources/wsdl/XSD_IDREF.wsdl | 285 + axiom/test/resources/wsdl/XSD_IDREFS.wsdl | 285 + axiom/test/resources/wsdl/XSD_NCName.wsdl | 285 + axiom/test/resources/wsdl/XSD_NMTOKEN.wsdl | 285 + axiom/test/resources/wsdl/XSD_NMTOKENS.wsdl | 285 + axiom/test/resources/wsdl/XSD_NOTATION.wsdl | 285 + axiom/test/resources/wsdl/XSD_Name.wsdl | 285 + axiom/test/resources/wsdl/XSD_QName.wsdl | 285 + axiom/test/resources/wsdl/XSD_anyURI.wsdl | 285 + axiom/test/resources/wsdl/XSD_base64Binary.wsdl | 285 + axiom/test/resources/wsdl/XSD_boolean.wsdl | 285 + axiom/test/resources/wsdl/XSD_byte.wsdl | 285 + axiom/test/resources/wsdl/XSD_date.wsdl | 285 + axiom/test/resources/wsdl/XSD_dateTime.wsdl | 285 + axiom/test/resources/wsdl/XSD_decimal.wsdl | 285 + axiom/test/resources/wsdl/XSD_double.wsdl | 285 + axiom/test/resources/wsdl/XSD_duration.wsdl | 285 + axiom/test/resources/wsdl/XSD_float.wsdl | 285 + axiom/test/resources/wsdl/XSD_gDay.wsdl | 285 + axiom/test/resources/wsdl/XSD_gMonth.wsdl | 285 + axiom/test/resources/wsdl/XSD_gMonthDay.wsdl | 285 + axiom/test/resources/wsdl/XSD_gYear.wsdl | 285 + axiom/test/resources/wsdl/XSD_gYearMonth.wsdl | 285 + axiom/test/resources/wsdl/XSD_hexBinary.wsdl | 285 + axiom/test/resources/wsdl/XSD_int.wsdl | 285 + axiom/test/resources/wsdl/XSD_integer.wsdl | 285 + axiom/test/resources/wsdl/XSD_language.wsdl | 285 + axiom/test/resources/wsdl/XSD_long.wsdl | 285 + axiom/test/resources/wsdl/XSD_negativeInteger.wsdl | 285 + .../resources/wsdl/XSD_nonNegativeInteger.wsdl | 285 + .../resources/wsdl/XSD_nonPositiveInteger.wsdl | 285 + .../test/resources/wsdl/XSD_normalizedString.wsdl | 285 + axiom/test/resources/wsdl/XSD_positiveInteger.wsdl | 285 + axiom/test/resources/wsdl/XSD_short.wsdl | 285 + axiom/test/resources/wsdl/XSD_string.wsdl | 285 + axiom/test/resources/wsdl/XSD_time.wsdl | 285 + axiom/test/resources/wsdl/XSD_token.wsdl | 285 + axiom/test/resources/wsdl/XSD_unsignedByte.wsdl | 285 + axiom/test/resources/wsdl/XSD_unsignedInt.wsdl | 285 + axiom/test/resources/wsdl/XSD_unsignedLong.wsdl | 285 + axiom/test/resources/wsdl/XSD_unsignedShort.wsdl | 285 + axiom/test/resources/wsdl/inquire_v2.wsdl | 275 + axiom/test/resources/wsdl/nillableComplexType.wsdl | 78 + axiom/test/resources/wsdl/nillableComplexType.xsd | 26 + axiom/test/resources/wsdl/wsaTestService.wsdl | 53 + axiom/test/resources/xml/om/axis.xml | 25 + axiom/test/resources/xml/om/basic.xml | 11 + axiom/test/resources/xml/om/basicupdate.xml | 47 + axiom/test/resources/xml/om/contents.xml | 70 + axiom/test/resources/xml/om/defaultNamespace.xml | 6 + axiom/test/resources/xml/om/evaluate.xml | 28 + axiom/test/resources/xml/om/fibo.xml | 29 + axiom/test/resources/xml/om/id.xml | 21 + axiom/test/resources/xml/om/jaxen24.xml | 2 + axiom/test/resources/xml/om/jaxen3.xml | 15 + axiom/test/resources/xml/om/lang.xml | 11 + axiom/test/resources/xml/om/message.xml | 27 + axiom/test/resources/xml/om/moreover.xml | 244 + axiom/test/resources/xml/om/much_ado.xml | 6850 ++++++++++++++++++++ axiom/test/resources/xml/om/namespaces.xml | 18 + axiom/test/resources/xml/om/nitf.xml | 67 + axiom/test/resources/xml/om/numbers.xml | 18 + axiom/test/resources/xml/om/pi.xml | 13 + axiom/test/resources/xml/om/pi2.xml | 6 + axiom/test/resources/xml/om/simple.xml | 2 + axiom/test/resources/xml/om/spaces.xml | 10 + axiom/test/resources/xml/om/test.xml | 12 + axiom/test/resources/xml/om/testNamespaces.xml | 22 + axiom/test/resources/xml/om/underscore.xml | 6 + axiom/test/resources/xml/om/web.xml | 42 + axiom/test/resources/xml/om/web2.xml | 7 + axiom/test/resources/xml/soap/OMElementTest.xml | 22 + .../xml/soap/badsoap/bodyNotQualified.xml | 19 + .../resources/xml/soap/badsoap/envelopeMissing.xml | 20 + .../xml/soap/badsoap/haederBodyWrongOrder.xml | 20 + .../xml/soap/badsoap/notnamespaceQualified.xml | 15 + .../resources/xml/soap/badsoap/twoBodymessage.xml | 24 + .../test/resources/xml/soap/badsoap/twoheaders.xml | 29 + .../resources/xml/soap/badsoap/wrongSoapNs.xml | 20 + axiom/test/resources/xml/soap/emtyBodymessage.xml | 18 + .../xml/soap/invalidMustUnderstandSOAP12.xml | 13 + axiom/test/resources/xml/soap/minimalMessage.xml | 4 + .../resources/xml/soap/reallyReallyBigMessage.xml | 2529 ++++++++ axiom/test/resources/xml/soap/sample1.txt | 12 + axiom/test/resources/xml/soap/sample1.xml | 9 + axiom/test/resources/xml/soap/security2-soap.xml | 54 + .../test/resources/xml/soap/soap11/soap11fault.xml | 16 + .../resources/xml/soap/soap11/soap11message.xml | 46 + axiom/test/resources/xml/soap/soap12message.xml | 58 + axiom/test/resources/xml/soap/soapmessage.txt | 16 + axiom/test/resources/xml/soap/soapmessage.xml | 20 + axiom/test/resources/xml/soap/soapmessage1.xml | 27 + axiom/test/resources/xml/soap/test.xml | 59 + .../test/resources/xml/soap/whitespacedMessage.xml | 27 + .../resources/xml/soap/wrongEnvelopeNamespace.xml | 12 + axiom/test/soap/Makefile.am | 13 + axiom/test/soap/test_soap.c | 550 ++ axiom/test/util/Makefile.am | 8 + axiom/test/util/axiom_util_test.c | 168 + axiom/test/util/build.sh | 2 + axiom/test/util/test.xml | 7 + axiom/test/xpath/Makefile.am | 20 + axiom/test/xpath/results.txt | 616 ++ axiom/test/xpath/test.ns | 2 + axiom/test/xpath/test.xml | 55 + axiom/test/xpath/test.xpath | 37 + axiom/test/xpath/test_xpath.c | 513 ++ axiom/test/xpath/test_xpath_streaming.c | 468 ++ 328 files changed, 84884 insertions(+) create mode 100644 axiom/AUTHORS create mode 100644 axiom/COPYING create mode 100644 axiom/CREDITS create mode 100644 axiom/ChangeLog create mode 100644 axiom/INSTALL create mode 100644 axiom/LICENSE create mode 100644 axiom/Makefile.am create mode 100644 axiom/NEWS create mode 100644 axiom/README create mode 100755 axiom/autogen.sh create mode 100755 axiom/build.sh create mode 100644 axiom/configure.ac create mode 100644 axiom/include/Makefile.am create mode 100644 axiom/include/axiom.h create mode 100644 axiom/include/axiom_attribute.h create mode 100644 axiom/include/axiom_child_element_iterator.h create mode 100644 axiom/include/axiom_children_iterator.h create mode 100644 axiom/include/axiom_children_qname_iterator.h create mode 100644 axiom/include/axiom_children_with_specific_attribute_iterator.h create mode 100644 axiom/include/axiom_comment.h create mode 100644 axiom/include/axiom_data_handler.h create mode 100644 axiom/include/axiom_data_source.h create mode 100644 axiom/include/axiom_defines.h create mode 100644 axiom/include/axiom_doctype.h create mode 100644 axiom/include/axiom_document.h create mode 100644 axiom/include/axiom_element.h create mode 100644 axiom/include/axiom_mime_const.h create mode 100644 axiom/include/axiom_mime_parser.h create mode 100644 axiom/include/axiom_mime_part.h create mode 100644 axiom/include/axiom_mtom_caching_callback.h create mode 100644 axiom/include/axiom_mtom_sending_callback.h create mode 100644 axiom/include/axiom_namespace.h create mode 100644 axiom/include/axiom_navigator.h create mode 100644 axiom/include/axiom_node.h create mode 100644 axiom/include/axiom_output.h create mode 100644 axiom/include/axiom_processing_instruction.h create mode 100644 axiom/include/axiom_soap.h create mode 100644 axiom/include/axiom_soap_body.h create mode 100644 axiom/include/axiom_soap_builder.h create mode 100644 axiom/include/axiom_soap_const.h create mode 100644 axiom/include/axiom_soap_envelope.h create mode 100644 axiom/include/axiom_soap_fault.h create mode 100644 axiom/include/axiom_soap_fault_code.h create mode 100644 axiom/include/axiom_soap_fault_detail.h create mode 100644 axiom/include/axiom_soap_fault_node.h create mode 100644 axiom/include/axiom_soap_fault_reason.h create mode 100644 axiom/include/axiom_soap_fault_role.h create mode 100644 axiom/include/axiom_soap_fault_sub_code.h create mode 100644 axiom/include/axiom_soap_fault_text.h create mode 100644 axiom/include/axiom_soap_fault_value.h create mode 100644 axiom/include/axiom_soap_header.h create mode 100644 axiom/include/axiom_soap_header_block.h create mode 100644 axiom/include/axiom_stax_builder.h create mode 100644 axiom/include/axiom_text.h create mode 100644 axiom/include/axiom_util.h create mode 100644 axiom/include/axiom_xml_reader.h create mode 100644 axiom/include/axiom_xml_writer.h create mode 100644 axiom/include/axiom_xpath.h create mode 100644 axiom/src/Makefile.am create mode 100644 axiom/src/attachments/Makefile.am create mode 100644 axiom/src/attachments/axiom_mime_body_part.h create mode 100644 axiom/src/attachments/data_handler.c create mode 100644 axiom/src/attachments/mime_body_part.c create mode 100644 axiom/src/attachments/mime_parser.c create mode 100644 axiom/src/attachments/mime_part.c create mode 100644 axiom/src/om/Makefile.am create mode 100644 axiom/src/om/axiom_namespace_internal.h create mode 100644 axiom/src/om/axiom_node_internal.h create mode 100644 axiom/src/om/axiom_stax_builder_internal.h create mode 100644 axiom/src/om/om_attribute.c create mode 100644 axiom/src/om/om_child_element_iterator.c create mode 100644 axiom/src/om/om_children_iterator.c create mode 100644 axiom/src/om/om_children_qname_iterator.c create mode 100644 axiom/src/om/om_children_with_specific_attribute_iterator.c create mode 100644 axiom/src/om/om_comment.c create mode 100644 axiom/src/om/om_data_source.c create mode 100644 axiom/src/om/om_doctype.c create mode 100644 axiom/src/om/om_document.c create mode 100644 axiom/src/om/om_element.c create mode 100644 axiom/src/om/om_namespace.c create mode 100644 axiom/src/om/om_navigator.c create mode 100644 axiom/src/om/om_node.c create mode 100644 axiom/src/om/om_output.c create mode 100644 axiom/src/om/om_processing_instruction.c create mode 100644 axiom/src/om/om_stax_builder.c create mode 100644 axiom/src/om/om_text.c create mode 100644 axiom/src/parser/Makefile.am create mode 100644 axiom/src/parser/guththila/Makefile.am create mode 100644 axiom/src/parser/guththila/guththila_xml_reader_wrapper.c create mode 100644 axiom/src/parser/guththila/guththila_xml_writer_wrapper.c create mode 100644 axiom/src/parser/libxml2/Makefile.am create mode 100644 axiom/src/parser/libxml2/libxml2_reader_wrapper.c create mode 100644 axiom/src/parser/libxml2/libxml2_writer_wrapper.c create mode 100644 axiom/src/parser/xml_reader.c create mode 100644 axiom/src/parser/xml_writer.c create mode 100644 axiom/src/soap/Makefile.am create mode 100644 axiom/src/soap/_axiom_soap_body.h create mode 100644 axiom/src/soap/_axiom_soap_envelope.h create mode 100644 axiom/src/soap/_axiom_soap_fault.h create mode 100644 axiom/src/soap/_axiom_soap_fault_code.h create mode 100644 axiom/src/soap/_axiom_soap_fault_detail.h create mode 100644 axiom/src/soap/_axiom_soap_fault_node.h create mode 100644 axiom/src/soap/_axiom_soap_fault_reason.h create mode 100644 axiom/src/soap/_axiom_soap_fault_role.h create mode 100644 axiom/src/soap/_axiom_soap_fault_sub_code.h create mode 100644 axiom/src/soap/_axiom_soap_fault_text.h create mode 100644 axiom/src/soap/_axiom_soap_fault_value.h create mode 100644 axiom/src/soap/_axiom_soap_header.h create mode 100644 axiom/src/soap/_axiom_soap_header_block.h create mode 100644 axiom/src/soap/axiom_soap11_builder_helper.h create mode 100644 axiom/src/soap/axiom_soap12_builder_helper.h create mode 100644 axiom/src/soap/soap11_builder_helper.c create mode 100644 axiom/src/soap/soap12_builder_helper.c create mode 100644 axiom/src/soap/soap_body.c create mode 100644 axiom/src/soap/soap_builder.c create mode 100644 axiom/src/soap/soap_envelope.c create mode 100644 axiom/src/soap/soap_fault.c create mode 100644 axiom/src/soap/soap_fault_code.c create mode 100644 axiom/src/soap/soap_fault_detail.c create mode 100644 axiom/src/soap/soap_fault_node.c create mode 100644 axiom/src/soap/soap_fault_reason.c create mode 100644 axiom/src/soap/soap_fault_role.c create mode 100644 axiom/src/soap/soap_fault_sub_code.c create mode 100644 axiom/src/soap/soap_fault_text.c create mode 100644 axiom/src/soap/soap_fault_value.c create mode 100644 axiom/src/soap/soap_header.c create mode 100644 axiom/src/soap/soap_header_block.c create mode 100644 axiom/src/util/Makefile.am create mode 100644 axiom/src/util/om_util.c create mode 100644 axiom/src/xpath/Makefile.am create mode 100755 axiom/src/xpath/xpath.c create mode 100755 axiom/src/xpath/xpath_functions.c create mode 100755 axiom/src/xpath/xpath_functions.h create mode 100755 axiom/src/xpath/xpath_internals.c create mode 100755 axiom/src/xpath/xpath_internals.h create mode 100644 axiom/src/xpath/xpath_internals_engine.c create mode 100755 axiom/src/xpath/xpath_internals_engine.h create mode 100644 axiom/src/xpath/xpath_internals_iterators.c create mode 100755 axiom/src/xpath/xpath_internals_iterators.h create mode 100755 axiom/src/xpath/xpath_internals_parser.c create mode 100755 axiom/src/xpath/xpath_internals_parser.h create mode 100755 axiom/src/xpath/xpath_streaming.c create mode 100755 axiom/src/xpath/xpath_streaming.h create mode 100644 axiom/test/Makefile.am create mode 100644 axiom/test/om/Makefile.am create mode 100644 axiom/test/om/test_om.c create mode 100644 axiom/test/resources/wsdl/Attachment1.wsdl create mode 100644 axiom/test/resources/wsdl/AttachmentService.wsdl create mode 100644 axiom/test/resources/wsdl/AxisBench.wsdl create mode 100644 axiom/test/resources/wsdl/BasicAllTest.wsdl create mode 100644 axiom/test/resources/wsdl/BasicChoice.wsdl create mode 100644 axiom/test/resources/wsdl/Calculator.wsdl create mode 100644 axiom/test/resources/wsdl/CalculatorDoc.wsdl create mode 100644 axiom/test/resources/wsdl/Choice.wsdl create mode 100644 axiom/test/resources/wsdl/CombinedAllTest.wsdl create mode 100644 axiom/test/resources/wsdl/CombinedChoice.wsdl create mode 100644 axiom/test/resources/wsdl/ComplexLists.wsdl create mode 100644 axiom/test/resources/wsdl/ComplexTypeAll.wsdl create mode 100644 axiom/test/resources/wsdl/DIClientDoc.wsdl create mode 100644 axiom/test/resources/wsdl/DataHandlerService.wsdl create mode 100644 axiom/test/resources/wsdl/Enumeration.wsdl create mode 100644 axiom/test/resources/wsdl/ExceptionTest.wsdl create mode 100644 axiom/test/resources/wsdl/ExceptionTestDoc.wsdl create mode 100644 axiom/test/resources/wsdl/ExtensibilityQuery.wsdl create mode 100644 axiom/test/resources/wsdl/FaultMapping.wsdl create mode 100644 axiom/test/resources/wsdl/FaultMappingDoc.wsdl create mode 100644 axiom/test/resources/wsdl/FourLevelTestDoc.wsdl create mode 100644 axiom/test/resources/wsdl/InOut.wsdl create mode 100644 axiom/test/resources/wsdl/InteropTestRound1.wsdl create mode 100644 axiom/test/resources/wsdl/InteropTestRound1Doc.wsdl create mode 100644 axiom/test/resources/wsdl/LargeReturningString.wsdl create mode 100644 axiom/test/resources/wsdl/LimitedAllTest.wsdl create mode 100644 axiom/test/resources/wsdl/ManyTypeRefRoot.wsdl create mode 100644 axiom/test/resources/wsdl/MathOps.wsdl create mode 100644 axiom/test/resources/wsdl/MathOpsDoc.wsdl create mode 100644 axiom/test/resources/wsdl/MinOccurTest.wsdl create mode 100644 axiom/test/resources/wsdl/MultiOut.wsdl create mode 100644 axiom/test/resources/wsdl/NestedArrays.wsdl create mode 100644 axiom/test/resources/wsdl/NestedComplex.wsdl create mode 100644 axiom/test/resources/wsdl/NillableArrays.wsdl create mode 100644 axiom/test/resources/wsdl/OtherFaultException.wsdl create mode 100644 axiom/test/resources/wsdl/PlainTextAttachment.wsdl create mode 100644 axiom/test/resources/wsdl/PrimitiveAndArray.wsdl create mode 100644 axiom/test/resources/wsdl/RPCAllTest.wsdl create mode 100644 axiom/test/resources/wsdl/RecurseTypes.wsdl create mode 100644 axiom/test/resources/wsdl/RpcHttpHeaderTest1.wsdl create mode 100644 axiom/test/resources/wsdl/RpcHttpHeaderTest2.wsdl create mode 100644 axiom/test/resources/wsdl/RpcHttpHeaderTest3.wsdl create mode 100644 axiom/test/resources/wsdl/RpcHttpHeaderTest4.wsdl create mode 100644 axiom/test/resources/wsdl/RpcHttpHeaderTest5.wsdl create mode 100644 axiom/test/resources/wsdl/RpcHttpHeaderTest7.wsdl create mode 100644 axiom/test/resources/wsdl/RpcHttpHeaderTest8.wsdl create mode 100644 axiom/test/resources/wsdl/RpcSoapHeaderTest1.wsdl create mode 100644 axiom/test/resources/wsdl/RpcSoapHeaderTest10.wsdl create mode 100644 axiom/test/resources/wsdl/RpcSoapHeaderTest2.wsdl create mode 100644 axiom/test/resources/wsdl/RpcSoapHeaderTest3.wsdl create mode 100644 axiom/test/resources/wsdl/RpcSoapHeaderTest4.wsdl create mode 100644 axiom/test/resources/wsdl/RpcSoapHeaderTest6.wsdl create mode 100644 axiom/test/resources/wsdl/RpcSoapHeaderTest8.wsdl create mode 100644 axiom/test/resources/wsdl/RpcSoapHeaderTest9.wsdl create mode 100644 axiom/test/resources/wsdl/SimpleArray.wsdl create mode 100644 axiom/test/resources/wsdl/SimpleArrayDoc.wsdl create mode 100644 axiom/test/resources/wsdl/SimpleArrays.wsdl create mode 100644 axiom/test/resources/wsdl/SimpleChoice.wsdl create mode 100644 axiom/test/resources/wsdl/SimpleRef.wsdl create mode 100644 axiom/test/resources/wsdl/SimpleRefDoc.wsdl create mode 100644 axiom/test/resources/wsdl/SimpleTypeArray.wsdl create mode 100644 axiom/test/resources/wsdl/SimpleTypeInnerUnbounded.wsdl create mode 100644 axiom/test/resources/wsdl/SimpleTypeInnerUnboundedInOutput.wsdl create mode 100644 axiom/test/resources/wsdl/StockQuotes.wsdl create mode 100644 axiom/test/resources/wsdl/TestTransportTimeout.wsdl create mode 100644 axiom/test/resources/wsdl/UDDI.wsdl create mode 100644 axiom/test/resources/wsdl/UnboundedChoice.wsdl create mode 100644 axiom/test/resources/wsdl/UnboundedStringChoice.wsdl create mode 100644 axiom/test/resources/wsdl/XSDAttribute.wsdl create mode 100644 axiom/test/resources/wsdl/XSDElement.wsdl create mode 100644 axiom/test/resources/wsdl/XSDElementNil.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_ENTITIES.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_ENTITY.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_ID.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_IDREF.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_IDREFS.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_NCName.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_NMTOKEN.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_NMTOKENS.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_NOTATION.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_Name.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_QName.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_anyURI.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_base64Binary.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_boolean.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_byte.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_date.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_dateTime.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_decimal.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_double.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_duration.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_float.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_gDay.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_gMonth.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_gMonthDay.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_gYear.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_gYearMonth.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_hexBinary.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_int.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_integer.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_language.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_long.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_negativeInteger.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_nonNegativeInteger.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_nonPositiveInteger.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_normalizedString.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_positiveInteger.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_short.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_string.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_time.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_token.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_unsignedByte.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_unsignedInt.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_unsignedLong.wsdl create mode 100644 axiom/test/resources/wsdl/XSD_unsignedShort.wsdl create mode 100644 axiom/test/resources/wsdl/inquire_v2.wsdl create mode 100644 axiom/test/resources/wsdl/nillableComplexType.wsdl create mode 100644 axiom/test/resources/wsdl/nillableComplexType.xsd create mode 100644 axiom/test/resources/wsdl/wsaTestService.wsdl create mode 100644 axiom/test/resources/xml/om/axis.xml create mode 100644 axiom/test/resources/xml/om/basic.xml create mode 100644 axiom/test/resources/xml/om/basicupdate.xml create mode 100644 axiom/test/resources/xml/om/contents.xml create mode 100644 axiom/test/resources/xml/om/defaultNamespace.xml create mode 100644 axiom/test/resources/xml/om/evaluate.xml create mode 100644 axiom/test/resources/xml/om/fibo.xml create mode 100644 axiom/test/resources/xml/om/id.xml create mode 100644 axiom/test/resources/xml/om/jaxen24.xml create mode 100644 axiom/test/resources/xml/om/jaxen3.xml create mode 100644 axiom/test/resources/xml/om/lang.xml create mode 100644 axiom/test/resources/xml/om/message.xml create mode 100644 axiom/test/resources/xml/om/moreover.xml create mode 100644 axiom/test/resources/xml/om/much_ado.xml create mode 100644 axiom/test/resources/xml/om/namespaces.xml create mode 100644 axiom/test/resources/xml/om/nitf.xml create mode 100644 axiom/test/resources/xml/om/numbers.xml create mode 100644 axiom/test/resources/xml/om/pi.xml create mode 100644 axiom/test/resources/xml/om/pi2.xml create mode 100644 axiom/test/resources/xml/om/simple.xml create mode 100644 axiom/test/resources/xml/om/spaces.xml create mode 100644 axiom/test/resources/xml/om/test.xml create mode 100644 axiom/test/resources/xml/om/testNamespaces.xml create mode 100644 axiom/test/resources/xml/om/underscore.xml create mode 100644 axiom/test/resources/xml/om/web.xml create mode 100644 axiom/test/resources/xml/om/web2.xml create mode 100644 axiom/test/resources/xml/soap/OMElementTest.xml create mode 100644 axiom/test/resources/xml/soap/badsoap/bodyNotQualified.xml create mode 100644 axiom/test/resources/xml/soap/badsoap/envelopeMissing.xml create mode 100644 axiom/test/resources/xml/soap/badsoap/haederBodyWrongOrder.xml create mode 100644 axiom/test/resources/xml/soap/badsoap/notnamespaceQualified.xml create mode 100644 axiom/test/resources/xml/soap/badsoap/twoBodymessage.xml create mode 100644 axiom/test/resources/xml/soap/badsoap/twoheaders.xml create mode 100644 axiom/test/resources/xml/soap/badsoap/wrongSoapNs.xml create mode 100644 axiom/test/resources/xml/soap/emtyBodymessage.xml create mode 100644 axiom/test/resources/xml/soap/invalidMustUnderstandSOAP12.xml create mode 100644 axiom/test/resources/xml/soap/minimalMessage.xml create mode 100644 axiom/test/resources/xml/soap/reallyReallyBigMessage.xml create mode 100644 axiom/test/resources/xml/soap/sample1.txt create mode 100644 axiom/test/resources/xml/soap/sample1.xml create mode 100644 axiom/test/resources/xml/soap/security2-soap.xml create mode 100644 axiom/test/resources/xml/soap/soap11/soap11fault.xml create mode 100644 axiom/test/resources/xml/soap/soap11/soap11message.xml create mode 100644 axiom/test/resources/xml/soap/soap12message.xml create mode 100644 axiom/test/resources/xml/soap/soapmessage.txt create mode 100644 axiom/test/resources/xml/soap/soapmessage.xml create mode 100644 axiom/test/resources/xml/soap/soapmessage1.xml create mode 100644 axiom/test/resources/xml/soap/test.xml create mode 100644 axiom/test/resources/xml/soap/whitespacedMessage.xml create mode 100644 axiom/test/resources/xml/soap/wrongEnvelopeNamespace.xml create mode 100644 axiom/test/soap/Makefile.am create mode 100644 axiom/test/soap/test_soap.c create mode 100644 axiom/test/util/Makefile.am create mode 100644 axiom/test/util/axiom_util_test.c create mode 100644 axiom/test/util/build.sh create mode 100644 axiom/test/util/test.xml create mode 100644 axiom/test/xpath/Makefile.am create mode 100644 axiom/test/xpath/results.txt create mode 100644 axiom/test/xpath/test.ns create mode 100644 axiom/test/xpath/test.xml create mode 100644 axiom/test/xpath/test.xpath create mode 100644 axiom/test/xpath/test_xpath.c create mode 100644 axiom/test/xpath/test_xpath_streaming.c (limited to 'axiom') diff --git a/axiom/AUTHORS b/axiom/AUTHORS new file mode 100644 index 0000000..e69de29 diff --git a/axiom/COPYING b/axiom/COPYING new file mode 100644 index 0000000..6b0b127 --- /dev/null +++ b/axiom/COPYING @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/axiom/CREDITS b/axiom/CREDITS new file mode 100644 index 0000000..e69de29 diff --git a/axiom/ChangeLog b/axiom/ChangeLog new file mode 100644 index 0000000..0bd857b --- /dev/null +++ b/axiom/ChangeLog @@ -0,0 +1,6 @@ +Apache Axiom/C + + * Seperated Axiom module from Axis2/C + +-- Axis2-C team Thu, 18 May 2006 + diff --git a/axiom/INSTALL b/axiom/INSTALL new file mode 100644 index 0000000..9406038 --- /dev/null +++ b/axiom/INSTALL @@ -0,0 +1,14 @@ +Getting Axiom/C source working on Linux +============================================= +Build the source +This can be done using the following command sequence: + ./configure + make + make install + use './configure --help' for options + +NOTE: If you don't provide a --prefix configure option, it will by default +install into /usr/local/axis2_axiom directory. + + + diff --git a/axiom/LICENSE b/axiom/LICENSE new file mode 100644 index 0000000..6b0b127 --- /dev/null +++ b/axiom/LICENSE @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/axiom/Makefile.am b/axiom/Makefile.am new file mode 100644 index 0000000..a468a0c --- /dev/null +++ b/axiom/Makefile.am @@ -0,0 +1,9 @@ +datadir=$(prefix) +SUBDIRS = src $(TESTDIR) include +includedir=$(prefix)/include/axis2-1.6.0/ +include_HEADERS=$(top_builddir)/include/*.h +data_DATA= INSTALL README AUTHORS NEWS CREDITS LICENSE COPYING +EXTRA_DIST = build.sh autogen.sh CREDITS LICENSE +dist-hook: + rm -rf `find $(distdir)/ -type d -name .svn` + rm -rf `find $(distdir)/ -type d -name .deps` diff --git a/axiom/NEWS b/axiom/NEWS new file mode 100644 index 0000000..268572f --- /dev/null +++ b/axiom/NEWS @@ -0,0 +1,7 @@ +Axiom module seperated from Axis2/C +====================================== +Initially this was inside Axis2/C code base as axiom directory. As the +project expands it's moved to the top level with the view of making it a +seperate Apache project called Apache Axiom/C. + +-- Axis2-C team Thu, 18 May 2006 diff --git a/axiom/README b/axiom/README new file mode 100644 index 0000000..0b442a7 --- /dev/null +++ b/axiom/README @@ -0,0 +1,57 @@ + + Apache Axiom/C + ================ + + What is it? + ----------- + + Axiom stands for AXis Object Model (also known as OM - Object Model) and + refers to the XML infoset model that is initially developed for Apache + Axis2. This is an effort to implement Apache Axiom in C. + + Please have a look at http://ws.apache.org/axis2/c/docs/om_tutorial.html + for an introduction about Apache Axiom/C. + + As a project of the Apache Software Foundation, the + developers aim to collaboratively develop and maintain a robust, + commercial-grade, standards-based Web Services stack implementation with + freely available source code. + + The Latest Version + ------------------ + + You can get the latest svn checkout of Apache Axiom/C module from + + https://svn.apache.org/repos/asf/webservices/axis2/trunk/c/axiom + + Installation + ------------ + + Please see the file called INSTALL. + + Licensing + --------- + + Please see the file called LICENSE. + + Contacts + -------- + + o If you want freely available support for using Apache Axiom/C please + join the Apache Axis2/C user community by subscribing to users mailing + list, axis-c-user@ws.apache.org' as described at + http://ws.apache.org/axis2/c/mail-lists.html + + o If you have a bug report for Apache Axis2/C Guththila please log-in and create a JIRA issue + at http://issues.apache.org/jira/browse/AXIS2C + + o If you want to participate actively in developing Apache Axis2/C Guththila please + subscribe to the `axis-c-dev@ws.apache.org' mailing list as described at + http://ws.apache.org/axis2/c/mail-lists.html + + + Acknowledgments + ---------------- + + Apache Axiom/C relies heavily on the use of autoconf, automake and libtool + to provide a build environment. diff --git a/axiom/autogen.sh b/axiom/autogen.sh new file mode 100755 index 0000000..3862edc --- /dev/null +++ b/axiom/autogen.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +echo -n 'Running libtoolize...' +if [ `uname -s` = Darwin ] +then + LIBTOOLIZE=glibtoolize +else + LIBTOOLIZE=libtoolize +fi + +if $LIBTOOLIZE --force > /dev/null 2>&1; then + echo 'done.' +else + echo 'failed.' + exit 1 +fi + +echo -n 'Running aclocal...' +if aclocal > /dev/null 2>&1; then + echo 'done.' +else + echo 'failed.' + exit 1 +fi + +echo -n 'Running autoheader...' +if autoheader > /dev/null 2>&1; then + echo 'done.' +else + echo 'failed.' + exit 1 +fi + +echo -n 'Running autoconf...' +if autoconf > /dev/null 2>&1; then + echo 'done.' +else + echo 'failed.' + exit 1 +fi + +echo -n 'Running automake...' +if automake --add-missing > /dev/null 2>&1; then + echo 'done.' +else + echo 'failed.' + exit 1 +fi + +echo 'done' diff --git a/axiom/build.sh b/axiom/build.sh new file mode 100755 index 0000000..d39c3e7 --- /dev/null +++ b/axiom/build.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +./autogen.sh +./configure --prefix=${AXIS2C_HOME} --enable-static=no --enable-tests=no +make +make install + diff --git a/axiom/configure.ac b/axiom/configure.ac new file mode 100644 index 0000000..6802fb9 --- /dev/null +++ b/axiom/configure.ac @@ -0,0 +1,179 @@ +dnl run autogen.sh to generate the configure script. + +AC_PREREQ(2.59) + +AC_INIT(axis2_axiom-src, 1.6.0) +AC_CANONICAL_SYSTEM +AM_CONFIG_HEADER(config.h) +AM_INIT_AUTOMAKE +AC_PREFIX_DEFAULT(/usr/local/axis2_axiom) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_CXX +AC_PROG_CPP +AC_PROG_LIBTOOL +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MAKE_SET + +dnl check for flavours of varargs macros (test from GLib) +AC_MSG_CHECKING(for ISO C99 varargs macros in C) +AC_TRY_COMPILE([],[ +int a(int p1, int p2, int p3); +#define call_a(...) a(1,__VA_ARGS__) +call_a(2,3); +],axis2c_have_iso_c_varargs=yes,axis2c_have_iso_c_varargs=no) +AC_MSG_RESULT($axis2c_have_iso_c_varargs) + +AC_MSG_CHECKING(for GNUC varargs macros) +AC_TRY_COMPILE([],[ +int a(int p1, int p2, int p3); +#define call_a(params...) a(1,params) +call_a(2,3); +],axis2c_have_gnuc_varargs=yes,axis2c_have_gnuc_varargs=no) +AC_MSG_RESULT($axis2c_have_gnuc_varargs) + +dnl Output varargs tests +if test x$axis2c_have_iso_c_varargs = xyes; then + AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros]) +fi +if test x$axis2c_have_gnuc_varargs = xyes; then + AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros]) +fi + +dnl Checks for libraries. +AC_CHECK_LIB(dl, dlopen) +AC_CHECK_LIB(z, inflate) + +#CFLAGS="$CFLAGS -ansi -Wall -D_LARGEFILE64_SOURCE -Wno-implicit-function-declaration" +CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE" +if test "$GCC" = "yes"; then + CFLAGS="$CFLAGS -ansi -Werror -Wall -Wno-implicit-function-declaration " +fi + + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([stdio.h stdlib.h string.h]) +AC_CHECK_HEADERS([sys/socket.h]) +AC_CHECK_HEADERS([linux/if.h],[],[], +[ +#if HAVE_SYS_SOCKET_H +# include +#endif +]) + +dnl This is a check to see if we are running MacOS X +dnl It may be better to do a Darwin check +AC_CHECK_HEADER([sys/appleapiopts.h], + [AC_DEFINE([IS_MACOSX],[1],[Define to 1 if compiling on MacOS X])], + []) + +dnl Checks for typedefs, structures, and compiler characteristics. +dnl AC_C_CONST + +dnl Checks for library functions. +dnl AC_FUNC_MALLOC +dnl AC_FUNC_REALLOC +#AC_CHECK_FUNCS([memmove]) + +AC_MSG_CHECKING(whether to build xpath) +AC_ARG_ENABLE(xpath, [ --enable-xpath build xpath. default=yes], +[ case "${enableval}" in + no) + AC_MSG_RESULT(no) + ;; + *) + AC_MSG_RESULT(yes) + XPATH_DIR="xpath" + + ;; + esac ], + AC_MSG_RESULT(yes) + XPATH_DIR="xpath" +) + + +AC_MSG_CHECKING(whether to build guththila xml parser library) +AC_ARG_ENABLE(guththila, [ --enable-guththila build guththila xml parser library wrapper. default=yes], +[ case "${enableval}" in + no) + AC_MSG_RESULT(no) + ;; + *) + AC_MSG_RESULT(yes) + WRAPPER_DIR="guththila" + + ;; + esac ], + AC_MSG_RESULT(yes) + WRAPPER_DIR="guththila" +) + +AC_MSG_CHECKING(whether to build libxml2 xml parser library) +AC_ARG_ENABLE(libxml2, [ --enable-libxml2 build libxml2 xml parser library wrapper. default=no], +[ case "${enableval}" in + no) + AC_MSG_RESULT(no) + ;; + *) + AC_MSG_RESULT(yes) + CFLAGS="$CFLAGS -DAXIS2_LIBXML2_ENABLED" + WRAPPER_DIR="libxml2" + PKG_CHECK_MODULES(LIBXML2, libxml-2.0) + + ;; + esac ], + AC_MSG_RESULT(no) +) + + +AC_MSG_CHECKING(whether to build tests) +AC_ARG_ENABLE(tests, [ --enable-tests build tests. default=no], +[ case "${enableval}" in + yes) + AC_MSG_RESULT(yes) + TESTDIR="test" + ;; + *) + AC_MSG_RESULT(no) + TESTDIR="" + + ;; + esac ], + AC_MSG_RESULT(no) + TESTDIR="" +) + +PKG_PROG_PKG_CONFIG(0.15) +CFLAGS="$CFLAGS $GUTHTHILA_CFLAGS" +VERSION_NO="6:0:6" + +AC_SUBST(VERSION_NO) +AC_SUBST(LIBXML2_CFLAGS) +AC_SUBST(LIBXML2_LIBS) +AC_SUBST(WRAPPER_DIR) +AC_SUBST(GUTHTHILA_LIBS) +AC_SUBST(TESTDIR) +AC_SUBST(XPATH_DIR) + +AC_CONFIG_FILES([Makefile \ + src/Makefile \ + src/parser/Makefile \ + src/parser/libxml2/Makefile \ + src/parser/guththila/Makefile \ + src/soap/Makefile \ + src/om/Makefile \ + src/util/Makefile \ + src/attachments/Makefile \ + src/xpath/Makefile \ + test/Makefile \ + test/om/Makefile \ + test/soap/Makefile \ + test/util/Makefile \ + test/xpath/Makefile \ + include/Makefile + ]) + +AC_OUTPUT diff --git a/axiom/include/Makefile.am b/axiom/include/Makefile.am new file mode 100644 index 0000000..d938299 --- /dev/null +++ b/axiom/include/Makefile.am @@ -0,0 +1 @@ +TESTS = diff --git a/axiom/include/axiom.h b/axiom/include/axiom.h new file mode 100644 index 0000000..38272d6 --- /dev/null +++ b/axiom/include/axiom.h @@ -0,0 +1,57 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_H +#define AXIOM_H +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** +* @file axiom.h +* @brief includes all headers in OM +*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_H */ diff --git a/axiom/include/axiom_attribute.h b/axiom/include/axiom_attribute.h new file mode 100644 index 0000000..b0a6e8e --- /dev/null +++ b/axiom/include/axiom_attribute.h @@ -0,0 +1,263 @@ + +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef AXIOM_ATTRIBUTE_H +#define AXIOM_ATTRIBUTE_H + +/** +* @file axiom_attribute.h +* @brief om attribute struct represents an xml attribute +*/ +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_attribute attribute + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_attribute axiom_attribute_t; + + /** + * creates an om_attribute struct + * @param env Environment. MUST NOT be NULL + * @param localname localname of the attribute, should not be a null value. + * @param value normalized attribute value. cannot be NULL + * @param ns namespace, if any, of the attribute. Optional, can be NULL om_attribute wont free the ns + * @return a pointer to newly created attribute struct, returns NULL on error with + * error code set in environment's error. + */ + AXIS2_EXTERN axiom_attribute_t *AXIS2_CALL + axiom_attribute_create( + const axutil_env_t * env, + const axis2_char_t * localname, + const axis2_char_t * value, + axiom_namespace_t * ns); + + /** + * Free om attribute passed as void pointer. This will be + * cast into appropriate type and then pass the cast object + * into the om_attribute structure's free method + * @param om_attribute pointer to attribute struct to be freed + * @param env Environment. MUST NOT be NULL + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_attribute_free_void_arg( + void *om_attribute, + const axutil_env_t * env); + + /** + * Free an axiom_attribute struct + * @param om_attribute pointer to attribute struct to be freed + * @param env Environment. MUST NOT be NULL + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_attribute_free( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** + * Creates and returns a qname struct for this attribute + * @param om_attribute pointer to attribute struct + * for which the qname is to be returned + * @param env Environment. MUST NOT be NULL + * @return returns qname for given attribute.NULL on error + */ + + AXIS2_EXTERN axutil_qname_t *AXIS2_CALL + axiom_attribute_get_qname( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** + * Serialize op + * @param om_attribute pointer to attribute struct to be serialized + * @param env Environment. MUST NOT be NULL, + * @param om_output AXIOM output handler to be used in serializing + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + + AXIS2_EXTERN int AXIS2_CALL + axiom_attribute_serialize( + struct axiom_attribute *om_attribute, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** Returns the localname of this attribute + * @param om_attribute pointer to attribute struct + * @param env environment. MUST NOT not be NULL. + * @return localname returns NULL on error. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_attribute_get_localname( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** + * returns value of this attribute + *@param om_attribute pointer to om_attribute struct + *@param env environment N not be null + *@return value , null on error + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_attribute_get_value( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** + * returns namespace of this attribute + *@param om_attribute + *@param env environment MUST NOT be NULL + *@return a pointer to om_namespace struct , returns NULL on error. + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_attribute_get_namespace( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** sets the localname of the attribute + *@param om_attribute pointer to om attribute struct. + *@param env environment, MUST NOT be null. + *@param localname localname that should be set for this attribute + *@return status code AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_attribute_set_localname( + struct axiom_attribute *om_attribute, + const axutil_env_t * env, + const axis2_char_t * localname); + + /** set the attribute value + *@param om_attribute a pointer to om_attribute struct. + *@param env environment, MUST NOT be NULL. + *@param value value that should be set for this attribute + *@return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_attribute_set_value( + struct axiom_attribute *om_attribute, + const axutil_env_t * env, + const axis2_char_t * value); + + /** set namespace of the attribute + *@param om_attribute a pointer to om_attribute struct + *@param env environment, MUST NOT be NULL. + *@param om_namespace a pointer to om_namespace struct that should be set + * for this attribute + *@return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_attribute_set_namespace( + struct axiom_attribute *om_attribute, + const axutil_env_t * env, + axiom_namespace_t * om_namespace); + + /** + * clones an om attribute + * @param om_attibute + * @param env environment + * @returns pointer to cloned om attribute struct on success + * NULL otherwise + */ + AXIS2_EXTERN struct axiom_attribute *AXIS2_CALL + axiom_attribute_clone( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** Increment the reference counter. + * @param om_attribute a pointer to om_attribute struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_attribute_increment_ref( + struct axiom_attribute *om_attribute, + const axutil_env_t * env); + + /** Create OM attribute + * @param om_attribute a pointer to om_attribute struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axiom_attribute_t *AXIS2_CALL + axiom_attribute_create_str( + const axutil_env_t * env, + axutil_string_t * localname, + axutil_string_t * value, + axiom_namespace_t * ns); + + /** Get the localname as a string + * @param om_attribute a pointer to om_attribute struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axiom_attribute_get_localname_str( + axiom_attribute_t * attribute, + const axutil_env_t * env); + + /** Get the value as a string + * @param om_attribute a pointer to om_attribute struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axiom_attribute_get_value_str( + axiom_attribute_t * attribute, + const axutil_env_t * env); + + /** Set the localname of the attribute + * @param om_attribute a pointer to om_attribute struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_attribute_set_localname_str( + axiom_attribute_t * attribute, + const axutil_env_t * env, + axutil_string_t * localname); + + /** Set the value of the attribute + * @param om_attribute a pointer to om_attribute struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_attribute_set_value_str( + axiom_attribute_t * attribute, + const axutil_env_t * env, + axutil_string_t * value); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_ATTRIBUTE_H */ diff --git a/axiom/include/axiom_child_element_iterator.h b/axiom/include/axiom_child_element_iterator.h new file mode 100644 index 0000000..627a347 --- /dev/null +++ b/axiom/include/axiom_child_element_iterator.h @@ -0,0 +1,124 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_CHILD_ELEMENT_ITERATOR_H +#define AXIOM_CHILD_ELEMENT_ITERATOR_H + +/** +*@file axiom_child_element_iterator.h +*@brief this is the iterator for om elemnts +*/ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_child_element_iterator + axiom_child_element_iterator_t; + + /** + * @defgroup axiom_child_element_iterator child element iterator + * @ingroup axiom_om + * @{ + */ + + /** + * Free the iterator + * @param iterator a pointer to child element iterator struct + * @param env environment, MUST NOT be NULL. + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_child_element_iterator_free( + void *iterator, + const axutil_env_t * env); + + /** + * Removes from the underlying collection the last element returned by the + * iterator (optional op). This method can be called only once per + * call to next. The behavior of an iterator is unspecified if + * the underlying collection is modified while the iteration is in + * progress in any way other than by calling this method. + * @param iterator a pointer to child element iterator struct + * @param env environment, MUST NOT be NULL. + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_child_element_iterator_remove( + axiom_child_element_iterator_t * iterator, + const axutil_env_t * env); + + /** + * returns true if the iteration has more elements + * in otherwords it returns true if the next() would return an element + * rather than null with an error code set to environments error + * @param iterator a pointer to child element iterator struct + * @param env environment, MUST NOT be NULL. + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + + axiom_child_element_iterator_has_next( + axiom_child_element_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Returns the next element in the iteration. Returns null if there + * is no more elements + * @param iterator a pointer to child element iterator struct + * @param env environment, MUST NOT be NULL. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_child_element_iterator_next( + axiom_child_element_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Create a child element interator for the current child + * @param current child + * @param env environment, MUST NOT be NULL. + * return axiom_child_element_iterator_t + */ + + AXIS2_EXTERN axiom_child_element_iterator_t *AXIS2_CALL + axiom_child_element_iterator_create( + const axutil_env_t * env, + axiom_node_t * current_child); + +#define AXIOM_CHILD_ELEMENT_ITERATOR_FREE(iterator, env) \ + axiom_child_element_iterator_free(iterator, env) + +#define AXIOM_CHILD_ELEMENT_ITERATOR_REMOVE(iterator, env) \ + axiom_child_element_iterator_remove(iterator, env) + +#define AXIOM_CHILD_ELEMENT_ITERATOR_HAS_NEXT(iterator, env) \ + axiom_child_element_iterator_has_next(iterator, env) + +#define AXIOM_CHILD_ELEMENT_ITERATOR_NEXT(iterator, env) \ + axiom_child_element_iterator_next(iterator, env) + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_CHILD_ELEMENT_ITERATOR_H */ diff --git a/axiom/include/axiom_children_iterator.h b/axiom/include/axiom_children_iterator.h new file mode 100644 index 0000000..c0e802a --- /dev/null +++ b/axiom/include/axiom_children_iterator.h @@ -0,0 +1,123 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_CHILDREN_ITERATOR_H +#define AXIOM_CHILDREN_ITERATOR_H + +/** +*@file axiom_children_iterator.h +*@brief this is the iterator for om nodes +*/ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_children_iterator axiom_children_iterator_t; + + /** + * @defgroup axiom_children_iterator children iterator + * @ingroup axiom_om + * @{ + */ + + /** + * @param current child + * @param env environment + * return axiom_children_iterator_t + */ + + AXIS2_EXTERN axiom_children_iterator_t *AXIS2_CALL + + axiom_children_iterator_create( + const axutil_env_t * env, + axiom_node_t * current_child); + + /** + * Free the om_children_iterator struct + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_children_iterator_free( + axiom_children_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Removes from the underlying collection the last element returned by the + * iterator (optional op). This method can be called only once per + * call to next. The behavior of an iterator is unspecified if + * the underlying collection is modified while the iteration is in + * progress in any way other than by calling this method. + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_children_iterator_remove( + axiom_children_iterator_t * iterator, + const axutil_env_t * env); + + /** + * @returns true if the iteration has more elements. In other + * words, returns true if next() would return an om_node_t struct + * rather than null with error code set in environment + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_children_iterator_has_next( + axiom_children_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Returns the next element in the iteration. Returns null if there are + * no more elements in the iteration + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_children_iterator_next( + axiom_children_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Resets the Iterator. This moves the cursor back to the initial. + * iterator chidren_iterator to be reset. + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_children_iterator_reset( + axiom_children_iterator_t * iterator, + const axutil_env_t * env); + + /************ Macros *********************************************/ + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_CHILDREN_ITERATOR_H */ diff --git a/axiom/include/axiom_children_qname_iterator.h b/axiom/include/axiom_children_qname_iterator.h new file mode 100644 index 0000000..f7daa66 --- /dev/null +++ b/axiom/include/axiom_children_qname_iterator.h @@ -0,0 +1,107 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_CHILDREN_QNAME_ITERATOR_H +#define AXIOM_CHILDREN_QNAME_ITERATOR_H + +/** + *@file axiom_children_qname_iterator.h + *@brief this is the iterator for om nodes using qname + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_children_qname_iterator + axiom_children_qname_iterator_t; + + /** + * @defgroup axiom_children_qname_iterator children qname iterator + * @ingroup axiom_om + * @{ + */ + + AXIS2_EXTERN axiom_children_qname_iterator_t *AXIS2_CALL + axiom_children_qname_iterator_create( + const axutil_env_t * env, + axiom_node_t * current_child, + axutil_qname_t * given_qname); + + /** + * free om_children_qname_iterator struct + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_children_qname_iterator_free( + axiom_children_qname_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Removes from the underlying collection the last element returned by the + * iterator (optional operation). This method can be called only once per + * call to next. The behavior of an iterator is unspecified if + * the underlying collection is modified while the iteration is in + * progress in any way other than by calling this method. + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_children_qname_iterator_remove( + axiom_children_qname_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Returns true if the iteration has more elements. (In other + * words, returns true if next would return an + * axiom_node_t struct rather than null with error code set in environment + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + + axiom_children_qname_iterator_has_next( + axiom_children_qname_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Returns the next element in the iteration. + * @param iterator a pointer to axiom children iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_children_qname_iterator_next( + axiom_children_qname_iterator_t * iterator, + const axutil_env_t * env); + + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_CHILDREN_QNAME_ITERATOR_H */ diff --git a/axiom/include/axiom_children_with_specific_attribute_iterator.h b/axiom/include/axiom_children_with_specific_attribute_iterator.h new file mode 100644 index 0000000..cbfb21d --- /dev/null +++ b/axiom/include/axiom_children_with_specific_attribute_iterator.h @@ -0,0 +1,128 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_H +#define AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_H + +/** +*@file axiom_children_with_specific_attribute_iterator.h +*@brief this is the iterator for om nodes +*/ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_children_with_specific_attribute_iterator + axiom_children_with_specific_attribute_iterator_t; + + /** + * @defgroup axiom_children_with_specific_attribute_iterator children with specific attribute iterator + * @ingroup axiom_om + * @{ + */ + + /** + * Free function free the om_children_with_specific_attribute_iterator struct + * @param iterator a pointer to axiom children with specific attribute iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_children_with_specific_attribute_iterator_free( + axiom_children_with_specific_attribute_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Removes from the underlying collection the last element returned by the + * iterator (optional op). This method can be called only once per + * call to next. The behavior of an iterator is unspecified if + * the underlying collection is modified while the iteration is in + * progress in any way other than by calling this method. + * @param iterator a pointer to axiom children with specific attribute iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_children_with_specific_attribute_iterator_remove( + axiom_children_with_specific_attribute_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Returns true< if the iteration has more elements. (In other + * words, returns true if next would return an axiom_node_t struct + * rather than NULL with error code set in environment + * @param iterator a pointer to axiom children with specific attribute iterator struct + * @param env environment, MUST NOT be NULL + */ + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_children_with_specific_attribute_iterator_has_next( + axiom_children_with_specific_attribute_iterator_t * iterator, + const axutil_env_t * env); + + /** + * Returns the next element in the iteration. returns null if there is no + * more elements in the iteration + * @param iterator a pointer to axiom children with specific attribute iterator struct + * @param env environment, MUST NOT be NULL + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_children_with_specific_attribute_iterator_next( + axiom_children_with_specific_attribute_iterator_t * iterator, + const axutil_env_t * env); + + /** + * @param env environment, MUST NOT be NULL + * @param current_child the current child for the interation + * @param attr_qname the qname for the attribute + * @param attr_value the value string for the attribute + * @param detach AXIS2_TRUE to detach AXIS2_FALSE not to + * return axiom_children_with_specific_attribute_iterator_t + */ + + AXIS2_EXTERN axiom_children_with_specific_attribute_iterator_t *AXIS2_CALL + axiom_children_with_specific_attribute_iterator_create( + const axutil_env_t * env, + axiom_node_t * current_child, + axutil_qname_t * attr_qname, + axis2_char_t * attr_value, + axis2_bool_t detach); + +#define AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_FREE(iterator, env) \ + axiom_children_with_specific_attribute_iterator_free(iterator, env) + +#define AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_REMOVE(iterator, env) \ + axiom_children_with_specific_attribute_iterator_remove(iterator, env) + +#define AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_HAS_NEXT(iterator, env) \ + axiom_children_with_specific_attribute_iterator_has_next(iterator, env) + +#define AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_NEXT(iterator, env) \ + axiom_children_with_specific_attribute_iterator_next(iterator, env) + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_CHILDREN_WITH_SPECIFIC_ATTRIBUTE_ITERATOR_H */ diff --git a/axiom/include/axiom_comment.h b/axiom/include/axiom_comment.h new file mode 100644 index 0000000..63d048e --- /dev/null +++ b/axiom/include/axiom_comment.h @@ -0,0 +1,115 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_COMMENT_H +#define AXIOM_COMMENT_H + +/** + * @file axiom_comment.h + * @brief defines axiom_comment_t struct, and manipulation functions + */ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_comment comment + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_comment axiom_comment_t; + + /** + * Creates a comment struct + * @param env Environment. MUST NOT be NULL, + * @param parent This is the parent node of the comment is any, can be NULL. + * @param value comment text + * @param node This is an out parameter.cannot be NULL. + * Returns the node corresponding to the comment created. + * Node type will be set to AXIOM_COMMENT + * @return a pointer to the newly created comment struct + */ + AXIS2_EXTERN axiom_comment_t *AXIS2_CALL + axiom_comment_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * value, + axiom_node_t ** node); + + /** + * Free a axis2_comment_t struct + * @param om_comment pointer to axis2_commnet_t struct to be freed + * @param env Environment. MUST NOT be NULL. + * @return satus of the op. + * AXIS2_SUCCESS on success ,AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_comment_free( + struct axiom_comment *om_comment, + const axutil_env_t * env); + + /** get the comments data + * @param om_comment a pointer to axiom_comment_t struct + * @param env environment, MUST NOT be NULL + * @returns comment text + */ + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_comment_get_value( + struct axiom_comment *om_comment, + const axutil_env_t * env); + + /** + * set comment data + * @param om_comment pointer to axiom_comment_t struct + * @param env environment, MUST NOT be NULL. + * @param value comment text + * @returns AXIS2_SUCCESS on success , AXIS2_FAILURE on error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_comment_set_value( + struct axiom_comment *om_comment, + const axutil_env_t * env, + const axis2_char_t * value); + + /** + * serialize function + * @param om_comment pointer to axiom_comment_t struct + * @param env environment, MUST NOT be NULL. + * @param om_output pointer to om_output_t struct + * @return AXIS2_SUCCESS on success, AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_comment_serialize( + struct axiom_comment *om_comment, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_COMMENT_H */ diff --git a/axiom/include/axiom_data_handler.h b/axiom/include/axiom_data_handler.h new file mode 100644 index 0000000..0cf65c9 --- /dev/null +++ b/axiom/include/axiom_data_handler.h @@ -0,0 +1,260 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_DATA_HANDLER_H +#define AXIOM_DATA_HANDLER_H + +/** + * @file axiom_data_handler.h + * @brief axis2 data_handler interface + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef enum axiom_data_handler_type + { + AXIOM_DATA_HANDLER_TYPE_FILE, + AXIOM_DATA_HANDLER_TYPE_BUFFER, + AXIOM_DATA_HANDLER_TYPE_CALLBACK + } axiom_data_handler_type_t; + + typedef struct axiom_data_handler axiom_data_handler_t; + + /** @defgroup axiom_data_handler Flow + * @ingroup axiom_data_handler + * @{ + */ + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_data_handler_get_content_type( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @param mime type, + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_handler_set_content_type( + axiom_data_handler_t * data_handler, + const axutil_env_t * env, + const axis2_char_t *mime_type); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return bool whether attachment is cached or not + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_data_handler_get_cached( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @param cached, + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_data_handler_set_cached( + axiom_data_handler_t * data_handler, + const axutil_env_t * env, + axis2_bool_t cached); + + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_byte_t *AXIS2_CALL + + axiom_data_handler_get_input_stream( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN size_t AXIS2_CALL + axiom_data_handler_get_input_stream_len( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * The data_handler is responsible for memory occupied by the stream + * returned + * @param output_stream parameter to store reference to output byte stream. + * @param output_stream_size parameter to store reference to output byte + * stream length + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_handler_read_from( + axiom_data_handler_t * data_handler, + const axutil_env_t * env, + axis2_byte_t ** output_stream, + size_t *output_stream_size); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_data_handler_set_binary_data( + axiom_data_handler_t * data_handler, + const axutil_env_t * env, + axis2_byte_t * input_stream, + size_t input_stream_len); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_handler_write_to( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_handler_set_file_name( + axiom_data_handler_t * data_handler, + const axutil_env_t * env, + axis2_char_t * file_name); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return file name, in the case of file type data handler. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_data_handler_get_file_name( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_data_handler_free( + axiom_data_handler_t * data_handler, + const axutil_env_t * env); + + /** + * Creates data_handler struct + * @return pointer to newly created data_handler + */ + AXIS2_EXTERN axiom_data_handler_t *AXIS2_CALL + axiom_data_handler_create( + const axutil_env_t * env, + const axis2_char_t * file_name, + const axis2_char_t * mime_type); + + /* Add the binary to the array_list + * @param data_handler, a pointer to data handler struct + * data_handler, a pointer to data handler struct + * list, a pointer to an array_list which containing some message parts need + * to be written to the wire + * data_handler, a pointer to data handler struct + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_handler_add_binary_data( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + axutil_array_list_t *list); + + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_data_handler_get_mime_id( + axiom_data_handler_t *data_handler, + const axutil_env_t *env); + + /** + * @param data_handler, a pointer to data handler struct + * @param env environment, MUST NOT be NULL. + * @param mime id, + * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error. + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_handler_set_mime_id( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + const axis2_char_t *mime_id); + + + AXIS2_EXTERN axiom_data_handler_type_t AXIS2_CALL + axiom_data_handler_get_data_handler_type( + axiom_data_handler_t *data_handler, + const axutil_env_t *env); + + AXIS2_EXTERN void AXIS2_CALL + axiom_data_handler_set_data_handler_type( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + axiom_data_handler_type_t data_handler_type); + + AXIS2_EXTERN void *AXIS2_CALL + axiom_data_handler_get_user_param( + axiom_data_handler_t *data_handler, + const axutil_env_t *env); + + AXIS2_EXTERN void AXIS2_CALL + axiom_data_handler_set_user_param( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + void *user_param); + + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_DATA_HANDLER_H */ diff --git a/axiom/include/axiom_data_source.h b/axiom/include/axiom_data_source.h new file mode 100644 index 0000000..f892682 --- /dev/null +++ b/axiom/include/axiom_data_source.h @@ -0,0 +1,111 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_DATA_SOURCE_H +#define AXIOM_DATA_SOURCE_H + +/** + * @file axiom_data_source.h + * @brief Axis2 AXIOM XML data_source + */ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_data_source data_source + * @ingroup axiom_om + * @{ + */ + + /** + * \brief data_source struct + * Handles the XML data_source in OM + */ + typedef struct axiom_data_source axiom_data_source_t; + + /** + * Creates a new data_source struct + * @param env Environment. MUST NOT be NULL, . + * @param parent parent of the new node. Optinal, can be NULL. + * The parent element must be of type AXIOM_ELEMENT + * @param value Text value. Optinal, can be NULL. + * @param comment_node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the data_source struct created. + * Node type will be set to AXIOM_DATA_SOURCE + * @return pointer to newly created data_source struct + */ + AXIS2_EXTERN axiom_data_source_t *AXIS2_CALL + axiom_data_source_create( + const axutil_env_t * env, + axiom_node_t * parent, + axiom_node_t ** node); + + /** + * Free an axiom_data_source struct + * @param env environment. MUST NOT be NULL. + * @param om_data_source pointer to om data_source struct to be freed. + * @return satus of the op. AXIS2_SUCCESS on success + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_data_source_free( + struct axiom_data_source *om_data_source, + const axutil_env_t * env); + + /** + * Serialize op + * @param env environment. MUST NOT be NULL. + * @param om_data_source pointer to om data_source struct to be serialized. + * @param om_output AXIOM output handler to be used in serializing. + * @return satus of the op. AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_data_source_serialize( + struct axiom_data_source *om_data_source, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** + * set the data_source value + * @param om_data_source om_data_source struct + * @param env environment , MUST NOT be NULL. + * @param value data_source + * @return status of the op. AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axutil_stream_t *AXIS2_CALL + axiom_data_source_get_stream( + struct axiom_data_source *om_data_source, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_DATA_SOURCE_H */ diff --git a/axiom/include/axiom_defines.h b/axiom/include/axiom_defines.h new file mode 100644 index 0000000..9cf4b51 --- /dev/null +++ b/axiom/include/axiom_defines.h @@ -0,0 +1,40 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_DEFINES_H +#define AXIOM_DEFINES_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * This enum is used to decide the type of storage used + */ + typedef enum _axis2_xml_parser_type + { + AXIS2_XML_PARSER_TYPE_BUFFER = 1, + AXIS2_XML_PARSER_TYPE_FILE, + AXIS2_XML_PARSER_TYPE_DOC + } axis2_xml_parser_type; + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_DEFINES_H */ diff --git a/axiom/include/axiom_doctype.h b/axiom/include/axiom_doctype.h new file mode 100644 index 0000000..a054c6e --- /dev/null +++ b/axiom/include/axiom_doctype.h @@ -0,0 +1,120 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_DOCTYPE_H +#define AXIOM_DOCTYPE_H + +/** + *@file axiom_doctype.h + *@brief defines struct representing xml DTD and its manipulation functions + */ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + struct axiom_doctype; + struct axiom_doctype_ops; + + /** + * @defgroup axiom_doctype doctype + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_doctype axiom_doctype_t; + + /** + * Creates a axiom_doctype_t struct + * @param env Environment. MUST NOT be NULL, + * @param parent parent of the new node. Optinal, can be NULL. + * @param value doctype text + * @param node This is an out parameter.cannot be NULL. + * Returns the node corresponding to the doctype created. + * Node type will be set to AXIOM_DOCTYPE + * @return pointer to newly created doctype struct + */ + AXIS2_EXTERN axiom_doctype_t *AXIS2_CALL + axiom_doctype_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * value, + axiom_node_t ** node); + + /** + * free doctype struct + * @param om_doctype pointer to axiom_doctype_t struct to be freed + * @param env Environment. MUST NOT be NULL, + * @return satus of the op. AXIS2_SUCCESS on success + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_doctype_free( + struct axiom_doctype *om_doctype, + const axutil_env_t * env); + + /** + * @param om_doctype pointer to a axiom_doctype_t struct + * @param env environment must not be null + * @return DTD text + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_doctype_get_value( + struct axiom_doctype *om_doctype, + const axutil_env_t * env); + + /** + * @param om_doctype pointer to axiom doctype_t struct + * @param env environment , MUST NOT be NULL. + * @param value doctype text value + * @return status of the op, + * AXIS2_SUCCESS on success, AXIS2_FAILURE on error. + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_doctype_set_value( + struct axiom_doctype *om_doctype, + const axutil_env_t * env, + const axis2_char_t * value); + + /** + * serialize op + * @param om_doctype pointer to axiom_doctype_t struct + * @param env environment , MUST NOT be NULL + * @param om_output pointer to axiom_output_t struct + * @returns status of the op, + * AXIS2_SUCCESS on success, AXIS2_FAILURE on error. + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_doctype_serialize( + struct axiom_doctype *om_doctype, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_DOCTYPE_H */ diff --git a/axiom/include/axiom_document.h b/axiom/include/axiom_document.h new file mode 100644 index 0000000..ac014df --- /dev/null +++ b/axiom/include/axiom_document.h @@ -0,0 +1,173 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_DOCUMENT_H +#define AXIOM_DOCUMENT_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @file axiom_document.h + * @brief om_document represents an XML document + */ + +#define CHAR_SET_ENCODING "UTF-8" +#define XML_VERSION "1.0" + + struct axiom_stax_builder; + + /** + * @defgroup axiom_document document + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_document axiom_document_t; + + /** + * creates an axiom_document_t struct + * @param env Environment. MUST NOT be NULL. + * @param root pointer to document's root node. Optional, can be NULL + * @param builder pointer to axiom_stax_builder + * @return pointer to the newly created document. + */ + AXIS2_EXTERN axiom_document_t *AXIS2_CALL + axiom_document_create( + const axutil_env_t * env, + axiom_node_t * root, + struct axiom_stax_builder *builder); + + /** + * Free document struct + * @param document pointer to axiom_document_t struct to be freed + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_document_free( + struct axiom_document *document, + const axutil_env_t * env); + + /** + * Free document struct only, Does not free the associated axiom struture. + * @param document pointer to axiom_document_t struct to be freed + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_document_free_self( + struct axiom_document *document, + const axutil_env_t * env); + + /** Builds the next node if the builder is not finished with input xml stream + * @param document document whose next node is to be built. cannot be NULL + * @param env Environment. MUST NOT be NULL. + * @return pointer to the next node. NULL on error. + */ + + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_document_build_next( + struct axiom_document *document, + const axutil_env_t * env); + + /** + * Gets the root element of the document. + * @param document document to return the root of + * @param env Environment. MUST NOT be NULL. + * @return returns a pointer to the root node. If no root present, + * this method tries to build the root. Returns NULL on error. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_document_get_root_element( + struct axiom_document *document, + const axutil_env_t * env); + + /** + * set the root element of the document. IF a root node is already exist,it is freed + * before setting to root element + * @param document document struct to return the root of + * @param env Environment. MUST NOT be NULL. + * @return returns status code AXIS2_SUCCESS on success ,AXIS2_FAILURE on error. + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_document_set_root_element( + struct axiom_document *document, + const axutil_env_t * env, + axiom_node_t * om_node); + + /** + * This method builds the rest of the xml input stream from current position till + * the root element is completed . + * @param document pointer to axiom_document_t struct to be built. + * @param env environment MUST NOT be NULL. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_document_build_all( + struct axiom_document *document, + const axutil_env_t * env); + + /** + * get builder + * @param document pointer to axiom_document_t struct to be built. + * @param env environment MUST NOT be NULL. + * @return builder, returns NULL if a builder is not associated with + * document + */ + AXIS2_EXTERN struct axiom_stax_builder *AXIS2_CALL + axiom_document_get_builder( + struct axiom_document *document, + const axutil_env_t * env); + + /** + * sets builder for document. + * @param document pointer to axiom_document_t struct to be built. + * @param env environment MUST NOT be NULL. + * @param builder pointer to builder to associate with document + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_document_set_builder( + axiom_document_t * document, + const axutil_env_t * env, + struct axiom_stax_builder * builder); + + /** + * @param om_document + * @return status code AXIS2_SUCCESS on success , otherwise AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_document_serialize( + struct axiom_document *document, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_DOCUMENT_H */ diff --git a/axiom/include/axiom_element.h b/axiom/include/axiom_element.h new file mode 100644 index 0000000..ceb4417 --- /dev/null +++ b/axiom/include/axiom_element.h @@ -0,0 +1,747 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_ELEMENT_H +#define AXIOM_ELEMENT_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_element axiom_element_t; + + /** + * @defgroup axiom_element element + * @ingroup axiom_om + * @{ + */ + + /** + * Creates an AXIOM element with given local name + * @param env Environment. MUST NOT be NULL. + * @param parent parent of the element node to be created. can be NULL. + * @param localname local name of the elment. cannot be NULL. + * @param ns namespace of the element. can be NULL. + * If the value of the namespace has not already been declared + * then the namespace structure ns will be declared and will be + * freed when the tree is freed. + * If the value of the namespace has already been declared using + * another namespace structure then the namespace structure ns + * will be freed. + * @param node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the comment created. + * Node type will be set to AXIOM_ELEMENT + * @return a pointer to the newly created element struct + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_element_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * localname, + axiom_namespace_t * ns, + axiom_node_t ** node); + + /** + * Creates an AXIOM element with given qname + * @param env Environment. MUST NOT be NULL. + * @param parent parent of the element node to be created. can be NULL. + * @param qname qname of the elment.cannot be NULL. + * @param node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the comment created. + * Node type will be set to AXIOM_ELEMENT + * @return a pointer to the newly created element struct + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_element_create_with_qname( + const axutil_env_t * env, + axiom_node_t * parent, + const axutil_qname_t * qname, + axiom_node_t ** node); + /* + * Find a namespace in the scope of the document. + * Start to find from the given node and go up the hierarchy. + * @param om_element pointer to om_element_struct contained in + * node , + * @param env Environment. MUST NOT be NULL. + * @param node node containing an instance of an AXIOM element,cannot be NULL. + * @param uri namespace uri.. + * @param prefix namespace prefix. can be NULL. + * @return pointer to the namespace, if found, else NULL. On error, returns + * NULL and sets error code in environment,s error + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_find_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * node, + const axis2_char_t * uri, + const axis2_char_t * prefix); + + /** + * Declare a namespace in current element (in the scope of this element ). + * It checks to see if it is already declared. + * @param om_element contained in the om node struct + * @param env Environment. MUST NOT be NULL. + * @param node node containing an instance of an AXIOM element. + * @param ns pointer to the namespace struct to be declared + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_declare_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * node, + axiom_namespace_t * ns); + /** + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + * + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_declare_namespace_assume_param_ownership( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_namespace_t * ns); + + /** + * Finds a namespace using qname + * Start to find from the given node and go up the hierarchy. + * @param om_element om_element contained in node + * @param env Environment. MUST NOT be NULL. + * @param node node containing an instance of an AXIOM element, cannot be NULL. + * @param qname qname of the namespace to be found. cannot be NULL. + * @return pointer to the namespace, if found, else NULL. On error, returns + * NULL and sets the error code in environment's error struct. + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_find_namespace_with_qname( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * node, + axutil_qname_t * qname); + + /** + * Adds an attribute to current element The current element takes responsibility of the assigned attribute + * @param om_element element to which the attribute is to be added.cannot be NULL. + * @param env Environment. MUST NOT be NULL. + * @param attribute attribute to be added. + * @param node axiom_node_t node that om_element is contained in + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_add_attribute( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_attribute_t * attribute, + axiom_node_t * node); + + /** + * Gets (finds) the attribute with the given qname + * @param element element whose attribute is to be found. + * @param env Environment. MUST NOT be NULL. + * @qname qname qname of the attribute to be found. should not be NULL. + * @return a pointer to the attribute with given qname if found, else NULL. + * On error, returns NULL and sets the error code in environment's error struct. + */ + AXIS2_EXTERN axiom_attribute_t *AXIS2_CALL + axiom_element_get_attribute( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_qname_t * qname); + + /** + * Gets (finds) the attribute value with the given qname + * @param element element whose attribute is to be found. + * @param env Environment. MUST NOT be NULL. + * @qname qname qname of the attribute to be found. should not be NULL. + * @return the attribute value with given qname if found, else NULL. + * On error, returns NULL and sets the error code in environment's error struct. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_element_get_attribute_value( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_qname_t * qname); + + /** + * Frees given element + * @param element AXIOM element to be freed. + * @param env Environment. MUST NOT be NULL. + * @return satus of the op. AXIS2_SUCCESS on success ,AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_element_free( + axiom_element_t * element, + const axutil_env_t * env); + + /** + * Serializes the start part of the given element + * @param element element to be serialized. + * @param env Environment. MUST NOT be NULL. + * @param om_output AXIOM output handler to be used in serializing + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_serialize_start_part( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_output_t * om_output, + axiom_node_t * ele_node); + + /** + * Serializes the end part of the given element. serialize_start_part must + * have been called before calling this method. + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * @param om_output AXIOM output handler to be used in serializing + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_serialize_end_part( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** + * finds a namespace in current element's scope, + * by uri or prefix or both + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param uri namespace uri, may be null + * @param prefix prefix + * @return axiom_namespace_t if found, else return NULL + */ + + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_find_declared_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + const axis2_char_t * uri, + const axis2_char_t * prefix); + + /** + * returns the localname of this element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @returns localname of element, returns NULL on error. + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_element_get_localname( + axiom_element_t * om_element, + const axutil_env_t * env); + + /** + * set the localname of this element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @localname text value to be set as localname + * @returns status code of op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_set_localname( + axiom_element_t * om_element, + const axutil_env_t * env, + const axis2_char_t * localname); + + /** + * get the namespace of om_element + * @param om_element om_element struct + * @param env environemt, MUST NOT be NULL. + * @returns pointer to axiom_namespace_t struct + * NULL if there is no namespace associated with the element, + * NULL on error with error code set to environment's error + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_get_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * ele_node); + + /** + * set the namespace of the element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param ns pointer to namespace + * If the value of the namespace has not already been declared + * then the namespace structure ns will be declared and will be + * freed when the tree is freed. + * @returns status code of the op, with error code + * set to environment's error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_set_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_namespace_t * ns, + axiom_node_t * node); + + + /** + * unconditionally set the namespace of the element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param ns pointer to namespace + * The namespace ns is assumed to have been declared already. + * @returns status code of the op, with error code + * set to environment's error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_set_namespace_assume_param_ownership( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_namespace_t * ns); + + /** + * get the attribute list of the element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @returns axutil_hash poiner to attributes hash + * This hash table is read only + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_element_get_all_attributes( + axiom_element_t * om_element, + const axutil_env_t * env); + + /** + * get the namespace list of the element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @returns axutil_hash pointer to namespaces hash + * this hash table is read only + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_element_get_namespaces( + axiom_element_t * om_element, + const axutil_env_t * env); + + /** + *@return qname of this element + * the returned qname should not be externaly freed + * when om_element struct is freed qname is also + * freed + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param ele_node pointer to this element node + * + * @returns axutil_qname_t struct , NULL on failure + */ + AXIS2_EXTERN axutil_qname_t *AXIS2_CALL + axiom_element_get_qname( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * ele_node); + + /** + * returns a list of children iterator + * returned iterator is freed when om_element struct + * is freed + * iterators reset function must be called by user + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param element_node pointer to this element node + * + */ + AXIS2_EXTERN axiom_children_iterator_t *AXIS2_CALL + axiom_element_get_children( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node); + + /** + * returns a list of children iterator with qname + * returned iterator is freed when om element struct + * is freed + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param element_node pointer to this element node + * @returns children qname iterator struct + */ + + AXIS2_EXTERN axiom_children_qname_iterator_t *AXIS2_CALL + axiom_element_get_children_with_qname( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_qname_t * element_qname, + axiom_node_t * element_node); + + /** + * Returns the om_element corresponding to element_qname + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param element_qname qname of the element + * @param om_node pointer to this element node + * @param element_node + * @param child_node + * @returns children qname iterator struct + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_element_get_first_child_with_qname( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_qname_t * element_qname, + axiom_node_t * element_node, + axiom_node_t ** child_node); + + /** + * removes an attribute from the element attribute list + * user must free this attribute, element free function does not free + * attributes that are not is it's attribute list + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_attribute attribute to be removed + * @return AXIS2_SUCCESS if attribute was found and removed, else + * AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_remove_attribute( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_attribute_t * om_attribute); + + /** + * Sets the text of the given element. + * caution - This method will wipe out all the text elements (and hence any + * mixed content) before setting the text + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param text text to set. + * @param element_node node of element. + * @return AXIS2_SUCCESS if attribute was found and removed, else + * AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_set_text( + axiom_element_t * om_element, + const axutil_env_t * env, + const axis2_char_t * text, + axiom_node_t * element_node); + + /** + * Select all the text children and concat them to a single string. The string + * returned by this method call will be free by axiom when this method is called again. + * So it is recomended to have a copy of the return value if this method is going to + * be called more that once and the return values of the earlier calls are important. + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param element node , the container node of this om element + * @return the contanated text of all text childrens text values + * return null if no text children is avilable or on error + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_element_get_text( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node); + + /** + * returns the first child om element of this om element node + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * @return om_element if one is availble otherwise return NULL + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_element_get_first_element( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node, + axiom_node_t ** first_element_node); + + /** + * returns the serilized text of this element and its children + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param element_node the container node this on element is contained + * @return a char array of xml , returns NULL on error + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_element_to_string( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node); + + /** + * returns an iterator with child elements of type AXIOM_ELEMENT + * iterator is freed when om_element node is freed + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param element_node + * @returns axiom_child_element_iterator_t , NULL on error + */ + AXIS2_EXTERN axiom_child_element_iterator_t *AXIS2_CALL + axiom_element_get_child_elements( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node); + + /** + * builds this om_element_node completely, This is only possible + * if the om_stax_builder is associated with the om_element_node, + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * @param element_node corresponding om element node of this om element + * struct + * @returns AXIS2_SUCCESS if this element node was successfully completed, + * otherwise returns AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_build( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node); + + /** + * retrieves the default namespace of this element , if available, + * @param om_element pointer to om element + * @param env axutil_environment MUST Not be NULL + * @param element_node corresponding om element node of this om element + * @returns pointer to default namespace if availale , NULL otherwise + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_get_default_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node); + + /** + * declared a default namespace explicitly + * @param om_element pointer to om element + * @param env environment MUST not be NULL + * @param uri namespace uri of the default namespace + * @returns the declared namespace + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_declare_default_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * checks for the namespace in the context of this element + * with the given prefix + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_element_node pointer to this element node + * @returns pointer to relevent namespace + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_element_find_namespace_uri( + axiom_element_t * om_element, + const axutil_env_t * env, + const axis2_char_t * prefix, + axiom_node_t * element_node); + + /** + *This will not search the namespace in the scope nor will + * declare in the current element, as in set_namespace. This will + * just assign the given namespace to the element. + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * @param om_ns pointer to namespace to be set + * @returns + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_set_namespace_with_no_find_in_current_scope( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_namespace_t * om_ns); + + /** + * Extract attributes , returns a clones hash table of attributes, + * if attributes are associated with a namespace it is also cloned + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_element_extract_attributes( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * ele_node); + + /** + * Returns the attribute value as a string for the given element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param attr_name the attribute name + * + * @return the attribute value as a string + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_element_get_attribute_value_by_name( + axiom_element_t * om_ele, + const axutil_env_t * env, + axis2_char_t * attr_name); + + /** + * Create an OM Element and an OM node from given string params + * @param env environment MUST not be NULL + * @param parent pointer to this parent element node + * @param localname the locanmae of the element + * @param ns the namespace of the element + * @param node the reference ot the created node + * @return + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_element_create_str( + const axutil_env_t * env, + axiom_node_t * parent, + axutil_string_t * localname, + axiom_namespace_t * ns, + axiom_node_t ** node); + + /** + * Returns the Local name of the element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * + * @return the Local name of the element + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axiom_element_get_localname_str( + axiom_element_t * om_element, + const axutil_env_t * env); + + /** + * Set the Local name of the element + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param localname the Local name of the element + * + * @return + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_element_set_localname_str( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_string_t * localname); + + /** + * Return whether the element is empty or not + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * + * @return AXIS2_TRUE if empty AXIS2_FALSE if not empty + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_element_get_is_empty( + axiom_element_t * om_element, + const axutil_env_t * env); + + /** + * Set whether the element is empty or not + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param is_empty AXIS2_TRUE if empty AXIS2_FALSE if not empty + * + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_element_set_is_empty( + axiom_element_t * om_element, + const axutil_env_t * env, + axis2_bool_t is_empty); + + /** + * Collect all the namespaces with distinct prefixes in + * the parents of the given element. Effectively this + * is the set of namespaces declared above this element + * that are inscope at this element and might be used + * by it or its children. + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * @returns pointer to hash of relevent namespaces + */ + AXIS2_EXTERN axutil_hash_t * AXIS2_CALL + axiom_element_gather_parent_namespaces( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * om_node); + + /** + * If the provided namespace used by the provided element + * is one of the namespaces from the parent of the root + * root element, redeclares that namespace at the root element + * and removes it from the hash of parent namespaces + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * @param ns pointer to namespace to redeclare + * @param root_element pointer to the subtree root element node + * @param inscope_namespaces pointer to hash of parent namespaces + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_element_use_parent_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * om_node, + axiom_namespace_t *ns, + axiom_element_t * root_element, + axutil_hash_t *inscope_namespaces); + + /** + * Examines the subtree beginning at the provided element + * For each element or attribute, if it refers to a namespace + * declared in a parent of the subtree root element, redeclares + * that namespace at the level of the subtree root and removes + * it from the set of parent namespaces in scope and not yet + * declared + * @param om_element pointer to om_element + * @param env environment MUST not be NULL + * @param om_node pointer to this element node + * + * @param root_element pointer to the subtree root element node + * @param inscope_namespaces pointer to hash of parent namespaces + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_element_redeclare_parent_namespaces( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * om_node, + axiom_element_t * root_element, + axutil_hash_t *inscope_namespaces); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_ELEMENT_H */ diff --git a/axiom/include/axiom_mime_const.h b/axiom/include/axiom_mime_const.h new file mode 100644 index 0000000..e75fbd7 --- /dev/null +++ b/axiom/include/axiom_mime_const.h @@ -0,0 +1,56 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_MIME_CONST_H +#define AXIOM_MIME_CONST_H + +/** +* @file axiom.h +* @brief includes all headers in MIME_CONST +*/ +#ifdef __cplusplus +extern "C" +{ +#endif + +#define AXIOM_MIME_BOUNDARY_BYTE 45 +#define AXIOM_MIME_CRLF_BYTE 13 + +#define AXIOM_MIME_TYPE_XOP_XML "application/xop+xml" +#define AXIOM_MIME_TYPE_MULTIPART_RELATED "multipart/related" +#define AXIOM_MIME_TYPE_OCTET_STREAM "application/octet-stream" + +#define AXIOM_MIME_HEADER_FIELD_CHARSET "charset" +#define AXIOM_MIME_HEADER_FIELD_TYPE "type" +#define AXIOM_MIME_HEADER_FIELD_BOUNDARY "boundary" +#define AXIOM_MIME_HEADER_FIELD_START_INFO "start-info" +#define AXIOM_MIME_HEADER_FIELD_START "start" + +#define AXIOM_MIME_HEADER_CONTENT_TYPE "content-type" +#define AXIOM_MIME_HEADER_CONTENT_TRANSFER_ENCODING "content-transfer-encoding" +#define AXIOM_MIME_HEADER_CONTENT_ID "content-id" + +#define AXIOM_MIME_CONTENT_TRANSFER_ENCODING_BINARY "binary" + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_MIME_CONST_H */ diff --git a/axiom/include/axiom_mime_parser.h b/axiom/include/axiom_mime_parser.h new file mode 100644 index 0000000..b7f4f00 --- /dev/null +++ b/axiom/include/axiom_mime_parser.h @@ -0,0 +1,220 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_MIME_PARSER_H +#define AXIOM_MIME_PARSER_H + +/** + * @file axiom_mime_parser.h + * @brief axis2 mime_parser interface + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define AXIOM_MIME_PARSER_BUFFER_SIZE (1024 * 1024/2) +#define AXIOM_MIME_PARSER_MAX_BUFFERS 1000 + +#define AXIOM_MIME_PARSER_END_OF_MIME_MAX_COUNT 100 + + + typedef struct axiom_mime_parser axiom_mime_parser_t; + + /** @defgroup axiom_mime_parser Flow + * @ingroup axiom_mime_parser + * @{ + */ + + /** + * Parse and returns mime parts as a hash map + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @param callback_ctx the callback context + * @param mime_boundary the MIME boundary + * @return mime parts as a hash map + */ + /*AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_mime_parser_parse( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK, + void *callback_ctx, + axis2_char_t * mime_boundary);*/ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_mime_parser_parse_for_soap( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback, + void *callback_ctx, + axis2_char_t * mime_boundary); + + + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_mime_parser_parse_for_attachments( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback, + void *callback_ctx, + axis2_char_t * mime_boundary, + void *user_param); + + + /** + * Returns mime parts as a hash map + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @return mime parts as a hash map + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_mime_parser_get_mime_parts_map( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env); + + /** + * Deallocate memory. Free the mime parser struct + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_parser_free( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env); + + /** + * Returns the length of the SOAP Body + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @return the length of the SOAP Body + */ + AXIS2_EXTERN size_t AXIS2_CALL + axiom_mime_parser_get_soap_body_len( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env); + + /** + * Get the SOAP Body as a string + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @return the SOAP Body as a string + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_mime_parser_get_soap_body_str( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env); + + /** + * Create a mime parser struct + * @param env Environment. MUST NOT be NULL. + * @return created mime parser + */ + AXIS2_EXTERN axiom_mime_parser_t *AXIS2_CALL + axiom_mime_parser_create( + const axutil_env_t * env); + + /** + * Set the size of the chink buffer + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @param size the size of the chink buffer + * @return mime parts as a hash map + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_parser_set_buffer_size( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env, + int size); + + /** + * Set maximum number of chunk buffers + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @param num maximum number of chunk buffers + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_parser_set_max_buffers( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env, + int num); + + + /** + * Set attachment dir specified in the axis2.xml + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @param attachment_dir is string containg the directory path + * @return VOID + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_parser_set_attachment_dir( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_char_t *attachment_dir); + + + /** + * Set Caching callback name specified in the axis2.xml + * @param mime_parser the pointer for the mime parser struct + * @param env Environment. MUST NOT be NULL. + * @param callback_name is string containg the dll path + * @return VOID + */ + + + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_parser_set_caching_callback_name( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_char_t *callback_name); + + + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_parser_set_mime_boundary( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_char_t *mime_boundary); + + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_mime_parser_get_mime_boundary( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env); + + + + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_MIME_PARSER_H */ diff --git a/axiom/include/axiom_mime_part.h b/axiom/include/axiom_mime_part.h new file mode 100644 index 0000000..e4cfc36 --- /dev/null +++ b/axiom/include/axiom_mime_part.h @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_MIME_PART_H +#define AXIOM_MIME_PART_H + +/** + * @file axiom_mime_part.h + * @brief axis2 mime_part interface + */ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_mime_part_t axiom_mime_part_t; + + + /* An enum to keep different mime_part types */ + + typedef enum axiom_mime_part_type_t + { + + /** Char buffer */ + AXIOM_MIME_PART_BUFFER = 0, + + /* A file */ + AXIOM_MIME_PART_FILE, + + /* User specified callback */ + AXIOM_MIME_PART_CALLBACK, + + /* unknown type*/ + AXIOM_MIME_PART_UNKNOWN + + } axiom_mime_part_type_t; + + struct axiom_mime_part_t + { + /* This is when the mime part is a buffer. + * This will be null when the part is a file */ + axis2_byte_t *part; + + /* This is to keep file name when the part is a file + * NULL when the part is a buffer */ + axis2_char_t *file_name; + + /* Size of the part. In the case of buffer this is + * the buffer size and in the case of file this is + the file size */ + size_t part_size; + + /* This is one from the above defined enum */ + axiom_mime_part_type_t type; + + /* This is required in the case of the callback */ + void *user_param; + }; + + + + + AXIS2_EXTERN const axis2_char_t *AXIS2_CALL + axiom_mime_part_get_content_type_for_mime( + const axutil_env_t * env, + axis2_char_t * boundary, + axis2_char_t * content_id, + axis2_char_t * char_set_encoding, + const axis2_char_t * soap_content_type); + + + /** + * Creates mime_part struct + * @return pointer to newly created mime_part + */ + + AXIS2_EXTERN axiom_mime_part_t *AXIS2_CALL + axiom_mime_part_create( + const axutil_env_t *env); + + /* This method will create the output part + * list.*/ + + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axiom_mime_part_create_part_list( + const axutil_env_t *env, + axis2_char_t *soap_body, + axutil_array_list_t *binary_node_list, + axis2_char_t *boundary, + axis2_char_t *content_id, + axis2_char_t *char_set_encoding, + const axis2_char_t *soap_content_type); + + + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_part_free( + axiom_mime_part_t *mime_part, + const axutil_env_t *env); + + + + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_MIME_PART_H */ diff --git a/axiom/include/axiom_mtom_caching_callback.h b/axiom/include/axiom_mtom_caching_callback.h new file mode 100644 index 0000000..e432b2f --- /dev/null +++ b/axiom/include/axiom_mtom_caching_callback.h @@ -0,0 +1,114 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef AXIOM_MTOM_CACHING_CALLBACK_H +#define AXIOM_MTOM_CACHING_CALLBACK_H + +/** + * @file axiom_mtom_caching_callback.h + * @brief Caching callback for mime parser + */ + +/** +* @defgroup caching_callback +* @ingroup axiom +* @{ +*/ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * Type name for struct axiom_mtom_caching_callback_ops + */ + typedef struct axiom_mtom_caching_callback_ops axiom_mtom_caching_callback_ops_t; + + /** + * Type name for struct axiom_mtom_caching_callback + */ + typedef struct axiom_mtom_caching_callback axiom_mtom_caching_callback_t; + + + /** + * init_handler will init the caching storage + */ + + /** + * cache will write the data to the storage + */ + + /** + * close_handler will close the storage + */ + + struct axiom_mtom_caching_callback_ops + { + void* (AXIS2_CALL* + init_handler)(axiom_mtom_caching_callback_t *mtom_caching_callback, + const axutil_env_t* env, + axis2_char_t *key); + + axis2_status_t (AXIS2_CALL* + cache)(axiom_mtom_caching_callback_t *mtom_caching_callback, + const axutil_env_t* env, + axis2_char_t *data, + int length, + void *handler); + + axis2_status_t (AXIS2_CALL* + close_handler)(axiom_mtom_caching_callback_t *mtom_caching_callback, + const axutil_env_t* env, + void *handler); + + axis2_status_t (AXIS2_CALL* + free)(axiom_mtom_caching_callback_t *mtom_caching_callback, + const axutil_env_t* env); + }; + + struct axiom_mtom_caching_callback + { + axiom_mtom_caching_callback_ops_t *ops; + axutil_param_t *param; + void *user_param; + }; + + /*************************** Function macros **********************************/ +#define AXIOM_MTOM_CACHING_CALLBACK_INIT_HANDLER(mtom_caching_callback, env, key) \ + ((mtom_caching_callback)->ops->init_handler(mtom_caching_callback, env, key)) + +#define AXIOM_MTOM_CACHING_CALLBACK_CACHE(mtom_caching_callback, env, data, length, handler) \ + ((mtom_caching_callback)->ops->cache(mtom_caching_callback, env, data, length, handler)) + +#define AXIOM_MTOM_CACHING_CALLBACK_CLOSE_HANDLER(mtom_caching_callback, env, handler) \ + ((mtom_caching_callback)->ops->close_handler(mtom_caching_callback, env, handler)) + +#define AXIOM_MTOM_CACHING_CALLBACK_FREE(mtom_caching_callback, env) \ + ((mtom_caching_callback)->ops->free(mtom_caching_callback, env)) + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_MTOM_CACHING_CALLBACK */ + + diff --git a/axiom/include/axiom_mtom_sending_callback.h b/axiom/include/axiom_mtom_sending_callback.h new file mode 100644 index 0000000..ce2587e --- /dev/null +++ b/axiom/include/axiom_mtom_sending_callback.h @@ -0,0 +1,112 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef AXIOM_MTOM_SENDING_CALLBACK_H +#define AXIOM_MTOM_SENDING_CALLBACK_H + +/** + * @file axiom_mtom_sending_callback.h + * @brief sending callback for attachment sending + */ + +/** +* @defgroup mtom_sending_callback +* @ingroup axiom +* @{ +*/ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * Type name for struct axiom_mtom_sending_callback_ops + */ + typedef struct axiom_mtom_sending_callback_ops axiom_mtom_sending_callback_ops_t; + + /** + * Type name for struct axiom_mtom_sending_callback + */ + typedef struct axiom_mtom_sending_callback axiom_mtom_sending_callback_t; + + + /** + * init_handler will init the attachment storage + */ + + /** + * load will read the attachemnt by part from the storage + */ + + /** + * close_handler will close the storage + */ + + struct axiom_mtom_sending_callback_ops + { + void* (AXIS2_CALL* + init_handler)(axiom_mtom_sending_callback_t *mtom_sending_callback, + const axutil_env_t* env, + void *user_param); + + int (AXIS2_CALL* + load_data)(axiom_mtom_sending_callback_t *mtom_sending_callback, + const axutil_env_t* env, + void *handler, + axis2_char_t **buffer); + + axis2_status_t (AXIS2_CALL* + close_handler)(axiom_mtom_sending_callback_t *mtom_sending_callback, + const axutil_env_t* env, + void *handler); + + axis2_status_t (AXIS2_CALL* + free)(axiom_mtom_sending_callback_t *mtom_sending_callback, + const axutil_env_t* env); + }; + + struct axiom_mtom_sending_callback + { + axiom_mtom_sending_callback_ops_t *ops; + axutil_param_t *param; + }; + + /*************************** Function macros **********************************/ +#define AXIOM_MTOM_SENDING_CALLBACK_INIT_HANDLER(mtom_sending_callback, env, user_param) \ + ((mtom_sending_callback)->ops->init_handler(mtom_sending_callback, env, user_param)) + +#define AXIOM_MTOM_SENDING_CALLBACK_LOAD_DATA(mtom_sending_callback, env, handler, buffer) \ + ((mtom_sending_callback)->ops->load_data(mtom_sending_callback, env, handler, buffer)) + +#define AXIOM_MTOM_SENDING_CALLBACK_CLOSE_HANDLER(mtom_sending_callback, env, handler) \ + ((mtom_sending_callback)->ops->close_handler(mtom_sending_callback, env, handler)) + +#define AXIOM_MTOM_SENDING_CALLBACK_FREE(mtom_sending_callback, env) \ + ((mtom_sending_callback)->ops->free(mtom_sending_callback, env)) + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_MTOM_SENDING_CALLBACK */ + + diff --git a/axiom/include/axiom_namespace.h b/axiom/include/axiom_namespace.h new file mode 100644 index 0000000..73ccf17 --- /dev/null +++ b/axiom/include/axiom_namespace.h @@ -0,0 +1,201 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_NAMESPACE_H +#define AXIOM_NAMESPACE_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_namespace namespace + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_namespace axiom_namespace_t; + + /** + * Creates a namespace struct + * @param uri namespace URI + * @param prefix namespace prefix + * @return a pointer to newly created namespace struct + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_namespace_create( + const axutil_env_t * env, + const axis2_char_t * uri, + const axis2_char_t * prefix); + + /** + * Frees given AXIOM namespcae + * @param om_namespace namespace to be freed. + * @param env Environment. MUST NOT be NULL. + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_namespace_free( + struct axiom_namespace *om_namespace, + const axutil_env_t * env); + + /** + * Compares two namepsaces + * @param om_namespace first namespase to be compared + * @param env Environment. MUST NOT be NULL. + * @param om_namespace1 second namespace to be compared + * @return AXIS2_TRUE if the two namespaces are equal,AXIS2_FALSE otherwise + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_namespace_equals( + struct axiom_namespace *om_namespace, + const axutil_env_t * env, + struct axiom_namespace *om_namespace1); + + /** + * Serializes given namespace + * @param om_namespace namespace to be serialized. + * @param env Environment. MUST NOT be NULL. + * @param om_output AXIOM output handler to be used in serializing + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_namespace_serialize( + struct axiom_namespace *om_namespace, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** + * @param om_namespace pointer to om_namespace struct + * @param env environment , MUST NOT be NULL. + * @returns namespace uri , NULL on error + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_namespace_get_uri( + struct axiom_namespace *om_namespace, + const axutil_env_t * env); + + /** + * @param om_namespace pointer to om namespace struct + * @param env environment, MUST NOT be NULL + * @return prefix , NULL on error + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_namespace_get_prefix( + struct axiom_namespace *om_namespace, + const axutil_env_t * env); + + /** + * Clones an om_namespace struct + * @param om_namespace pointer to namespace struct + * @param env Environment. MUST NOT be NULL + * @returns axiom_namespace on success , NULL on error + */ + AXIS2_EXTERN struct axiom_namespace *AXIS2_CALL + axiom_namespace_clone( + struct axiom_namespace *om_namespace, + const axutil_env_t * env); + + /** + * to string , returns the string by combining namespace_uri, + * and prefix seperated by a '|' character + * @param om_namespace + * @param env Environment. MUST NOT be NULL + * @returns pointer to string , This is a property of namespace, + * should not be freed by user + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_namespace_to_string( + struct axiom_namespace *om_namespace, + const axutil_env_t * env); + + /** + * Incerament the reference value. The struct will be freed when the ref value is zero + * @param om_namespace pointer to the axiom namespace struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_namespace_increment_ref( + struct axiom_namespace *om_namespace, + const axutil_env_t * env); + + /** + * Create an OM namespace from a URI and a Prefix + * @param om_namespace pointer to the axiom namespace struct + * @param env Environment. MUST NOT be NULL + * + * @return created OM namespace + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_namespace_create_str( + const axutil_env_t * env, + axutil_string_t * uri, + axutil_string_t * prefix); + + /** + * Set the uri string + * @param om_namespace pointer to the axiom namespace struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_namespace_set_uri_str( + axiom_namespace_t * om_namespace, + const axutil_env_t * env, + axutil_string_t * uri); + + /** + * Get the uri as a string + * @param om_namespace pointer to the axiom namespace struct + * @param env Environment. MUST NOT be NULL + * + * @return the uri as a string + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axiom_namespace_get_uri_str( + axiom_namespace_t * om_namespace, + const axutil_env_t * env); + + /** + * Get the prefix as a string + * @param om_namespace pointer to the axiom namespace struct + * @param env Environment. MUST NOT be NULL + * + * @return the prefix as a string + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axiom_namespace_get_prefix_str( + axiom_namespace_t * om_namespace, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_NAMESPACE */ diff --git a/axiom/include/axiom_navigator.h b/axiom/include/axiom_navigator.h new file mode 100644 index 0000000..6ff8b53 --- /dev/null +++ b/axiom/include/axiom_navigator.h @@ -0,0 +1,121 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_NAVIGATOR_H +#define AXIOM_NAVIGATOR_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_navigator navigator + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_navigator axiom_navigator_t; + + /** Creates an axiom_navigator + * @param env environment MUST not be NULL + * @param node a pointer to axiom_node_t struct + * which is to be navigated + * @returns a pointer to axiom_navigator_t struct + * or returns NULL on error + */ + AXIS2_EXTERN axiom_navigator_t *AXIS2_CALL + axiom_navigator_create( + const axutil_env_t * env, + axiom_node_t * node); + + /** + * free function , free the axiom_navigator struct + * @param om_navigator axiom_navigator_struct + * @param env environment MUST not be NULL + * @returns AXIS2_SUCCESS + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_navigator_free( + axiom_navigator_t * om_navigator, + const axutil_env_t * env); + + /** + * Returns the navigable status + * @param om_navigator axiom_navigator_struct + * @param env environment MUST not be NULL + * @returns AXIS2_TRUE if the om is navigable + * otherwise returns AXIS2_FALSE + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_navigator_is_navigable( + axiom_navigator_t * om_navigator, + const axutil_env_t * env); + + /** + * Returns the build status of this node + * if the node is completly build returns AXIS2_TRUE + * otherwise AXIS2_FALSE + * @param om_navigator axiom_navigator struct + * @param env environment MUST not be NULL + * @return AXIS2_TRUE if this node is completly built + * otherwise return AXIS2_FALSE + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_navigator_is_completed( + axiom_navigator_t * om_navigator, + const axutil_env_t * env); + + /** + * gets the next node + * @param om_navigator om_navigaot struct + * @param env environment MUST not be NULL + * @returns axiom_node_t pointer in the sequence of preorder travasal + * however the an element node is treated slightly differently + * Once the om_element type om node is passed it returns the same om_node + * pointer in the next , returns NULL on error or if there is no more nodes + */ + + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_navigator_next( + axiom_navigator_t * om_navigator, + const axutil_env_t * env); + + /** + * method visited + * @param om_navigator om_navigaot struct + * @param env environment MUST not be NULL + * @returns AXIS2_TRUE if this node is alrady visited + * otherwise AXIS2_FALSE + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_navigator_visited( + axiom_navigator_t * om_navigator, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_NAVIGATOR_H */ diff --git a/axiom/include/axiom_node.h b/axiom/include/axiom_node.h new file mode 100644 index 0000000..dd5c320 --- /dev/null +++ b/axiom/include/axiom_node.h @@ -0,0 +1,379 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_NODE_H +#define AXIOM_NODE_H + +/** + * @defgroup axiom AXIOM project + * @{ + * @} + */ + +/** + * @defgroup axiom_om AXIOM + * @ingroup axiom + * @{ + * @} + */ + +/** + * @file axiom_node.h + * @brief defines axiom_node struct + */ +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_node axiom_node_t; + struct axiom_output; + struct axiom_document; + struct axiom_stax_builder; + + /** + * @defgroup axiom_node node + * @ingroup axiom_om + * @{ + */ + + /** + * @brief AXIOM types + */ + typedef enum axiom_types_t + { + + /** Invalid node type */ + AXIOM_INVALID = 0, + + /** AXIOM document type */ + AXIOM_DOCUMENT, + + /** AXIOM element type */ + AXIOM_ELEMENT, + + /** AXIOM doctype type */ + AXIOM_DOCTYPE, + + /** AXIOM comment type */ + AXIOM_COMMENT, + + /** AXIOM attribute type */ + AXIOM_ATTRIBUTE, + + /** AXIOM namespace type */ + AXIOM_NAMESPACE, + + /** AXIOM processing instruction type */ + AXIOM_PROCESSING_INSTRUCTION, + + /** AXIOM text type */ + AXIOM_TEXT, + + /** AXIOM data source, represent a serialized XML fragment with a stream */ + AXIOM_DATA_SOURCE + } axiom_types_t; + + /** + * Creates a node struct. + * @param env Environment. MUST NOT be NULL, . + * @return a pointer to newly created node struct. NULL on error. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_create( + const axutil_env_t * env); + + /** + * Creates a node struct from a character buffer. + * @param env Environment. MUST NOT be NULL, . + * @param buffer string. buffer to make the node + * @return a pointer to newly created node struct. NULL on error. + */ + AXIS2_EXTERN axiom_node_t* AXIS2_CALL + axiom_node_create_from_buffer( + const axutil_env_t * env, + axis2_char_t *buffer); + + + /** + * Frees an om node and all of its children. Please note that the attached + * data_element will also be freed along with the node. If the node is + * still attached to a parent, it will be detached first, then freed. + * @param om_node node to be freed. + * @param env Environment. MUST NOT be NULL, . + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_node_free_tree( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * Adds given node as child to parent. child should not have a parent + * if child has a parent it will be detached from existing parent + * @param om_node parent node. cannot be NULL. + * @param env Environment. MUST NOT be NULL, . + * @param child child node. + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_add_child( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * child); + + /** + * Detaches given node from the parent and reset the links + * @param om_node node to be detached, cannot be NULL. + * @param env Environment. MUST NOT be NULL, . + * @return a pointer to detached node,returns NULL on error with error + * code set to environment's error struct + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_detach( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * Inserts a sibling node after the given node + * @param om_node node to whom the sibling to be inserted. , cannot be NULL. + * @param env Environment. MUST NOT be NULL, . + * @param node_to_insert the node to be inserted. , cannot be NULL. + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_insert_sibling_after( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * node_to_insert); + + /** + * Inserts a sibling node before the given current node + * @param om_node node to whom the sibling to be inserted. , cannot be NULL. + * @param env Environment. MUST NOT be NULL, . + * @param node_to_insert the node to be inserted. , cannot be NULL. + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_insert_sibling_before( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * node_to_insert); + + /** + * Serializes the given node. This op makes the node go + * through its children and serialize them in order. + * @param om_node node to be serialized. cannot be NULL. + * @param env Environment .MUST NOT be NULL. + * @param om_output AXIOM output handler to be used in serializing + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_serialize( + axiom_node_t * om_node, + const axutil_env_t * env, + struct axiom_output *om_output); + + /** get parent of om_node + *@om_node node + *@param env environment + *@return pointer to parent node of om_node, return NULL if no parent exists or + * when an error occured. + */ + + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_get_parent( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * get the first child of om_node + * @param om_node node + * @param env environment must not be null. + * @returns pointer to first child node , NULL is returned on error with + * error code set in environments error + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_get_first_child( + axiom_node_t * om_node, + const axutil_env_t * env); + + /**get the first AXIOM_ELEMENT in om_node + * @param om_node node + * @param env environment must not be null + * @returns pointer to first child om element, NULL is returned on error + * with error code set in environments error. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_get_first_element( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * get the last child + * @param om_node node + * @param env environment, MUST NOT be NULL + * @return pointer to last child of this node , return NULL on error. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_get_last_child( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * get the previous sibling + * @param om_node om_node struct + * @param env environment , must node be null + * @returns a pointer to previous sibling , NULL if a previous sibling does not exits + * (happens when this node is the first child of a node ) + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_get_previous_sibling( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * get next sibling + * @param om_node om_node struct + * @param env environment, MUST NOT be NULL. + * @return next sibling of this node. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_node_get_next_sibling( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * get the node type of this element + * Node type can be one of AXIOM_ELEMENT, AXIOM_COMMENT, AXIOM_TEXT + * AXIOM_DOCTYPE, AXIOM_PROCESSING_INSTRUCTION + * @param om_node node of which node type is required + * @param env environment + * @return node type + */ + AXIS2_EXTERN axiom_types_t AXIS2_CALL + axiom_node_get_node_type( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * get the struct contained in the node + * IF the node is on type AXIOM_ELEMENT , this method returns + * a pointer to axiom_element_t struct contained + * @param om_node node + * @param env environment, MUST NOT be NULL. + * @returns pointer to struct contained in the node + * returns NULL if no struct is contained + */ + AXIS2_EXTERN void *AXIS2_CALL + axiom_node_get_data_element( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * Indicates whether parser has parsed this information item completely or not + * @param om_node om_node struct + * @param env environment, MUST NOT be NULL. + * @returns AXIS2_TRUE if node is completly build, + * AXIS2_FALSE if node is not completed + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_node_is_complete( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * returns the associated document, + * only valid if built using builder and for a node of type + * AXIOM_ELEMENT + * returns null if no document is available + * @param om_node + * @param env environment, MUST NOT be NULL. + * + * @return the OM document of the node + */ + AXIS2_EXTERN struct axiom_document *AXIS2_CALL + axiom_node_get_document( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * + * @param om_node pointer to the OM node struct + * @param env environment, MUST NOT be NULL + * + * @return the string representation of the node + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_node_to_string( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * + * @param om_node pointer to the OM node struct + * @param env environment, MUST NOT be NULL + * @param om_output the serialized output will be placed here + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_serialize_sub_tree( + axiom_node_t * om_node, + const axutil_env_t * env, + struct axiom_output *om_output); + + /** + * + * @param om_node pointer to the OM node struct + * @param env environment, MUST NOT be NULL + * + * @return the tree as a string + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_node_sub_tree_to_string( + axiom_node_t * om_node, + const axutil_env_t * env); + + /** + * Convert the node to string, treating the binary contents, if any, + * as non-optimized content. + * @param om_node pointer to the OM node struct + * @param env environment, MUST NOT be NULL + * + * @return the none optimized string + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_node_to_string_non_optimized( + axiom_node_t * om_node, + const axutil_env_t * env); + + AXIS2_EXTERN struct axiom_stax_builder *AXIS2_CALL + axiom_node_get_builder( + axiom_node_t * om_node, + const axutil_env_t * env); + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_NODE_H */ diff --git a/axiom/include/axiom_output.h b/axiom/include/axiom_output.h new file mode 100644 index 0000000..18b524b --- /dev/null +++ b/axiom/include/axiom_output.h @@ -0,0 +1,254 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_OUTPUT_H +#define AXIOM_OUTPUT_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_output output + * @ingroup axiom_om + * @{ + */ + + /** + * \brief output struct + * The XML writer interface struct of om + */ + typedef struct axiom_output axiom_output_t; + struct axiom_text; + + /** + * Creates AXIOM output struct + * @param env Environment. MUST NOT be NULL, . + * @param xml_writer XML writer. OM output takes + * ownership of the xml_writer. + * @return a pointer to newly created output struct. + */ + AXIS2_EXTERN axiom_output_t *AXIS2_CALL + axiom_output_create( + const axutil_env_t * env, + axiom_xml_writer_t * xml_writer); + + /** + * Performs xml writing. + * Accepts variable number of args depending on the on AXIOM type to be serialized + * @param om_output Output struct to be used + * @param env Environment. MUST NOT be NULL, + * @param type one of the AXIOM types + * @param no_of_args number of arguments passed in the variable parameter list + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_write( + axiom_output_t * om_output, + const axutil_env_t * env, + axiom_types_t type, + int no_of_args, + ...); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_write_optimized( + axiom_output_t * om_output, + const axutil_env_t * env, + struct axiom_text *om_text); + + /** + * Free om_output + * @param om_output om_output struct + * @param env environment + * @return status code AXIS2_SUCCESS on success, + * AXIS2_FAILURE otherwise + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_output_free( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * If the xml to be serialized is soap 11, this property is set to true + * @param om_output pointer to om_output struct + * @param env environment must not be NULL + * @returns the output soap version + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_output_is_soap11( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * @returns true if the ignore_xml_declaration property is true + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + + axiom_output_is_ignore_xml_declaration( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * Sets the ignore_xml_declaration property is true + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_output_set_ignore_xml_declaration( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_bool_t ignore_xml_dec); + + /** + * Sets the soap11 property to true + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_set_soap11( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_bool_t soap11); + + /** + * Sets xml_version property + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_set_xml_version( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_char_t * xml_version); + + /** + * @returns xml version property + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_output_get_xml_version( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * Sets the char set encoding property + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_set_char_set_encoding( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_char_t * char_set_encoding); + + /** + * @returns the char set encoding property + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_output_get_char_set_encoding( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * Sets the do optimize property true + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_set_do_optimize( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_bool_t optimize); + + /** + * Returns the xml writer + */ + AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL + axiom_output_get_xml_writer( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * Returns the content type + * for soap11 'text/xml' etc.. + * @param om_output + * @param env environemnt + * @returns content id + */ + AXIS2_EXTERN const axis2_char_t *AXIS2_CALL + axiom_output_get_content_type( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * Writes the xml versio encoding + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_write_xml_version_encoding( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * @returns whether the output is to be optimized + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_output_is_optimized( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * Returns the next content id + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_output_get_next_content_id( + axiom_output_t * om_output, + const axutil_env_t * env); + + /** + * root content id + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_output_get_root_content_id( + axiom_output_t * om_output, + const axutil_env_t * env); + /** + * + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_output_get_mime_boundry( + axiom_output_t * om_output, + const axutil_env_t * env); + /** + * + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_output_flush( + axiom_output_t * om_output, + const axutil_env_t * env); + + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axiom_output_get_mime_parts( + axiom_output_t * om_output, + const axutil_env_t * env); + + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_OUTPUT_H */ diff --git a/axiom/include/axiom_processing_instruction.h b/axiom/include/axiom_processing_instruction.h new file mode 100644 index 0000000..24fcdc9 --- /dev/null +++ b/axiom/include/axiom_processing_instruction.h @@ -0,0 +1,136 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_PI_H +#define AXIOM_PI_H + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_processing_instruction pocessing instruction + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_processing_instruction + axiom_processing_instruction_t; + + /** + * Creates a processing instruction + * @param environment Environment. MUST NOT be NULL. + * @param parent parent of the element node to be created. Optional, can be NULL. + * @param target target of the processing instruction.cannot be NULL. + * @param value value of the processing instruction.cannot be NULL. + * @param node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the comment created. + * Node type will be set to AXIOM_PROCESSING_INSTRUCTION + * @return a pointer tonewly created processing instruction struct + */ + AXIS2_EXTERN axiom_processing_instruction_t *AXIS2_CALL + axiom_processing_instruction_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * target, + const axis2_char_t * value, + axiom_node_t ** node); + + /** + * Frees an instance of axiom_processing_instruction + * @param om_pi processing instruction to be freed. + * @param env Environment. MUST NOT be NULL, . + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_processing_instruction_free( + struct axiom_processing_instruction *om_pi, + const axutil_env_t * env); + + /** + * Set processing instruction data + * @param om_pi + * @param env Environment. MUST NOT be NULL, . + * @param value + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_processing_instruction_set_value( + struct axiom_processing_instruction *om_pi, + const axutil_env_t * env, + const axis2_char_t * value); + + /** + * Set processing instruction target + * @param om_pi processing_instruction struct + * @param env environment, MUST NOT be NULL. + * @param target + * @return status of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_processing_instruction_set_target( + struct axiom_processing_instruction *om_pi, + const axutil_env_t * env, + const axis2_char_t * target); + + /** + * Get PI target + * @param om_pi processing_instruction struct + * @param env Environment. MUST NOT be NULL, . + * @return target text , NULL on error or if target is null + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_processing_instruction_get_target( + struct axiom_processing_instruction *om_pi, + const axutil_env_t * env); + + /** + * Get data part of processing_instruction + * @param om_pi processing instruction + * @param env environment , MUST NOT be NULL. + * @return data text , NULL if there is no data, + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_processing_instruction_get_value( + struct axiom_processing_instruction *om_pi, + const axutil_env_t * env); + + /** + * Serialize function + * @param om_pi processing_instruction struct + * @param env environment, MUST NOT be NULL. + * @param om_output om_output handler struct + * @return status of the op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_processing_instruction_serialize( + struct axiom_processing_instruction *om_pi, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_PI_H */ diff --git a/axiom/include/axiom_soap.h b/axiom/include/axiom_soap.h new file mode 100644 index 0000000..be0d956 --- /dev/null +++ b/axiom/include/axiom_soap.h @@ -0,0 +1,53 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_H +#define AXIOM_SOAP_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** +* @file axiom_soap.h +* @brief includes all SOAP related headers +*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_H */ diff --git a/axiom/include/axiom_soap_body.h b/axiom/include/axiom_soap_body.h new file mode 100644 index 0000000..203b584 --- /dev/null +++ b/axiom/include/axiom_soap_body.h @@ -0,0 +1,184 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_BODY_H +#define AXIOM_SOAP_BODY_H + +/** + * @file axiom_soap_body.h + * @brief axiom_soap_body struct + */ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_body axiom_soap_body_t; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_body soap body + * @ingroup axiom_soap + * @{ + */ + + /** + * a struct that represents the contents of the SOAP body + * element in a SOAP message. SOAP body element consists of XML data + * that affects the way the application-specific content is processed. + * soap_body_struct contains soap_header and + * which have the content for the SOAP body. + * this also contains axiom_soap_fault_t struct , which carries status and/or + * error information. + */ + + /** + * creates a soap body struct + * @param env Environment. MUST NOT be NULL + * @param envelope the SOAP envelope to set the SOAP Body + * @return created SOAP Body + */ + + AXIS2_EXTERN axiom_soap_body_t *AXIS2_CALL + axiom_soap_body_create_with_parent( + const axutil_env_t * env, + struct axiom_soap_envelope *envelope); + + /** + * Deallocate all the resources associated to soap_body + * But it does not deallocate the underlying om structure + * @param body soap_body struct + * @param env must not be null + * @return status code AXIS2_SUCCESS + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_body_free( + axiom_soap_body_t * body, + const axutil_env_t * env); + + /** + * Indicates whether a soap fault is available with this + * soap body + * @param body soap_body struct + * @param env environment must not be null + * @return AXIS2_TRUE if fault is available, AXIS2_FALSE otherwise + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_soap_body_has_fault( + axiom_soap_body_t * body, + const axutil_env_t * env); + + /** + * returns the soap fault in this soap_body + * IF a soap_builder is associated with the soap_body + * Pulling will take place + * @param body soap_body + * @param env environment must not be null + * @return axiom_soap_fault_t if available, NULL otherwise + */ + AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL + axiom_soap_body_get_fault( + axiom_soap_body_t * body, + const axutil_env_t * env); + + /** + * get the underlying om_node + * @param body soap_body + * @param env environment must not be null + * @returns axiom_node_t + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_body_get_base_node( + axiom_soap_body_t * body, + const axutil_env_t * env); + + /** + * return the soap version + * @param body soap_body + * @param env environment must not be null + * @return one of AXIOM_SOAP11 or AXIOM_SOAP12 + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_body_get_soap_version( + axiom_soap_body_t * body, + const axutil_env_t * env); + + /** + * build the soap body completely . return the status code, + * @param body pointer to soap_body struct + * @param env axutil_environment struct MUST not be NULL + * @returns status code , AXIS2_SUCCESS on success , AXIS2_ERROR + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_body_build( + axiom_soap_body_t * body, + const axutil_env_t * env); + + /** add an om node as the child to this soap_body + * the child is added to as the first child + * @param body pointer to soap_body struct + * @param env axutil_environment struct MUST not be NULL + * @returns status code , AXIS2_SUCCESS on success , AXIS2_ERROR + * otherwise + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_body_add_child( + axiom_soap_body_t * body, + const axutil_env_t * env, + axiom_node_t * child); + + /** + * SOAP builder construct a SOAP 1.2 fault all the time. + * So when SOAP 1.1 is in use, we should convert SOAP fault to + * SOAP 1.1 fault format before use. + * @param body pointer to soap_body struct + * @param env axutil_environment struct MUST not be NULL + * @returns status code , AXIS2_SUCCESS on success , AXIS2_ERROR + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_body_convert_fault_to_soap11( + axiom_soap_body_t * soap_body, + const axutil_env_t * env); + + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_body_process_attachments( + axiom_soap_body_t * soap_body, + const axutil_env_t * env, + void *user_param, + axis2_char_t *callback_name); + + AXIS2_EXTERN struct axiom_soap_builder *AXIS2_CALL + axiom_soap_body_get_builder( + axiom_soap_body_t * soap_body, + const axutil_env_t * env); + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_BODY_H */ diff --git a/axiom/include/axiom_soap_builder.h b/axiom/include/axiom_soap_builder.h new file mode 100644 index 0000000..9fffb78 --- /dev/null +++ b/axiom/include/axiom_soap_builder.h @@ -0,0 +1,253 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_BUILDER_H +#define AXIOM_SOAP_BUILDER_H + +#include +#include +#include + +/** + * @file axiom_soap_builder.h + * @brief axiom_soap_builder struct + */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_builder axiom_soap_builder_t; + + /** + * @defgroup axiom_soap_builder soap builder + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a axiom_soap_builder struct + * @param env Environment. MUST NOT be NULL + * @param builder Stax builder + * @return the created SOAP Builder + */ + AXIS2_EXTERN axiom_soap_builder_t *AXIS2_CALL + axiom_soap_builder_create( + const axutil_env_t * env, + axiom_stax_builder_t * builder, + const axis2_char_t * soap_version); + /** + * Free the SOAP Builder + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_builder_free( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * Get the SOAP envelope of the SOAP builder + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP envelope + */ + AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL + axiom_soap_builder_get_soap_envelope( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * Get the OM document of the SOAP Buidler + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return the OM document + */ + AXIS2_EXTERN axiom_document_t *AXIS2_CALL + axiom_soap_builder_get_document( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * Builds next element of the OM structure + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * @return AXIS2_SUCCESS if the next element is present else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_builder_next( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return the axiom_node of the OM document + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_builder_get_document_element( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_builder_set_bool_processing_mandatory_fault_elements( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + axis2_bool_t value); + + /** + * + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_builder_set_processing_detail_elements( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + axis2_bool_t value); + + /** + * + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_TRUE if the the element is present, AXIS2_FALSE otherwise + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_soap_builder_is_processing_detail_elements( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * Get the SOAP version + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP version + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_builder_get_soap_version( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * Set the MIME body parts + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_builder_set_mime_body_parts( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + axutil_hash_t * map); + + /** + * Get the MIME body parts + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * + * @return hash of mime body parts + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_soap_builder_get_mime_body_parts( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + /** + * Set the mime_parser + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * @paran mime_parser pointer to a axiom_mime_parser_t instance + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_builder_set_mime_parser( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + axiom_mime_parser_t *mime_parser); + + /** + * Set the callback function + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * @param callback to the callback function pointer + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_builder_set_callback_function( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback); + + /** + * Set the callback_ctx + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * @param void pointer to the callback_ctx + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_builder_set_callback_ctx( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + void *callback_ctx); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_builder_create_attachments( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + void *user_param, + axis2_char_t *callback_name); + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_soap_builder_replace_xop( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + axiom_node_t *om_element_node, + axiom_element_t *om_element); + + AXIS2_EXTERN axiom_stax_builder_t *AXIS2_CALL + axiom_soap_builder_get_om_builder( + axiom_soap_builder_t * builder, + const axutil_env_t * env); + + + + /** @} */ +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_SOAP_BUILDER_H */ diff --git a/axiom/include/axiom_soap_const.h b/axiom/include/axiom_soap_const.h new file mode 100644 index 0000000..3d5933b --- /dev/null +++ b/axiom/include/axiom_soap_const.h @@ -0,0 +1,176 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_CONST_H +#define AXIOM_SOAP_CONST_H + +/** +* @file axiom_soap.h +* @brief defines SOAP constants +*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap SOAP + * @ingroup axiom + * @{ + * @} + */ + typedef enum soap_version + { + AXIOM_SOAP_VERSION_NOT_SET = 0, + + AXIOM_SOAP11, + + AXIOM_SOAP12 + } axiom_soap_version; + + /** soap 11 constants */ + +#define AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI "http://schemas.xmlsoap.org/soap/envelope/" + +#define AXIOM_SOAP11_ATTR_ACTOR "actor" + +#define AXIOM_SOAP11_SOAP_FAULT_CODE_LOCAL_NAME "faultcode" + +#define AXIOM_SOAP11_SOAP_FAULT_STRING_LOCAL_NAME "faultstring" + +#define AXIOM_SOAP11_SOAP_FAULT_ACTOR_LOCAL_NAME "faultactor" + +#define AXIOM_SOAP11_SOAP_FAULT_DETAIL_LOCAL_NAME "detail" + +#define AXIOM_SOAP11_CONTENT_TYPE "text/xml" + +#define AXIOM_SOAP11_FAULT_CODE_SENDER "Client" + +#define AXIOM_SOAP11_FAULT_CODE_RECEIVER "Server" + +#define AXIOM_SOAP11_SOAP_ACTOR_NEXT "http://schemas.xmlsoap.org/soap/actor/next" + + /** soap12 constants */ + +#define AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI "http://www.w3.org/2003/05/soap-envelope" + +#define AXIOM_SOAP12_SOAP_ROLE "role" + +#define AXIOM_SOAP12_SOAP_RELAY "relay" + +#define AXIOM_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME "Code" + +#define AXIOM_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME "Subcode" + +#define AXIOM_SOAP12_SOAP_FAULT_VALUE_LOCAL_NAME "Value" + +#define AXIOM_SOAP12_SOAP_FAULT_VALUE_VERSION_MISMATCH "VersionMismatch" + +#define AXIOM_SOAP12_SOAP_FAULT_VALUE_MUST_UNDERSTAND "MustUnderstand" + +#define AXIOM_SOAP12_SOAP_FAULT_VALUE_DATA_ENCODING_UKNOWN "DataEncodingUnknown" + +#define AXIOM_SOAP12_SOAP_FAULT_VALUE_SENDER "Sender" + +#define AXIOM_SOAP12_SOAP_FAULT_VALUE_RECEIVER "Receiver" + + /** SOAP Fault */ + +#define AXIOM_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME "Reason" + +#define AXIOM_SOAP12_SOAP_FAULT_TEXT_LOCAL_NAME "Text" + +#define AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME "lang" + +#define AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_NS_URI "http://www.w3.org/XML/1998/namespace" + +#define AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_NS_PREFIX "xml" + +#define AXIOM_SOAP12_SOAP_FAULT_NODE_LOCAL_NAME "Node" + +#define AXIOM_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME "Detail" + +#define AXIOM_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME "Role" + +#define AXIOM_SOAP12_CONTENT_TYPE "application/soap+xml" + +#define AXIOM_SOAP12_FAULT_CODE_SENDER "Sender" + +#define AXIOM_SOAP12_FAULT_CODE_RECEIVER "Receiver" + +#define AXIOM_SOAP12_SOAP_ROLE_NEXT "http://www.w3.org/2003/05/soap-envelope/role/next" + +#define AXIOM_SOAP12_SOAP_ROLE_NONE "http://www.w3.org/2003/05/soap-envelope/role/none" + +#define SOAP12_SOAP_ROLE_ULTIMATE_RECEIVER "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver" + +#define AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX "soapenv" + +#define AXIOM_SOAP_ENVELOPE_LOCAL_NAME "Envelope" + +#define AXIOM_SOAP_HEADER_LOCAL_NAME "Header" + +#define AXIOM_SOAP_BODY_LOCAL_NAME "Body" + +#define AXIOM_SOAP_BODY_NAMESPACE_PREFIX AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX + +#define AXIOM_SOAP_BODY_FAULT_LOCAL_NAME "Fault" + + /** attribute must understand */ + +#define AXIOM_SOAP_ATTR_MUST_UNDERSTAND "mustUnderstand" + +#define AXIOM_SOAP_ATTR_MUST_UNDERSTAND_TRUE "true" + +#define AXIOM_SOAP_ATTR_MUST_UNDERSTAND_FALSE "false" + +#define AXIOM_SOAP_ATTR_MUST_UNDERSTAND_0 "0" + +#define AXIOM_SOAP_ATTR_MUST_UNDERSTAND_1 "1" + +#define AXIOM_SOAP_FAULT_LOCAL_NAME "Fault" + +#define AXIOM_SOAP_FAULT_DETAIL_LOCAL_NAME "detail" + +#define AXIOM_SOAP_FAULT_NAMESPACE_PREFIX AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX + +#define AXIOM_SOAP_FAULT_DETAIL_EXCEPTION_ENTRY "Exception" + +#define AXIOM_SOAP_FAULT_CODE_VERSION_MISMATCH "soapenv:VersionMismatch" + +#define AXIOM_SOAP_FAULT_CODE_MUST_UNDERSTAND "soapenv:MustUnderstand" + +#define AXIOM_SOAP_FAULT_CODE_DATA_ENCODING_UNKNOWN "soapenv:DataEncodingUnknown" + +#define AXIOM_SOAP_FAULT_CODE_SENDER "" + +#define AXIOM_SOAP_FAULT_CODE_RECEIVER "" + + /* MTOM related */ + +#define AXIS2_XOP_NAMESPACE_URI "http://www.w3.org/2004/08/xop/include" + +#define AXIS2_XOP_INCLUDE "Include" + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_CONSTANTS_H */ diff --git a/axiom/include/axiom_soap_envelope.h b/axiom/include/axiom_soap_envelope.h new file mode 100644 index 0000000..24b8645 --- /dev/null +++ b/axiom/include/axiom_soap_envelope.h @@ -0,0 +1,244 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_ENVELOPE_H +#define AXIOM_SOAP_ENVELOPE_H + +/** + * @file axiom_soap_envelope.h + * @brief axiom_soap_envelope struct + * corresponds to root element of soap message + */ +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_envelope axiom_soap_envelope_t; + + struct axiom_soap_body; + struct axiom_soap_header; + struct axiom_soap_header_block; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_envelope soap envelope + * @ingroup axiom_soap + * @{ + */ + + /** + * create a soap_envelope with the given namespace prefix and uri + * as the prefix and uri, The uri of ns should be valid soap uri + * @param env Environment. MUST NOT be NULL + * @param ns The OM namespace + * + * @return Created SOAP envelope + */ + AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL + axiom_soap_envelope_create( + const axutil_env_t * env, + axiom_namespace_t * ns); + + /** + * create a soap_envelope with the given namespace prefix and uri is selected + * according to soap_version, soap version should be one of AXIOM_SOAP11 + * or AXIOM_SOAP12 + * @param env Environment. MUST NOT be NULL + * @param prefix soap envelope prefix + * if prefix is NULL default prefix is used + * + * @return a pointer to soap envelope struct + */ + AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL + axiom_soap_envelope_create_with_soap_version_prefix( + const axutil_env_t * env, + int soap_version, + const axis2_char_t * prefix); + + /** + * Create the default SOAP envelope + * @param envelope OM SOAP Envelope + * @param env Environment. MUST NOT be NULL + * + * @return Created SOAP envelope + */ + AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL + axiom_soap_envelope_create_default_soap_envelope( + const axutil_env_t * env, + int soap_version); + + /** + * Create the default SOAP fault envelope + * @param envelope OM SOAP Envelope + * @param env Environment. MUST NOT be NULL + * + * @return Created SOAP fault envelope + */ + AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL + axiom_soap_envelope_create_default_soap_fault_envelope( + const axutil_env_t * env, + const axis2_char_t * code_value, + const axis2_char_t * reason_text, + const int soap_version, + axutil_array_list_t * sub_codes, + axiom_node_t * detail_node); + + /** + * gets the soap header of this soap envelope + * @param envelope soap envelope + * @param env environment must not be null + * @return soap header null it no header is present + */ + AXIS2_EXTERN struct axiom_soap_header *AXIS2_CALL + axiom_soap_envelope_get_header( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** + * Returns the soap body associated with this soap envelope + * @param envelope soap_envelope + * @param env environment + * @return soap_body + */ + AXIS2_EXTERN struct axiom_soap_body *AXIS2_CALL + axiom_soap_envelope_get_body( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** + * serialize function , serialize the soap envelope + * IF the soap version it set to soap11 the soap fault part is converted + * to soap11 fault even is the underlying soap fault is of soap12 type + * @param envelope soap envelope + * @param env environment must not be null + * @param om_output + * @param cache whether caching is enabled or not + * @return status code , AXIS2_SUCCESS if success , + * AXIS2_FAILURE otherwise + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_envelope_serialize( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env, + axiom_output_t * om_output, + axis2_bool_t cache); + + /** + * Free function, This function deallocate all the resources associated + * with the soap_envelope + * IT frees it's soap body and soap headers as well as the underlying + * om node tree by calling axiom_node_free_tree function + * @param envelope soap_envelope + * @param env environment + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_envelope_free( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** + * returns the om_node associated with this soap envelope + * @param envelope soap_envelope + * @param env environment + * @return axiom_node_t pointer + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_envelope_get_base_node( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** returns the soap version of this soap envelope + * @param envelope soap_envelope + * @param env environment must not be null + * @return soap_version AXIOM_SOAP12 or AXIOM_SOAP11 + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_envelope_get_soap_version( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** + * Return the soap envelope namespace + * @param envelope + * @param env + * @return axiom_namespace_t + */ + AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL + axiom_soap_envelope_get_namespace( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** + * Set the SOAP version + * @param envelope OM SOAP Envelope + * @param env Environment. MUST NOT be NULL + * @param soap_version, the SOAP version number. + * Must be either AXIOM_SOAP11 or AXIOM_SOAP12 + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_envelope_set_soap_version( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env, + int soap_version); + + /** + * Increment the reference number for the created instance + * @param envelope OM SOAP Envelope + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_envelope_increment_ref( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** + * get the soap builder of the envelope + * @param envelope OM SOAP Envelope + * @param env Environment. MUST NOT be NULL + * + * @return soap_builder struct related to the envelope + */ + AXIS2_EXTERN struct axiom_soap_builder *AXIS2_CALL + axiom_soap_envelope_get_soap_builder( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + AXIS2_EXTERN struct axiom_soap_builder *AXIS2_CALL + axiom_soap_envelope_get_builder( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_ENVELOPE_H */ diff --git a/axiom/include/axiom_soap_fault.h b/axiom/include/axiom_soap_fault.h new file mode 100644 index 0000000..d75ea3c --- /dev/null +++ b/axiom/include/axiom_soap_fault.h @@ -0,0 +1,215 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_FAULT_H +#define AXIOM_SOAP_FAULT_H + +/** + * @file axiom_soap_fault.h + * @brief axiom_soap_fault struct + */ +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault axiom_soap_fault_t; + + struct axiom_soap_fault_reason; + struct axiom_soap_fault_detail; + struct axiom_soap_fault_sub_code; + struct axiom_soap_fault_code; + struct axiom_soap_fault_node; + struct axiom_soap_fault_role; + struct axiom_soap_fault_text; + struct axiom_soap_fault_value; + struct axiom_soap_body; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_fault soap fault + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap fault struct + * @param env environment must not be NULL + * @param parent soap body struct to which this soap + * fault is the child + * @param env Environment. MUST NOT be NULL + * @returns pointer to axiom_soap_fault_t struct on success + * otherwise return NULL with error code set in environments error + */ + AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL + axiom_soap_fault_create_with_parent( + const axutil_env_t * env, + struct axiom_soap_body *parent); + + /** create an returns a axiom_soap_fault_t struct with a soap fault detail + * element and have this exceptio string as a text of a child of soap fault + * detail + * @param env environment must not be NULL + * @param parent soap body struct must not be NULL + * @param exceptio an error string must not be NULL + * @returns pointer to axiom_soap_fault_t on success , + * otherwise return NULL + */ + AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL + axiom_soap_fault_create_with_exception( + const axutil_env_t * env, + struct axiom_soap_body *parent, + axis2_char_t * exception); + + /** + * + * @param env environment must not be NULL + * @param parent soap body struct must not be NULL + * @param code_value + * @param reason_text + * @param soap_version + * + * @return the created default OM SOAP fault + */ + AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL + axiom_soap_fault_create_default_fault( + const axutil_env_t * env, + struct axiom_soap_body *parent, + const axis2_char_t * code_value, + const axis2_char_t * reason_text, + const int soap_version); + + /** + * Free an axiom_soap_fault + * @param fault pointer to soap_fault struct + * @param env Environment. MUST NOT be NULL + * @return status of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_free( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * this function returns a axiom_soap_fault_code struct + * if a fault code is associated with this soap fault + * only valid when called after building the soap fault + * @param fault soap fault struct + * @param env environment must not be NULL + * @returns pointer to soap_fault_code struct if one is associated + * with this soap_fault struct , NULL is returned otherwise + */ + AXIS2_EXTERN struct axiom_soap_fault_code *AXIS2_CALL + axiom_soap_fault_get_code( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * @param fault soap fault struct + * @param env environment must not be NULL + * @returns pointer to soap_fault_reason struct if one is associated + * with this soap_fault struct , NULL is returned otherwise + */ + + AXIS2_EXTERN struct axiom_soap_fault_reason *AXIS2_CALL + axiom_soap_fault_get_reason( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * @param fault soap fault struct + * @param env environment must not be NULL + * @returns pointer to soap_fault_node struct if one is associated + * with this soap_fault struct , NULL is returned otherwise + */ + AXIS2_EXTERN struct axiom_soap_fault_node *AXIS2_CALL + axiom_soap_fault_get_node( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * @param fault soap fault struct + * @param env environment must not be NULL + * @returns pointer to soap_fault_code struct if one is associated + * with this soap_fault struct , NULL is returned otherwise + */ + AXIS2_EXTERN struct axiom_soap_fault_role *AXIS2_CALL + axiom_soap_fault_get_role( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * @param fault soap fault struct + * @param env environment must not be NULL + * @returns a pointer to soap_fault_code struct if one is + * associated with this soap_fault struct , NULL is returned otherwise + */ + AXIS2_EXTERN struct axiom_soap_fault_detail *AXIS2_CALL + axiom_soap_fault_get_detail( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * @param fault soap fault struct + * @param env enviroment must not be NULL + * @returns a pointer to soap_fault_code struct if one is + * associated with this soap_fault struct , NULL is returned otherwise + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_fault_get_exception( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** + * set an error string + * @param fualt soap fault struct + * @param env enviroment must not be NULL + * @param exception error message to be stored on soap fault + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_set_exception( + axiom_soap_fault_t * fault, + const axutil_env_t * env, + axis2_char_t * exception); + + /** + * returns the axiom_node_t struct which is wrapped by + * this soap fault struct + * @param fault soap fault struct + * @param env environment must not be NULL + * @returns a pointer to axiom_node_t struct if an om node is associated + * with this soap fault struct, otherwise return NULL + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_get_base_node( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_H */ diff --git a/axiom/include/axiom_soap_fault_code.h b/axiom/include/axiom_soap_fault_code.h new file mode 100644 index 0000000..ccc2b46 --- /dev/null +++ b/axiom/include/axiom_soap_fault_code.h @@ -0,0 +1,120 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_FAULT_CODE_H +#define AXIOM_SOAP_FAULT_CODE_H + +/** + * @file axiom_soap_fault_code.h + * @brief axiom_soap_fault_code struct + */ +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_code axiom_soap_fault_code_t; + + struct axiom_soap_fault_value; + struct axiom_soap_fault_sub_code; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_fault_code soap fault code + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap fault code struct + * @param env Environment. MUST NOT be NULL + * @param fault_code the pointer to the AXIOM fault code struct + * + * @return + */ + AXIS2_EXTERN axiom_soap_fault_code_t *AXIS2_CALL + axiom_soap_fault_code_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault); + /** + * + * @param fault_code the pointer to the AXIOM fault code struct + * @param env Environment. MUST NOT be NULL + * + * @return + */ + AXIS2_EXTERN axiom_soap_fault_code_t *AXIS2_CALL + axiom_soap_fault_code_create_with_parent_value( + const axutil_env_t * env, + axiom_soap_fault_t * fault, + axis2_char_t * value); + + /** + * Free an axiom_soap_fault_code + * @param fault_code pointer to soap_fault_code struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_code_free( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env); + + /** + * @param fault_code the pointer to the AXIOM fault code struct + * @param env Environment. MUST NOT be NULL + * @returns axiom_soap_fault_sub_code struct if one is associated with + * this fault_code struct , otherwise teturns NULL + */ + + AXIS2_EXTERN struct axiom_soap_fault_sub_code *AXIS2_CALL + axiom_soap_fault_code_get_sub_code( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env); + + /** + * @param fault_code the pointer to the AXIOM fault code struct + * @param env Environment. MUST NOT be NULL + * @returns soap_fault_value if available + */ + AXIS2_EXTERN struct axiom_soap_fault_value *AXIS2_CALL + axiom_soap_fault_code_get_value( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env); + /** + * Get the base node of the SOAP fault + * @param fault_code the pointer to the AXIOM fault code struct + * @param env Environment. MUST NOT be NULL + * + * @return retrns the base node of the SOAP fault + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_code_get_base_node( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_SOAP_FAULT_CODE_H */ diff --git a/axiom/include/axiom_soap_fault_detail.h b/axiom/include/axiom_soap_fault_detail.h new file mode 100644 index 0000000..6d17a77 --- /dev/null +++ b/axiom/include/axiom_soap_fault_detail.h @@ -0,0 +1,111 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_FAULT_DETAIL_H +#define AXIOM_SOAP_FAULT_DETAIL_H + +/** + * @file axiom_soap_fault_detail.h + * @brief axiom_soap_fault_detail struct + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_detail axiom_soap_fault_detail_t; + + /** + * @defgroup axiom_soap_fault_detail soap fault detail + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap struct + * @param env Environment. MUST NOT be NULL + * @param fault The SOAP fault + * + * @return the created OM SOAP fault detail + */ + AXIS2_EXTERN axiom_soap_fault_detail_t *AXIS2_CALL + axiom_soap_fault_detail_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault); + + /** + * Free an axiom_soap_fault_detail + * @param fault_detail pointer to soap_fault_detail struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_detail_free( + axiom_soap_fault_detail_t * fault_detail, + const axutil_env_t * env); + + /** + * Adds a detail entry to the SOAP fault detail + * @param fault_detail pointer to soap_fault_detail struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_detail_add_detail_entry( + axiom_soap_fault_detail_t * fault_detail, + const axutil_env_t * env, + axiom_node_t * ele_node); + + /** + * Return all detail entries in the SOAP fault detail + * @param fault_detail pointer to soap_fault_detail struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axiom_children_iterator_t *AXIS2_CALL + axiom_soap_fault_detail_get_all_detail_entries( + axiom_soap_fault_detail_t * fault_detail, + const axutil_env_t * env); + + /** + * Returns the base node of the SOAP fault detail + * @param fault_detail pointer to soap_fault_detail struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_detail_get_base_node( + axiom_soap_fault_detail_t * fault_code, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_DETAIL_H */ diff --git a/axiom/include/axiom_soap_fault_node.h b/axiom/include/axiom_soap_fault_node.h new file mode 100644 index 0000000..b0a8313 --- /dev/null +++ b/axiom/include/axiom_soap_fault_node.h @@ -0,0 +1,112 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_FAULT_NODE_H +#define AXIOM_SOAP_FAULT_NODE_H + +/** + * @file axiom_soap_fault_node.h + * @brief axiom_soap_fault_node struct + */ +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_node axiom_soap_fault_node_t; + + /** + * @defgroup axiom_soap_fault_node soap fault node + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap fault node struct + * @param env Environment. MUST NOT be NULL + * @param fault_node pointer to soap_fault_node struct + * + * @return the created SOAP fault node + */ + AXIS2_EXTERN axiom_soap_fault_node_t *AXIS2_CALL + axiom_soap_fault_node_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault); + + /** + * Free an axiom_soap_fault_node + * @param fault_node pointer to soap_fault_node struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_node_free( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env); + + /** + * Set the fault string value of the SOAP fault node + * @param fault_node pointer to soap_fault_node struct + * @param env Environment. MUST NOT be NULL + * @param fault_val the fault string value + * + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_node_set_value( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env, + axis2_char_t * fault_val); + + /** + * Get the string value of the SOAP fault node + * @param fault_node pointer to soap_fault_node struct + * @param env Environment. MUST NOT be NULL + * + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_fault_node_get_value( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env); + + /** + * Get the base node of the SOAP fault node + * @param fault_node pointer to soap_fault_node struct + * @param env Environment. MUST NOT be NULL + * + * @return the base node of the fault node + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_node_get_base_node( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_NODE_H */ diff --git a/axiom/include/axiom_soap_fault_reason.h b/axiom/include/axiom_soap_fault_reason.h new file mode 100644 index 0000000..e9e8da3 --- /dev/null +++ b/axiom/include/axiom_soap_fault_reason.h @@ -0,0 +1,139 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_FAULT_REASON_H +#define AXIOM_SOAP_FAULT_REASON_H + +/** +* @file axiom_soap_fault_reason.h +* @brief axiom_soap_fault_reason +*/ +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_reason axiom_soap_fault_reason_t; + struct axiom_soap_fault_text; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_fault_reason soap fault reason + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a SOAP fault reason struct + * @param env Environment. MUST NOT be NULL + * @param fault the SOAP fault + * + * @return the created SOAP fault reason struct + */ + AXIS2_EXTERN axiom_soap_fault_reason_t *AXIS2_CALL + axiom_soap_fault_reason_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault); + + /** + * Free an axiom_soap_fault_reason + * @param fault_reason pointer to soap_fault_reason struct + * @param env Environment. MUST NOT be NULL + * + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_reason_free( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env); + + /** + * Get the SOAP fault text by comparing the given string + * @param fault_reason pointer to soap_fault_reason struct + * @param env Environment. MUST NOT be NULL + * @param lang string to be compares + * + * @return the SOAP fault text of the SOAP fault string + */ + AXIS2_EXTERN struct axiom_soap_fault_text *AXIS2_CALL + axiom_soap_fault_reason_get_soap_fault_text( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + axis2_char_t * lang); + + /** + * Returns all the SOAP fault reason strings as an array list + * @param fault_reason pointer to soap_fault_reason struct + * @param env Environment. MUST NOT be NULL + * + * @return all the SOAP fault reason strings as an array list + */ + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axiom_soap_fault_reason_get_all_soap_fault_texts( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env); + + /** + * Retuens the first SOAP fault reason string + * @param fault_reason pointer to soap_fault_reason struct + * @param env Environment. MUST NOT be NULL + * + * @return The first SOAP fault reason string + */ + AXIS2_EXTERN struct axiom_soap_fault_text *AXIS2_CALL + axiom_soap_fault_reason_get_first_soap_fault_text( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env); + + /** + * Add a string as a SOAP fault reason + * @param fault_reason pointer to soap_fault_reason struct + * @param env Environment. MUST NOT be NULL + * @param fault_text The text to be added as the SOAP fault reason + * + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_reason_add_soap_fault_text( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + struct axiom_soap_fault_text *fault_text); + + /** + * Get the base node of the SOAP fault reason + * @param fault_reason pointer to soap_fault_reason struct + * @param env Environment. MUST NOT be NULL + * @return the base node of the SOAP fault reason + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_reason_get_base_node( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_REASON_H */ diff --git a/axiom/include/axiom_soap_fault_role.h b/axiom/include/axiom_soap_fault_role.h new file mode 100644 index 0000000..7cfa82c --- /dev/null +++ b/axiom/include/axiom_soap_fault_role.h @@ -0,0 +1,109 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_FAULT_ROLE_H +#define AXIOM_SOAP_FAULT_ROLE_H + +/** + * @file axiom_soap_fault_role.h + * @brief axiom_soap_fault_role + */ +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_role axiom_soap_fault_role_t; + + /** + * @defgroup axiom_soap_fault_role soap fault role + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap struct + * @param env Environment. MUST NOT be NULL + */ + AXIS2_EXTERN axiom_soap_fault_role_t *AXIS2_CALL + axiom_soap_fault_role_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault); + + /** + * Free an axiom_soap_fault_role + * @param fault_role pointer to soap_fault_role struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_role_free( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env); + + /** + * Set the SOAP fault role value + * @param fault_role pointer to soap_fault_role struct + * @param env Environment. MUST NOT be NULL + * @param uri the URI to be set + * + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_role_set_role_value( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * Get the SOAP fault role value + * @param fault_role pointer to soap_fault_role struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP fault role value + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_fault_role_get_role_value( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env); + + /** + * Get the base node of the OM SOAP fault role + * @param fault_role pointer to soap_fault_role struct + * @param env Environment. MUST NOT be NULL + * + * @return the base node of the OM SOAP fault role + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_role_get_base_node( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_ROLE_H */ diff --git a/axiom/include/axiom_soap_fault_sub_code.h b/axiom/include/axiom_soap_fault_sub_code.h new file mode 100644 index 0000000..6d4723c --- /dev/null +++ b/axiom/include/axiom_soap_fault_sub_code.h @@ -0,0 +1,123 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_FAULT_SUB_CODE_H +#define AXIOM_SOAP_FAULT_SUB_CODE_H + +/** + * @file axiom_soap_fault_sub_code.h + * @brief axiom_soap_fault_sub_code struct + */ +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_sub_code axiom_soap_fault_sub_code_t; + struct axiom_soap_fault_value; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_fault_sub_code soap fault sub code + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap struct + * @param env Environment. MUST NOT be NULL + * @param fault_code SOAP fault code + * + * @return Created SOAP fault sub code + */ + AXIS2_EXTERN axiom_soap_fault_sub_code_t *AXIS2_CALL + axiom_soap_fault_sub_code_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_code_t * fault_code); + + /** + * Create a SOAP fault sub code from the given SOAP fault and value + * @param fault_sub_code pointer to soap_fault_sub_code struct + * @param env Environment. MUST NOT be NULL + * @param value the value to be set to the SOAP fault + * + * @return Created SOAP sub code + */ + AXIS2_EXTERN axiom_soap_fault_sub_code_t *AXIS2_CALL + axiom_soap_fault_sub_code_create_with_parent_value( + const axutil_env_t * env, + axiom_soap_fault_code_t * fault_code, + axis2_char_t * value); + + /** + * Free an axiom_soap_fault_sub_code + * @param fault_sub_code pointer to soap_fault_sub_code struct + * @param env Environment. MUST NOT be NULL + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_sub_code_free( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env); + + /** + * Get the SOAP fault sub code + * @param fault_sub_code pointer to soap_fault_sub_code struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP fault sub code + */ + AXIS2_EXTERN axiom_soap_fault_sub_code_t *AXIS2_CALL + axiom_soap_fault_sub_code_get_sub_code( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env); + + /** + * Get the value of the SOAP fault sub code + * @param fault_sub_code pointer to soap_fault_sub_code struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP fault value + */ + AXIS2_EXTERN struct axiom_soap_fault_value *AXIS2_CALL + axiom_soap_fault_sub_code_get_value( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env); + + /** + * Get the base node of the SOAP fault sub code + * @param fault_sub_code pointer to soap_fault_sub_code struct + * @param env Environment. MUST NOT be NULL + * + * @return the base node of the SOAP fault sub code as OM node + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_sub_code_get_base_node( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_SUB_CODE_H */ diff --git a/axiom/include/axiom_soap_fault_text.h b/axiom/include/axiom_soap_fault_text.h new file mode 100644 index 0000000..10a0465 --- /dev/null +++ b/axiom/include/axiom_soap_fault_text.h @@ -0,0 +1,138 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_FAULT_TEXT_H +#define AXIOM_SOAP_FAULT_TEXT_H + +/** + * @file axiom_soap_fault_text.h + * @brief axiom_soap_fault_text + */ +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_text axiom_soap_fault_text_t; + + /** + * @defgroup axiom_soap_fault_text soap fault text + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap fault struct + * @param env Environment. MUST NOT be NULL + * @param fault the SOAP fault reason + * + * @return Created SOAP fault text + */ + AXIS2_EXTERN axiom_soap_fault_text_t *AXIS2_CALL + axiom_soap_fault_text_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_reason_t * fault); + + /** + * Free an axiom_soap_fault_text + * @param fault_text pointer to soap_fault_text struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_text_free( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env); + + /** + * Set the lang of the SOAP fault text + * @param fault_text pointer to soap_fault_text struct + * @param env Environment. MUST NOT be NULL + * @param lang the string to be set + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_text_set_lang( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env, + const axis2_char_t * lang); + + /** + * Get the lang of the SOAP fault + * @param fault_text pointer to soap_fault_text struct + * @param env Environment. MUST NOT be NULL + * + * @return the lang of the SOAP fault + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_fault_text_get_lang( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env); + + /** + * Get the base node of the SOAP fault text + * @param fault_text pointer to soap_fault_text struct + * @param env Environment. MUST NOT be NULL + * + * @return the base node of the SOAP fault text + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_text_get_base_node( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env); + + /** + * Set the SOAP fault text + * @param fault_text pointer to soap_fault_text struct + * @param env Environment. MUST NOT be NULL + * @param value the text value + * @param lang string to be compared + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_text_set_text( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env, + axis2_char_t * value, + axis2_char_t * lang); + + /** + * get the SOAP fault text + * @param fault_text pointer to soap_fault_text struct + * @param env Environment. MUST NOT be NULL + * + * @return the Text of the SOAP fault + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_fault_text_get_text( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_TEXT_H */ diff --git a/axiom/include/axiom_soap_fault_value.h b/axiom/include/axiom_soap_fault_value.h new file mode 100644 index 0000000..446a89e --- /dev/null +++ b/axiom/include/axiom_soap_fault_value.h @@ -0,0 +1,120 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_FAULT_VALUE_H +#define AXIOM_SOAP_FAULT_VALUE_H + +/** +* @file axiom_soap_fault_value.h +* @brief axiom_soap_fault_value +*/ +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_fault_value axiom_soap_fault_value_t; + + /** + * @defgroup axiom_soap_fault_value soap fault value + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap struct + * @param env Environment. MUST NOT be NULL + */ + AXIS2_EXTERN axiom_soap_fault_value_t *AXIS2_CALL + axiom_soap_fault_value_create_with_subcode( + const axutil_env_t * env, + axiom_soap_fault_sub_code_t * parent); + + /** + * Create s SOAP fault value givn a SOAP fault code + * @param fault_value pointer to soap_fault_value struct + * @param env Environment. MUST NOT be NULL + * + * @return Created SOAP fault value + */ + AXIS2_EXTERN axiom_soap_fault_value_t *AXIS2_CALL + axiom_soap_fault_value_create_with_code( + const axutil_env_t * env, + axiom_soap_fault_code_t * parent); + + /** + * Free an axiom_soap_fault_value + * @param fault_value pointer to soap_fault_value struct + * @param env Environment. MUST NOT be NULL + * + * @return VOID + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_fault_value_free( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env); + + /** + * Get the text value of the soapenv:Value element directly under soapenv:Code element + * @param fault_value pointer to axiom_soap_fault_t + * @param env Environment. MUST NOT BE NULL + * @return text value + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_fault_value_get_text( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env); + + /** + * Set the text value of the soapenv:Value element directly under soapenv:Code element + * @param fault_value pointer to axiom_soap_fault_t + * @param env Environment. MUST NOT BE NULL + * @param text value to be set + * + * @return the base node + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_fault_value_get_base_node( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env); + + /** + * set the text value of soap_fault_value element + * @param fault_value pointer to soap fault value struct + * @param env environment MUST not be NULL + * @param text Text value to be set + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_value_set_text( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env, + axis2_char_t * text); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP_FAULT_VALUE_H */ diff --git a/axiom/include/axiom_soap_header.h b/axiom/include/axiom_soap_header.h new file mode 100644 index 0000000..f0ed2f5 --- /dev/null +++ b/axiom/include/axiom_soap_header.h @@ -0,0 +1,205 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_HEADER_H +#define AXIOM_SOAP_HEADER_H + +/** + * @file axiom_soap_header.h + * @brief axiom_soap_header struct + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_header axiom_soap_header_t; + + struct axiom_soap_header_block; + struct axiom_soap_builder; + + /** + * @defgroup axiom_soap_header soap header + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axiom_soap_header_t *AXIS2_CALL + axiom_soap_header_create_with_parent( + const axutil_env_t * env, + struct axiom_soap_envelope *envelope); + + /** + * Free an axiom_soap_header + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_header_free( + axiom_soap_header_t * header, + const axutil_env_t * env); + + /** + * create a new axiom_soap_header_block_t struct initialized with the + * specified name and adds it to passed axiom_soap_header_t struct. + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * @param localName the localname of the SOAP header block + * @param ns the namespace of the SOAP header block + * @return The newly created axiom_soap_header_block_t struct + */ + AXIS2_EXTERN struct axiom_soap_header_block *AXIS2_CALL + + axiom_soap_header_add_header_block( + axiom_soap_header_t * header, + const axutil_env_t * env, + const axis2_char_t * localname, + axiom_namespace_t * ns); + + /** + * returns a hash_table of all the soap_header_block_t struct in this + * soap_header_t object that have the the specified actor. An + * actor is a global attribute that indicates the intermediate parties to + * whom the message should be sent. An actor receives the message and then + * sends it to the next actor. The default actor is the ultimate intended + * recipient for the message, so if no actor attribute is set in a + * axiom_soap_header_t struct the message is sent to its ultimate + * destination. + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * @param role the role value for the examination + * + * @return hash_table of all the soap_header_block_t struct + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_soap_header_examine_header_blocks( + axiom_soap_header_t * header, + const axutil_env_t * env, + axis2_char_t * param_role); + + /** + * returns an arraylist of header_blocks which has a given namesapce uri + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * @param ns_uri namespace uri + * @return pointer to axutil_array_list_t, or null if no header_blocks with + * given namespace uri exists + * The returned array_list must be freed by the user. + */ + AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL + axiom_soap_header_get_header_blocks_with_namespace_uri( + axiom_soap_header_t * header, + const axutil_env_t * env, + const axis2_char_t * ns_uri); + + /** + * returns an iterator to iterate through all soap header block's om nodes + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * @returns axiom_children_qname_iterator_t or null if no header blocks + * present + */ + AXIS2_EXTERN axiom_children_qname_iterator_t *AXIS2_CALL + axiom_soap_header_examine_all_header_blocks( + axiom_soap_header_t * header, + const axutil_env_t * env); + + /** + * returns an iterator to iterate through all header blocks om_nodes + * with the matching role attribute + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * @param role + * @returns iterator or null if no header blocks present with matching + * role attribute + */ + AXIS2_EXTERN axiom_children_with_specific_attribute_iterator_t + *AXIS2_CALL + axiom_soap_header_extract_header_blocks( + axiom_soap_header_t * header, + const axutil_env_t * env, + axis2_char_t * role); + + /** + * returns the axiom_node_t struct wrapped in soap_header + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * + * @return the base node of the SOAP header + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_header_get_base_node( + axiom_soap_header_t * header, + const axutil_env_t * env); + + /** + * return the soap_version of this soap_header + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIOM_SOAP11 or AXIOM_SOAP12 + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_header_get_soap_version( + axiom_soap_header_t * header, + const axutil_env_t * env); + + /** + * Get all the SOAP headers + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * + * @returns a hash table of all header_blocks in this header + * the returned hash is a readonly hash should not be modified + */ + AXIS2_EXTERN axutil_hash_t *AXIS2_CALL + axiom_soap_header_get_all_header_blocks( + axiom_soap_header_t * header, + const axutil_env_t * env); + + /** + * remove header block that matches to the given qname + * qname should not be null + * @param header pointer to soap_header struct + * @param env Environment. MUST NOT be NULL + * + * @return status of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_remove_header_block( + axiom_soap_header_t * header, + const axutil_env_t * env, + axutil_qname_t * qname); + + /** @} */ +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_SOAP_HEADER_H */ diff --git a/axiom/include/axiom_soap_header_block.h b/axiom/include/axiom_soap_header_block.h new file mode 100644 index 0000000..30ba4b0 --- /dev/null +++ b/axiom/include/axiom_soap_header_block.h @@ -0,0 +1,228 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP_HEADER_BLOCK_H +#define AXIOM_SOAP_HEADER_BLOCK_H + +/** + * @file axiom_soap_header_block.h + * @brief axiom_soap_header_block struct + */ +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap_header_block axiom_soap_header_block_t; + + /** + * @defgroup axiom_soap_header_block soap header block + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap struct + * @param env Environment. MUST NOT be NULL + * this is an internal function. + * + * @return the created SOAP header block + */ + AXIS2_EXTERN axiom_soap_header_block_t *AXIS2_CALL + axiom_soap_header_block_create_with_parent( + const axutil_env_t * env, + const axis2_char_t * localname, + axiom_namespace_t * ns, + struct axiom_soap_header *parent); + + /** + * Free an axiom_soap_header_block + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_soap_header_block_free( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** + * Set the SOAP role + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * @param uri the role URI + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_block_set_role( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * Set the mustunderstand attribute of the SOAP header + * If must_understand=TRUE its set to 1, otherwise set to 0 + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * @param must_understand SOAP mustunderstand attribute value + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_block_set_must_understand_with_bool( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + axis2_bool_t must_understand); + + /** + * Set the SOAP mustunderstand attribute + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * @param must_understand SOAP mustunderstand attribute + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_block_set_must_understand_with_string( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + axis2_char_t * must_understand); + + /** + * To check the SOAP mustunderstand attribute + * If must_understand=TRUE its set to 1, otherwise set to 0 + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_TRUE if mustunderstand is set true. AXIS2_FALSE otherwise + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_soap_header_block_get_must_understand( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** + * To chk if the SOAP header is processed or not + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * + * @return AXIS2_TRUE if checked AXIS2_FALSE otherwise + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_soap_header_block_is_processed( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** + * Set the SOAP header as processed + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_block_set_processed( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** + * Get the SOAP role of the header block + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP role of the header block + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_header_block_get_role( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** + * Set the attribute of the header block + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * @param attr_name the attribute name + * @param attr_value the attribute value + * @param soap_envelope_namespace_uri the namsepace URI value + * + * @return satus of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_block_set_attribute( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + const axis2_char_t * attr_name, + const axis2_char_t * attr_value, + const axis2_char_t * soap_envelope_namespace_uri); + + /** + * Get the attribute of the header block + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * @param attr_name the attribute name + * @param the namespace URI of the SOAP envelope + * + * @return the attribute of the header block + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_soap_header_block_get_attribute( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + const axis2_char_t * attr_name, + const axis2_char_t * soap_envelope_namespace_uri); + + /** + * Get the base node of the header block + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * + * @return the base node of the of the header block + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_soap_header_block_get_base_node( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** + * Get the SOAP version of the header block + * @param header_block pointer to soap_header_block struct + * @param env Environment. MUST NOT be NULL + * + * @return the SOAP version of the header block + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_header_block_get_soap_version( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_SOAP_HEADER_BLOCK_H */ diff --git a/axiom/include/axiom_stax_builder.h b/axiom/include/axiom_stax_builder.h new file mode 100644 index 0000000..fb4a1ec --- /dev/null +++ b/axiom/include/axiom_stax_builder.h @@ -0,0 +1,154 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_STAX_BUILDER_H +#define AXIOM_STAX_BUILDER_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_stax_builder stax builder + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_stax_builder axiom_stax_builder_t; + + /** + * Creates an stax builder + * @param environment Environment. MUST NOT be NULL. + * @param parser parser to be used with builder. The builder + * will take ownership of the parser. + * @return a pointer to the newly created builder struct. + */ + AXIS2_EXTERN axiom_stax_builder_t *AXIS2_CALL + axiom_stax_builder_create( + const axutil_env_t * env, + axiom_xml_reader_t * parser); + + /** + * Builds the next node from stream. Moves pull parser forward and reacts + * to events. + * @param builder pointer to stax builder struct to be used + * @param environment Environment. MUST NOT be NULL. + * @return a pointer to the next node, or NULL if there are no more nodes. + * On erros sets the error and returns NULL. + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_stax_builder_next( + struct axiom_stax_builder *builder, + const axutil_env_t * env); + + /** + * Discards the element that is being built currently. + * @param environment Environment. MUST NOT be NULL, . + * @param builder pointer to stax builder struct to be used + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_stax_builder_discard_current_element( + struct axiom_stax_builder *builder, + const axutil_env_t * env); + + /** + * Free the build struct instance and its associated document,axiom tree. + * @param builder pointer to builder struct + * @param env environment, MUST NOT be NULL + * @return status of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_stax_builder_free( + struct axiom_stax_builder *builder, + const axutil_env_t * env); + + /** + * Free the build struct instance and its associated document. + does not free the associated axiom tree. + * @param builder pointer to builder struct + * @param env environment, MUST NOT be NULL + * @return status of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_stax_builder_free_self( + struct axiom_stax_builder *builder, + const axutil_env_t * env); + + /** Gets the document associated with the builder + * @param builder axiom_stax_builder + * @param env environment + * @return pointer to document struct associated with builder + * NULL if there is no document associated with the builder, + * NULL if an error occured. + */ + AXIS2_EXTERN axiom_document_t *AXIS2_CALL + axiom_stax_builder_get_document( + struct axiom_stax_builder *builder, + const axutil_env_t * env); + + /** + * builder is finished building om structure + * @param builder pointer to stax builder struct to be used + * @param environment Environment. MUST NOT be NULL. + * + * @return AXIS2_TRUE if is complete or AXIS2_FALSE otherwise + */ + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axiom_stax_builder_is_complete( + struct axiom_stax_builder *builder, + const axutil_env_t * env); + + /** + * moves the reader to next event and returns the token returned by the xml_reader , + * @param builder pointer to STAX builder struct to be used + * @param environment Environment. MUST NOT be NULL. + * @return next event axiom_xml_reader_event_types. Returns -1 on error + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_stax_builder_next_with_token( + struct axiom_stax_builder *builder, + const axutil_env_t * env); + + AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL + axiom_stax_builder_get_parser( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env); + + AXIS2_EXTERN void AXIS2_CALL + axiom_stax_builder_set_cache( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env, + axis2_bool_t enable_cache); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_STAX_BUILDER_H */ diff --git a/axiom/include/axiom_text.h b/axiom/include/axiom_text.h new file mode 100644 index 0000000..3768d90 --- /dev/null +++ b/axiom/include/axiom_text.h @@ -0,0 +1,265 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_TEXT_H +#define AXIOM_TEXT_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_text text + * @ingroup axiom_om + * @{ + */ + + typedef struct axiom_text axiom_text_t; + + /** + * Creates a new text struct + * @param env Environment. + * @param parent parent of the new node. Optinal, can be NULL. + * The parent element must be of type AXIOM_ELEMENT + * @param value Text value. Optinal, can be NULL. + * @param comment_node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the text struct created. + * Node type will be set to AXIOM_TEXT + * @return pointer to newly created text struct + */ + AXIS2_EXTERN axiom_text_t *AXIS2_CALL + axiom_text_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * value, + axiom_node_t ** node); + + /** + * Creates a new text struct + * @param env Environment. + * @param parent parent of the new node. Optinal, can be NULL. + * The parent element must be of type AXIOM_ELEMENT + * @param value Text value string. Optinal, can be NULL. + * @param comment_node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the text struct created. + * Node type will be set to AXIOM_TEXT + * @return pointer to newly created text struct + */ + AXIS2_EXTERN axiom_text_t *AXIS2_CALL + axiom_text_create_str( + const axutil_env_t * env, + axiom_node_t * parent, + axutil_string_t * value, + axiom_node_t ** node); + + /** + * Creates a new text struct for binary data (MTOM) + * @param env Environment. + * @param parent parent of the new node. Optinal, can be NULL. + * The parent element must be of type AXIOM_ELEMENT + * @param data_handler data handler. Optinal, can be NULL. + * @param comment_node This is an out parameter. cannot be NULL. + * Returns the node corresponding to the text struct created. + * Node type will be set to AXIOM_TEXT + * @return pointer to newly created text struct + */ + AXIS2_EXTERN axiom_text_t *AXIS2_CALL + axiom_text_create_with_data_handler( + const axutil_env_t * env, + axiom_node_t * parent, + axiom_data_handler_t * data_handler, + axiom_node_t ** node); + + /** + * Free an axiom_text struct + * @param env environment. + * @param om_text pointer to om text struct to be freed. + * @return satus of the op. AXIS2_SUCCESS on success + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_text_free( + struct axiom_text *om_text, + const axutil_env_t * env); + + /** + * Serialize op + * @param env environment. + * @param om_text pointer to om text struct to be serialized. + * @param om_output AXIOM output handler to be used in serializing. + * @return satus of the op. AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_serialize( + struct axiom_text *om_text, + const axutil_env_t * env, + axiom_output_t * om_output); + + /** + * Sets the text value + * @param om_text om_text struct + * @param env environment. + * @param value text + * @return status of the op. AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_set_value( + struct axiom_text *om_text, + const axutil_env_t * env, + const axis2_char_t * value); + + /** + * Gets text value + * @param om_text om_text struct + * @param env environment. + * @return text value , NULL is returned if there is no text value. + */ + AXIS2_EXTERN const axis2_char_t *AXIS2_CALL + axiom_text_get_value( + struct axiom_text *om_text, + const axutil_env_t * env); + + /** + * Sets the text value + * @param om_text om_text struct + * @param env environment. + * @param value string + * @return status of the op. AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_set_value_str( + struct axiom_text *om_text, + const axutil_env_t * env, + axutil_string_t * value); + + /** + * Gets text value from the text node even when MTOM optimized + * @param om_text om_text struct + * @param env environment. + * @return text value base64 encoded text when MTOM optimized, + * NULL is returned if there is no text value. + */ + AXIS2_EXTERN const axis2_char_t *AXIS2_CALL + axiom_text_get_text( + axiom_text_t * om_text, + const axutil_env_t * env); + + /** + * Gets text value + * @param om_text om_text struct + * @param env environment. + * @return text valu stringe , NULL is returned if there is no text value. + */ + AXIS2_EXTERN axutil_string_t *AXIS2_CALL + axiom_text_get_value_str( + struct axiom_text *om_text, + const axutil_env_t * env); + + /** + * Sets optimized + * @param om_text pointer to om_text struct + * @param env environment + * @optimize optimize value + * @returns AXIS2_SUCCESS + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_set_optimize( + struct axiom_text *om_text, + const axutil_env_t * env, + axis2_bool_t optimize); + + /** + * @param om_text text value + * @param env environment + * @param is_binary + * @returns AXIS2_SUCCESS + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_set_is_binary( + struct axiom_text *om_text, + const axutil_env_t * env, + const axis2_bool_t is_binary); + + /** + * Get the data handler of the OM text + * @param om_text pointer to the OM Text struct + * @param environment Environment. MUST NOT be NULL + * + * @return the data handler of the OM text + */ + AXIS2_EXTERN axiom_data_handler_t *AXIS2_CALL + axiom_text_get_data_handler( + struct axiom_text *om_text, + const axutil_env_t * env); + + /** + * Get the Content ID of the OM text + * @param om_text pointer to the OM Text struct + * @param environment Environment. MUST NOT be NULL + * + * @return the content id of the OM text + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_text_get_content_id( + struct axiom_text *om_text, + const axutil_env_t * env); + + /** + * Set the content ID of the OM text + * @param om_text pointer to the OM Text struct + * @param environment Environment. MUST NOT be NULL + * @param content_id the content ID + * @return status of the op. AXIS2_SUCCESS on success + * else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_set_content_id( + axiom_text_t * om_text, + const axutil_env_t * env, + const axis2_char_t * content_id); + + /** + * Sets the boolean value indicating if the binary data associated with the text + * node should be sent in SOAP with Attachment (SwA) format or not. + * @param om_text text node + * @param env environment + * @param is_swa bool value, AXIS2_TRUE means use SwA format, else AXIS2_FALSE + * @returns AXIS2_SUCCESS + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_text_set_is_swa( + struct axiom_text *om_text, + const axutil_env_t * env, + const axis2_bool_t is_swa); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_TEXT_H */ diff --git a/axiom/include/axiom_util.h b/axiom/include/axiom_util.h new file mode 100644 index 0000000..9c87877 --- /dev/null +++ b/axiom/include/axiom_util.h @@ -0,0 +1,396 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_UTIL_H +#define AXIOM_UTIL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + /** + * After calling this method the variable child points to + * the node of the returning element + * @param ele_node axiom node + * @param env environment, MUST not be NULL + * @param uri uri + * return the first child element which has the given uri + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_first_child_element_with_uri( + axiom_node_t * ele_node, + const axutil_env_t * env, + axis2_char_t * uri, + axiom_node_t ** child); + /** + * After calling this method next_node will point to the + * previous sibling node to the returning node + * @param ele_node axiom node + * @param env environment, MUST not be NULL + * @param uri uri + * @param next_node + * return the next sibling element to the element which contains + * the give namespace uri + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_next_sibling_element_with_uri( + axiom_node_t * ele_node, + const axutil_env_t * env, + axis2_char_t * uri, + axiom_node_t ** next_node); + /** + * @param eleaxiom node + * @param env environment, MUST not be NULL + * @param ele_node + * @param child_node + * return the first child element this calls the method + * axiom_element_get_first_child_element + * + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_first_child_element( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axiom_node_t ** child_node); + /** + * @param ele axiom element + * @param env environment, MUST not be NULL + * @param ele_node + * @param child_node + * return the last child element of the given element ele_node + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_last_child_element( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axiom_node_t ** child_node); + /** + * @param ele axiom node + * @param env environment, MUST not be NULL + * @param ele_node + * @param next_node + * return the first child element which has the given uri + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_next_sibling_element( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axiom_node_t ** next_node); + /** + * @param ele axiom element + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param localname localname to find the first child element + * @param child_node + * + * return the first child element from ele_node which contains the + * given local name + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_first_child_element_with_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param localname to find the last child element + * @param child_node + * return the last child element which having the given local name + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_last_child_element_with_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param localname to find the last child element + * @param next_node + * return the next sibling element which is having the given local name + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_next_siblng_element_with_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axiom_node_t ** next_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param localname to find the last child element + * @param uri uri to of the namespace to find the first element + * @param next_node + * return the first child element which is having the given local + * name and the given namespace uri + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_first_child_element_with_uri_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * uri, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param localname to find the last child element + * @param uri uri of the namespace to find the last element + * @param next_node + * return the last child element which is having the given local name and + * the given namespace uri + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_last_child_element_with_uri_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * uri, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param localname to find the last child element + * @param uri uri of the namespace to find the last element + * @param next_node + * return next sibling element which is having the given local name and + * the given namespace uri + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_next_sibling_element_with_uri_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * uri, + axiom_node_t ** next_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param names local names to find the child element + * @param child_node + * return the first child element which is having all the localnames given + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_first_child_element_with_localnames( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axutil_array_list_t * names, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param names local names to find the last child element + * @param child_node + * return the last child element which is having all the localnames given + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_last_child_element_with_localnames( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axutil_array_list_t * names, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node axiom node + * @param names local names to find the next sibling + * @param child_node + * return the next sibling element which is having all the localnames given + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_next_siblng_element_with_localnames( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axutil_array_list_t * names, + axiom_node_t ** next_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node + * @param localname local name to find the first child + * @param attr_name attribute name to find first child + * @param attr_value attribute value of attr_name attribute + * @param child_node + * return the first child element which is having the given local + * name and the given attribute (attribute name and attribute value) + */ + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_first_child_element_with_localname_attr( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * attr_name, + axis2_char_t * attr_value, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node + * @param localname local name to find the last child + * @param attr_name attribute name to find last child + * @param attr_value attribute value of attr_name attribute + * @param child_node + * return the last child element which is having the given local + * name and the given attribute (attribute name and attribute value) + */ + + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_last_child_element_with_localname_attr( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * attr_name, + axis2_char_t * attr_value, + axiom_node_t ** child_node); + /** + * @param ele + * @param env environment, MUST not be NULL + * @param ele_node + * @param localname local name to find the next sibling child + * @param attr_name attribute name to find the next sibling child + * @param attr_value attribute value of attr_name attribute + * @param child_node + * return the next sibling child element which is having the given local + * name and the given attribute (attribute name and attribute value) + */ + + AXIS2_EXTERN axiom_element_t *AXIS2_CALL + axiom_util_get_next_siblng_element_with_localname_attr( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * attr_name, + axis2_char_t * attr_value, + axiom_node_t ** next_node); + /** + * @param node axiom node + * @param env environment, MUST not be NULL + * + * return the element text of axiom_node + */ + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_util_get_child_text( + axiom_node_t * node, + const axutil_env_t * env); + /** + * @param node axiom node + * @param env environment, MUST not be NULL + * + * return the local name of axiom_node + */ + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_util_get_localname( + axiom_node_t * node, + const axutil_env_t * env); + /** + * @param om_node axiom node + * @param env environment, MUST not be NULL + * + * return the namespace uri of the give node variable om_node if + * there's no namespace in that particular om_node this method + * returns NULL + */ + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_util_get_node_namespace_uri( + axiom_node_t * om_node, + const axutil_env_t * env); + /** + * @param om_ele axiom node + * @param env environment, MUST not be NULL + * @param om_node + * return all the child element using the method + * axiom_child_element_iterator_create + */ + + AXIS2_EXTERN axiom_child_element_iterator_t *AXIS2_CALL + axiom_util_get_child_elements( + axiom_element_t * om_ele, + const axutil_env_t * env, + axiom_node_t * om_node); + + AXIS2_EXTERN axiom_document_t *AXIS2_CALL + axiom_util_new_document( + const axutil_env_t * env, + const axutil_uri_t * uri); + + AXIS2_EXTERN axiom_node_t* AXIS2_CALL + axiom_util_get_node_by_local_name( + const axutil_env_t *env, + axiom_node_t *node, + axis2_char_t *local_name); + + /** + * Creates a clone of given node + * @param env environment, MUST not be NULL + * @param node node to be cloned + * @return cloned node + */ + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_util_clone_node( + const axutil_env_t *env, + axiom_node_t *node); + +#ifdef __cplusplus + } +#endif +#endif /* AXIOM_UTIL_H */ diff --git a/axiom/include/axiom_xml_reader.h b/axiom/include/axiom_xml_reader.h new file mode 100644 index 0000000..c9450a8 --- /dev/null +++ b/axiom/include/axiom_xml_reader.h @@ -0,0 +1,706 @@ + +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef AXIOM_XML_READER_H +#define AXIOM_XML_READER_H + +/** + *@file axiom_xml_reader.h + *@brief this is the parser abstraction layer for axis2 + */ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_xml_reader_ops axiom_xml_reader_ops_t; + typedef struct axiom_xml_reader axiom_xml_reader_t; + + /** + * @defgroup axiom_parser parser + * @ingroup axiom + * @{ + * @} + */ + + /** + * @defgroup axiom_xml_reader XML reader + * @ingroup axiom_parser + * @{ + */ + + typedef enum axiom_xml_reader_event_types + { + AXIOM_XML_READER_START_DOCUMENT = 0, /* */ + AXIOM_XML_READER_START_ELEMENT, /* */ + AXIOM_XML_READER_END_ELEMENT, /* */ + AXIOM_XML_READER_SPACE, /* *//*event is for value, not for x*/ + AXIOM_XML_READER_EMPTY_ELEMENT, /* */ + AXIOM_XML_READER_CHARACTER, /* text*//*event is for text, not for x*/ + AXIOM_XML_READER_ENTITY_REFERENCE, + AXIOM_XML_READER_COMMENT, /* */ + AXIOM_XML_READER_PROCESSING_INSTRUCTION, + AXIOM_XML_READER_CDATA, + AXIOM_XML_READER_DOCUMENT_TYPE + } axiom_xml_reader_event_types; + + /** + * \brief AXIOM_XML_READER ops + * Encapsulator struct for ops of axiom_xml_reader + */ + + struct axiom_xml_reader_ops + { + + /** + * causes the reader to read the next parse event. + * returns the event just read + * @param parser axiom_xml_reader struct + * @param env axutil_environment, MUST NOT be NULL + * @returns one of the events defined in + * axiom_xml_reader_event_types + */ + + int( + AXIS2_CALL + * next)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * free pull_parser + * @param parser axiom_xml_reader struct + * @param env axutil_environment MUST NOT be NULL + * @returns axis2_status_code + */ + + void( + AXIS2_CALL + * free)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Get the Number of attributes in the current element + * @param parser axiom_xml_reader + * @param env axutil_environment, MUST NOT be NULL. + * @returns Number of attributes , AXIS2_FAILURE on error + */ + + int( + AXIS2_CALL + * get_attribute_count)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** This is used to get an attribute's localname using an index relative to + * current element.The iterations are not zero based. + * To access the first attribute use 1 for parameter i + * @param parser parser struct + * @param env environment struct + * @param i attribute index + * @returns the attribute localname + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_attribute_name_by_number)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** This is used to get an attribute's prefix using an index relative to + * current element. The iterations are not zero based. + * To access the first attribute use 1 for parameter i + * @param parser parser struct + * @param env environment, MUST NOT be NULL + * @param i attribute index. + * @returns the attribute prefix, returns NULL on error, + * caller must free the value using axiom_xml_reader_xml_free macro + */ + + axis2_char_t *( + AXIS2_CALL + * get_attribute_prefix_by_number)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** Gets an attribute's value using an index relative to + * current element. The iterations are not zero based. + * To access the first attribute use 1 for parameter i + * @param parser parser struct + * @param env environment, MUST NOT be NULL. + * @param i attribute index + * @returns the attribute value, returns NULL on error, + * caller must free the value using axiom_xml_reader_xml_free macro + */ + + axis2_char_t *( + AXIS2_CALL + * get_attribute_value_by_number)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** Gets an attribute's namespace uri using an index relative to + * current element. The iterations are not zero based. + * To access the first attribute use 1 for parameter i + * @param parser parser struct + * @param env environment struct + * @param i attribute index + * @returns the attribute value, returns NULL on error + * caller must free the value using axiom_xml_reader_xml_free macro + */ + + axis2_char_t *( + AXIS2_CALL + * get_attribute_namespace_by_number)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** Returns the text value of current element + * @param parser pointer to parser + * @param env environment, MUST not be NULL + * @returns Text Value, NULL on error + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_value)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Returns the namespace count of current element + * @param parser parser struct + * @param env environment + * @returns namespace count of current element, + */ + int( + AXIS2_CALL + * get_namespace_count)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Accesses the namespace uri of the namespaces declared in current element + * using an index + * @param parser parser struct + * @param env environment + * @param i index + * @returns namespace uri of corresponding namespace + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_namespace_uri_by_number)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * Accesses the namespace prefix of the namespaces declared in current element + * using an index + * @param parser parser struct + * @param env environment + * @param i index + * @returns namespace prefix of corresponding namespace + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_namespace_prefix_by_number)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * Used to obtain the current element prefix + * @param parser parser struct + * @param env environment struct + * @returns prefix , NULL on error + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_prefix)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Used to obtain the current element localname + * @param parser parser struct + * @param env environment struct + * @returns localname , NULL on error + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_name)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Used to get the processingInstruction target + * @param parser parser struct + * @param env environment, MUST NOT be NULL. + * @returns target value of processingInstruction + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_pi_target)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Gets the processingInstruction data + * @param parser parser struct + * @param env environment, MUST NOT be NULL. + * @returns data of processingInstruction + * caller must free the value using axiom_xml_reader_xml_free macro + */ + axis2_char_t *( + AXIS2_CALL + * get_pi_data)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Used to get the DTD + * @param parser pointer to pull parser struct + * @param env environment, MUST NOT be NULL. + * @return text of doctype declaration. NULL is returns of no data + * exists. + */ + axis2_char_t *( + AXIS2_CALL + * get_dtd)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * Free function , this function wraps the underlying parser's + * xml free function. For freeing values obatined by calling + * pull parser api methods, This function must be used. + * @param parser pointer to axiom_xml_reader + * @param env environment, MUST NOT be NULL. + * @param data data values to be destroyed + * @return status of the op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + void( + AXIS2_CALL + * xml_free)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + void *data); + + /** + * Gets the char set encoding of the parser + * @param parser xml parser + * @param env environment + * @returns char set encoding string or NULL in failure + */ + + axis2_char_t *( + AXIS2_CALL + * get_char_set_encoding)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** Returns the namespace uri associated with current node */ + axis2_char_t *( + AXIS2_CALL + * get_namespace_uri)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + axis2_char_t *( + AXIS2_CALL + * get_namespace_uri_by_prefix)( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + axis2_char_t * prefix); + + void *( + AXIS2_CALL + * get_context)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + axis2_char_t *( + AXIS2_CALL + * get_current_buffer)( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + }; + + /** + * @brief axiom_xml_reader struct + * Axis2 OM pull_parser + */ + struct axiom_xml_reader + { + const axiom_xml_reader_ops_t *ops; + }; + + /** + * Creates an instance of axiom_xml_reader to parse + * a file using an xml document in a file system + * @param env environment struct, must not be null + * @param filename url of an xml document + * @returns a pointer to xml_pull_parser_t struct + * NULL on error with error code set in the environment's error + */ + AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL + axiom_xml_reader_create_for_file( + const axutil_env_t * env, + char *filename, + const axis2_char_t * encoding); + + /** + * This create an instance of axiom_xml_reader to + * parse a xml document in a buffer. It takes a callback + * function that takes a buffer and the size of the buffer + * The user must implement a function that takes in buffer + * and size and fill the buffer with specified size + * with xml stream, parser will call this function to fill the + * buffer on the fly while parsing. + * @param env environment MUST NOT be NULL. + * @param read_input_callback() callback function that fills + * a char buffer. + * @param close_input_callback() callback function that closes + * the input stream. + * @param ctx, context can be any data that needs to be passed + * to the callback method. + * @param encoding encoding scheme of the xml stream + */ + AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL + axiom_xml_reader_create_for_io( + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK, + AXIS2_CLOSE_INPUT_CALLBACK, + void *ctx, + const axis2_char_t * encoding); + + /** + * Create an axiom_xml_reader_t using a buffer, which is the xml input + * @param env environment, MUST not be NULL + * @param container any data that needs to passed to the corresponding + * parser's create_for_memory method. The reader does not take ownership + * of this data. + * @param size size of the buffer + * @param encoding encoding of the xml + * @return pointer to axiom_xml_reader_t struct on success , NULL otherwise + */ + AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL + axiom_xml_reader_create_for_memory( + const axutil_env_t * env, + void *container, + int size, + const axis2_char_t * encoding, + int type); + + /** + * init function initializes the parser. When using libxml2 parser, this function + * is needed to initialize libxml2. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_reader_init(void + ); + + /** + * parser cleanup function. This function is used to clean up the globals of libxml2 + * parser. + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_reader_cleanup(void + ); + + /** + * while parsing through this method is calling for each and every + * time it parse a charactor.This is the atomic method which parse charactors. + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_xml_reader_next( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_xml_reader_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * free method for xml reader + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_xml_reader_get_attribute_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return number of attributes in an element + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_attribute_name_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return the attribute name by number + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_attribute_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return the attribute prefix by number + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_attribute_value_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return attribute value by number + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_attribute_namespace_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return attribute namespace by number + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_value( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return value of the element + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_xml_reader_get_namespace_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return the number of namespaces in an element + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_namespace_uri_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return uri or the namespace by number + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_namespace_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return prefix of the namespace by number + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return namespace prefix + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_name( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return name of the element + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_pi_target( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_pi_data( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_dtd( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_xml_reader_xml_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + void *data); + + /** + * free method for xml + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_char_set_encoding( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return charactor encoding + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_namespace_uri( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** + * + * @param parser pointer to the OM XML Reader struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_namespace_uri_by_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + axis2_char_t * prefix); + + AXIS2_EXTERN void *AXIS2_CALL + axiom_xml_reader_get_context( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_reader_get_current_buffer( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_XML_READER_H */ + + + + + + + + + + + + + + diff --git a/axiom/include/axiom_xml_writer.h b/axiom/include/axiom_xml_writer.h new file mode 100644 index 0000000..cddfc73 --- /dev/null +++ b/axiom/include/axiom_xml_writer.h @@ -0,0 +1,1014 @@ + +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef AXIOM_XML_WRITER_H +#define AXIOM_XML_WRITER_H + +/** + *@file axiom_xml_writer.h + *@brief this is the parser abstraction layer for axis2 + */ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_xml_writer_ops axiom_xml_writer_ops_t; + typedef struct axiom_xml_writer axiom_xml_writer_t; + + /** + * @defgroup axiom_xml_writer XML writer + * @ingroup axiom_parser + * @{ + */ + + /** + * \brief axiom_xml_writer ops + * Encapsulator struct for ops of axiom_xml_writer + */ + + struct axiom_xml_writer_ops + { + + /** + * Free xml writer + * @param writer pointer to xml_writer struct to be freed + * @param env environment, MUST NOT be NULL. + * @returns status of the op. + * AXIS2_SUCCESS on success and AXIS2_FAILURE on error + */ + + void( + AXIS2_CALL + * free)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * Write a start tag to output stream with localname. + * Internally the writer keeps track of the opened tags + * @param writer pointer to xml writer struct + * @param env environment. MUST NOT be NULL. + * @param localname localname of the tag, May not be NULL. + * @return the status of the op, AXIS2_SUCCESS on success + AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_start_element)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname); + + /** + * write an end tag to the output relying on the internal + * state of writer to determine the prefix and localname of + * the element + * @param writer xml_writer struct + * @param env environment, MUST NOT be NULL. + * @return status of the op. AXIS2_SUCCESS on success. + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * end_start_element)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * Write an element tag with localname and namespace uri + * @param writer pointer to xml writer struct + * @param env environment struct + * @param localname localname of the tag, May not be null. + * @param namespace_uri the namespace URI of the the pefix + * to use.may not be null. + * @returns status of the op, AXIS2_SUCCESS on success. + * AXIS2_FAILURE on error + */ + axis2_status_t( + AXIS2_CALL + * write_start_element_with_namespace)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri); + + /** + * write a start tag to output + * @param writer pointer to xml_writer struct + * @param environment, MUST NOT be NULL. + * @param localname localname of the tag, May not be null. + * @param namespace_uri namespace to bind the prefix to + * @param prefix the prefix to the tag.May not be NULL. + * @return status of the op + AXIS2_SUCCESS on success. AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_start_element_with_namespace_prefix)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + + /** + * write an element tag with localname + * @param writer xml_writer + * @param env environment + * @param localname localname + * @return status of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_empty_element)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname); + + /** + * write empty_element with localname and namespace uri. + * @param writer xml writer + * @param env environment + * @param localname localname + * @param namespace uri + * @return status of the op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + + axis2_status_t( + AXIS2_CALL + * write_empty_element_with_namespace)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri); + + /** + * write empty element with namespace uri and prefix + * @param writer xml_writer + * @param env environment + * @param localname localname + * @param namespace_uri namespace uri + * @param prefix prefix + * @return status of the op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_empty_element_with_namespace_prefix)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + + /** + * write end tag with correct localname prefix resolved internally + * @param writer xml writer + * @param env environment + * @return status of the op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on failure + */ + axis2_status_t( + AXIS2_CALL + * write_end_element)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * write end document + * @param writer xml writer + * @param env environment + * @return status of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_end_document)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * write attribute with localname and value + * @param writer writer + * @param env environment + * @param localname localname + * @param value text value of attribute + * @return status of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_attribute)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value); + + /** + * @param writer + * @param env environment + * @param localname + * @param value text value of attribute + * @param namespace uri namespace uri + * @return status code of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_attribute_with_namespace)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri); + + /** + * @param writer xml_writer + * @param env environment + * @param localname localname + * @param value text value of attribute + * @param namespace uri namespaceuri + * @param prefix prefix + */ + axis2_status_t( + AXIS2_CALL + * write_attribute_with_namespace_prefix)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + + /** + * @param writer xml_writer + * @param env environment + * @param prefix prefix + * @param namespace uri namespaceuri + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + + axis2_status_t( + AXIS2_CALL + * write_namespace)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * namespace_uri); + + /** + * @param writer xml_writer + * @param env environment + * @param namespace uri namespaceuri + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + + axis2_status_t( + AXIS2_CALL + * write_default_namespace)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * namespace_uri); + + /** + * @param writer xml_writer + * @param env environment + * @param value value + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + + axis2_status_t( + AXIS2_CALL + * write_comment)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * value); + + /** + * @param writer xml_writer + * @param env environment + * @param target pi target + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + + axis2_status_t( + AXIS2_CALL + * write_processing_instruction)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target); + + /** + * @param writer xml_writer + * @param env environment + * @param target pi target + * @param data pi data + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + + axis2_status_t( + AXIS2_CALL + * write_processing_instruction_data)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target, + axis2_char_t * data); + + /** + * @param writer xml_writer + * @param env environment + * @param data cdata + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_cdata)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * data); + + /** + * @param writer xml_writer + * @param env environment + * @param dtd dtd + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_dtd)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * dtd); + + /** + * @param writer xml_writer + * @param env environment + * @param name name + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_entity_ref)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * name); + + /** + * @param writer xml_writer + * @param env environment + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_start_document)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer xml_writer + * @param env environment + * @param version version + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_start_document_with_version)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version); + + /** + * @param writer xml_writer + * @param env environment + * @param version version + * @param encoding encoding + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_start_document_with_version_encoding)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version, + axis2_char_t * encoding); + + /** + * @param writer xml_writer + * @param env environment + * @param text text + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_characters)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text); + + /** + * @param writer xml_writer + * @param env environment + * @param uri uri + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_char_t *( + AXIS2_CALL + * get_prefix)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * @param writer xml_writer + * @param env environment + * @param prefix prefix + * @param uri uri + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * set_prefix)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * uri); + + /** + * @param writer xml_writer + * @param env environment + * @param uri uri + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * set_default_prefix)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * @param writer xml_writer + * @param env environment + * @param text text + * @param in_attr + * @return status of op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error. + */ + axis2_status_t( + AXIS2_CALL + * write_encoded)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text, + int in_attr); + + void *( + AXIS2_CALL + * get_xml)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + unsigned int( + AXIS2_CALL + * get_xml_size)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + int( + AXIS2_CALL + * get_type)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + axis2_status_t( + AXIS2_CALL + * write_raw)( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * content); + axis2_status_t( + AXIS2_CALL + * flush)( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + }; + + /** + * @brief axis2_pull_parser struct + * Axis2 OM pull_parser + */ + + struct axiom_xml_writer + { + const axiom_xml_writer_ops_t *ops; + }; + + /** + * create function for axiom_xml_writer + * @param env environment + * @param filename filename + * @param encoding encoding + * @param is_prefix_default + * @param compression + * return xml writer wrapper structure + */ + AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL + axiom_xml_writer_create( + const axutil_env_t * env, + axis2_char_t * filename, + axis2_char_t * encoding, + int is_prefix_default, + int compression); + + /** + * create fuction for xml writer for memory buffer + * @param env environment struct, must not be null + * @param env environment + * @param encoding encoding + * @param is_prefix_default + * @param compression + * @return xml writer wrapper structure. + */ + AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL + axiom_xml_writer_create_for_memory( + const axutil_env_t * env, + axis2_char_t * encoding, + int is_prefix_default, + int compression, + int type); + + /** + * free method for axiom xml writer + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_xml_writer_free( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the start element + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname); + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_end_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_start_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname localname of the start element + * @param namespace_uri namespace uri of that element + * @param prefix prefix of that namespace + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_start_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the element + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_empty_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the element + * @param namespace_uri uri of the namespace + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_empty_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the element + * @param namespace_uri uri of the namespace + * @param prefix prefix of the namespace + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_empty_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_end_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_end_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the element + * @param value value of the element + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_attribute( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the element + * @param value value of the element + * @param uri of the namespace + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_attribute_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param localname local name of the element + * @param value value of the element + * @param uri of the namespace + * @param prefix of the namespace + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_attribute_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * @param prefix prefix of the namespace + * @param uri of the namespace + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * namespace_uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_default_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * namespace_uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_comment( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * value); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_processing_instruction( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_processing_instruction_data( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target, + axis2_char_t * data); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_cdata( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * data); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_dtd( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * dtd); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_entity_ref( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * name); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_start_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_start_document_with_version( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_start_document_with_version_encoding( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version, + axis2_char_t * encoding); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_characters( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN axis2_char_t *AXIS2_CALL + axiom_xml_writer_get_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return prefix + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_set_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * uri); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_set_default_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + + /** + * sets the default prefix + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_encoded( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text, + int in_attr); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN void *AXIS2_CALL + axiom_xml_writer_get_xml( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return + */ + AXIS2_EXTERN unsigned int AXIS2_CALL + axiom_xml_writer_get_xml_size( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return size of the xml + */ + AXIS2_EXTERN int AXIS2_CALL + axiom_xml_writer_get_type( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return type + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_write_raw( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * content); + + /** + * @param writer pointer to the OM XML Writer struct + * @param env environment struct, must not be null + * + * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_xml_writer_flush( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_XML_WRITER_H */ diff --git a/axiom/include/axiom_xpath.h b/axiom/include/axiom_xpath.h new file mode 100644 index 0000000..d2b0ee2 --- /dev/null +++ b/axiom/include/axiom_xpath.h @@ -0,0 +1,407 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_XPATH_H +#define AXIOM_XPATH_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_xpath_api api + * @ingroup axiom_xpath + * @{ + */ + + + /** + * Enable tracing + */ + +#define AXIOM_XPATH_DEBUG + + /** + * An error occured while evaluating the xpath expression + */ +#define AXIOM_XPATH_EVALUATION_ERROR 0 + +#define AXIOM_XPATH_ERROR_STREAMING_NOT_SUPPORTED 10 + + /* Typedefs */ + + /** + * XPath expression + * It includes the expression as a string and parsed data. + */ + typedef struct axiom_xpath_expression axiom_xpath_expression_t; + + /** + * The XPath context + * Keeps a reference to the context node or attribute, + * XPath expression, environment and result set. + */ + typedef struct axiom_xpath_context axiom_xpath_context_t; + + /** + * XPath result set + * Contains the result set and other information such as + * whether the expression was evaluated successfully. + */ + typedef struct axiom_xpath_result axiom_xpath_result_t; + + /** + * XPath result + * Stores type and value of the result. + */ + typedef struct axiom_xpath_result_node axiom_xpath_result_node_t; + + /** + * XPath result types + */ + typedef enum axiom_xpath_result_type_t + { + AXIOM_XPATH_TYPE_NODE = 0, + AXIOM_XPATH_TYPE_ATTRIBUTE, + AXIOM_XPATH_TYPE_NAMESPACE, + AXIOM_XPATH_TYPE_TEXT, + AXIOM_XPATH_TYPE_NUMBER, + AXIOM_XPATH_TYPE_BOOLEAN + } axiom_xpath_result_type_t; + + typedef int (*axiom_xpath_function_t)(axiom_xpath_context_t *context, + int np); + + /** + * XPath expression + */ + struct axiom_xpath_expression + { + /** XPath expression as a string */ + axis2_char_t* expr_str; + + /** Length of the expression */ + int expr_len; + + /** A cursor pointing to the position currently being parsed */ + int expr_ptr; + + /** Parsed expression in an array list*/ + axutil_array_list_t *operations; + + /** A pointer to the start operation in operations */ + int start; + }; + + /** + * XPath context + */ + struct axiom_xpath_context + { + /** Environment */ + const axutil_env_t *env; + + /** List of namespaces */ + axutil_hash_t *namespaces; + + /** Set of functions */ + axutil_hash_t *functions; + + /** Root node */ + axiom_node_t *root_node; + + /** Context node */ + axiom_node_t *node; + + /** Context attribute */ + axiom_attribute_t *attribute; + + /** Context attribute */ + axiom_namespace_t *ns; + + /** Context position */ + int position; + + /** Context size + * *Does not work location paths due to optimizations */ + int size; + + /** XPath expression */ + axiom_xpath_expression_t *expr; + + /** Streaming */ + axis2_bool_t streaming; + + /** Stack of processed items */ + axutil_stack_t *stack; + + /* TODO: + functions + variables + etc */ + }; + + /** + * XPath result set + */ + struct axiom_xpath_result + { + /** A flag indicating whether errors occured while evaluting XPath + * expression */ + int flag; + + /** An array list containing the set of results */ + axutil_array_list_t * nodes; + }; + + /** + * XPath result + */ + struct axiom_xpath_result_node + { + /** Type of result */ + axiom_xpath_result_type_t type; + + /** Value */ + void * value; + }; + + /** + * Compile an XPath expression + * + * @param env Environment must not be null + * @param xpath_expr A pointer to the XPath expression + * @return The parsed XPath expression. Returns NULL if an error occured + * while parsing. + */ + AXIS2_EXTERN axiom_xpath_expression_t * AXIS2_CALL axiom_xpath_compile_expression( + const axutil_env_t *env, + const axis2_char_t* xpath_expr); + + /** + * Create an empty XPath context + * + * @param env Environment must not be null + * @param root_node A pointer to the root of the tree + * @return The initialized XPath context. + */ + AXIS2_EXTERN axiom_xpath_context_t * AXIS2_CALL axiom_xpath_context_create( + const axutil_env_t *env, + axiom_node_t * root_node); + + /** + * Evaluate an parsed XPath expression. Different expressions could + * be evaluated on the same context, and same expression could be + * evaluated on multiple trees without recompiling. + * + * @param context XPath context must not be null + * @param xpath_expr XPath expression to be evaluated + * @return The set of results. + */ + AXIS2_EXTERN axiom_xpath_result_t * AXIS2_CALL axiom_xpath_evaluate( + axiom_xpath_context_t *context, + axiom_xpath_expression_t *xpath_expr); + + + /** + * Convert an XPath result to a boolean. + * If the result is a boolean the value of it is returned. + * If the result is a number, AXIS2_TRUE is + * returned if the value is not equal to 0 and AXIS2_FALSE otherwise. + * Otherwise AXIS2_TRUE is returned if the result is not NULL and AXIS2_FALSE otherwise. + * + * @param env Environment must not be null + * @param node A pointer to the XPath result + * @return The boolean value. + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL axiom_xpath_cast_node_to_boolean( + const axutil_env_t *env, + axiom_xpath_result_node_t * node); + + /** + * Convert an XPath result to a number. + * If the result is a boolean, 1 is returned if it's true and 0 otherwise. + * If the result is a number the value of it is returned. + * Otherwise AXIS2_TRUE is returned if the result is not NULL and AXIS2_FALSE otherwise. + * + * @param env Environment must not be null + * @param node A pointer to the XPath result + * @return The numerical value. + */ + AXIS2_EXTERN double AXIS2_CALL axiom_xpath_cast_node_to_number( + const axutil_env_t *env, + axiom_xpath_result_node_t * node); + + /** + * Convert an XPath result to text. + * If the result is a boolean, "true" is returned if it's true and "false" otherwise. + * If the result is a number the text representation of it is returned. + * If the result is a text the value of it is returned. + * If the result is an axiom node, the text value of it is returned + * If the result is an axiom attribue, the text value of it is returned + * + * @param env Environment must not be null + * @param node A pointer to the XPath result + * @return The text value. + */ + AXIS2_EXTERN axis2_char_t * AXIS2_CALL axiom_xpath_cast_node_to_string( + const axutil_env_t *env, + axiom_xpath_result_node_t * node); + + /** + * Convert an XPath result to an axiom node. + * If the result is an axiom node it is returned and NULL otherwise. + * + * @param env Environment must not be null + * @param node A pointer to the XPath result + * @return The axiom node. + */ + AXIS2_EXTERN axiom_node_t * AXIS2_CALL axiom_xpath_cast_node_to_axiom_node( + const axutil_env_t *env, + axiom_xpath_result_node_t * node); + + + /** + * Free XPath context + * + * @param env Environment must not be null + * @param context XPath context must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_free_context( + const axutil_env_t *env, + axiom_xpath_context_t *context); + + /** + * Free XPath expression + * + * @param env Environment must not be null + * @param xpath_expr XPath expression must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_free_expression( + const axutil_env_t *env, + axiom_xpath_expression_t * xpath_expr); + + /** + * Free XPath result set + * + * @param env Environment must not be null + * @param result XPath result set must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_free_result( + const axutil_env_t *env, + axiom_xpath_result_t* result); + + /** + * Registers a XPath namespace + * + * @param context XPath Context, must not be null + * @param ns AXIOM namespace, must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_register_namespace( + axiom_xpath_context_t *context, + axiom_namespace_t *ns); + + /** + * Get a registered namespace by the prefix. + * If there is no namespace registered by the given prefix NULL will be returned + * + * @param context XPath Context, must not be null + * @param prefix Prefix of the namespace, must not be null + * @return The namespace corresponding to the prefix. + */ + AXIS2_EXTERN axiom_namespace_t * AXIS2_CALL axiom_xpath_get_namespace( + axiom_xpath_context_t *context, + axis2_char_t *prefix); + + /** + * Clears all registered XPath namespaces + * + * @param context XPath Context, must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_clear_namespaces( + axiom_xpath_context_t *context); + + /** + * Evaluates an XPath expression on streaming XML. + * Not all expressions can be evaluated on streaming XML. + * If the expression cannot be evaluated on streaming XML NULL will be returned. + * + * @param context XPath Context, must not be null + * @param xpath_expr XPath expression to be evaluated + */ + AXIS2_EXTERN axiom_xpath_result_t * AXIS2_CALL axiom_xpath_evaluate_streaming( + axiom_xpath_context_t *context, + axiom_xpath_expression_t *xpath_expr); + + /** + * Checks whether the given expression can be evaluated on streaming XML. + * If it is possible AXIS2_TRUE will be retuned; AXIS2_FALSE otherwise. + * + * @param env Axis2 environment, must not be null + * @param expr Complied XPath expression, must not be null + * @return A boolean indicating whether the expression can be evaluated on streaming XML. + */ + AXIS2_EXTERN axis2_bool_t AXIS2_CALL axiom_xpath_streaming_check( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Setup the XPath core function library + * + * @param context XPath Context, must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_register_default_functions_set( + axiom_xpath_context_t *context); + + /** + * Registers a custom XPath function http://www.w3.org/TR/xpath#corelib + * + * @param context XPath Context, must not be null + * @param name Name of the function, must not be null + * @param func Pointer to the function, must not be null + */ + AXIS2_EXTERN void AXIS2_CALL axiom_xpath_register_function( + axiom_xpath_context_t *context, + axis2_char_t *name, + axiom_xpath_function_t func); + + /** + * Retrive a pointer to a registered funciton by the function name. + * If there is no function registered by the given name, NULL will be returned. + * + * @param context XPath Context, must not be null + * @param name Name of the function, must not be null + * @return The corresponding function. + */ + AXIS2_EXTERN axiom_xpath_function_t AXIS2_CALL axiom_xpath_get_function( + axiom_xpath_context_t *context, + axis2_char_t *name); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/axiom/src/Makefile.am b/axiom/src/Makefile.am new file mode 100644 index 0000000..a3e9472 --- /dev/null +++ b/axiom/src/Makefile.am @@ -0,0 +1,2 @@ +SUBDIRS = parser attachments soap util ${XPATH_DIR} om + diff --git a/axiom/src/attachments/Makefile.am b/axiom/src/attachments/Makefile.am new file mode 100644 index 0000000..e4ec8fd --- /dev/null +++ b/axiom/src/attachments/Makefile.am @@ -0,0 +1,15 @@ +noinst_LTLIBRARIES = libaxis2_attachments.la +AM_CPPFLAGS = $(CPPFLAGS) +libaxis2_attachments_la_SOURCES = mime_part.c \ + data_handler.c \ + mime_body_part.c \ + mime_parser.c + +libaxis2_attachments_la_LIBADD = ../../../util/src/libaxutil.la + +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/parser \ + -I ../../../util/include + +EXTRA_DIST = axiom_mime_body_part.h + diff --git a/axiom/src/attachments/axiom_mime_body_part.h b/axiom/src/attachments/axiom_mime_body_part.h new file mode 100644 index 0000000..a925679 --- /dev/null +++ b/axiom/src/attachments/axiom_mime_body_part.h @@ -0,0 +1,121 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_MIME_BODY_PART_H +#define AXIOM_MIME_BODY_PART_H + +/** + * @file axiom_mime_body_part.h + * @brief axis2 mime_body_part interface + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_mime_body_part axiom_mime_body_part_t; + + /** @defgroup axiom_mime_body_part + * @ingroup axiom_mime_body_part + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_mime_body_part_add_header( + axiom_mime_body_part_t * mime_body_part, + const axutil_env_t * env, + const axis2_char_t * name, + const axis2_char_t * value); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_mime_body_part_set_data_handler( + axiom_mime_body_part_t * mime_body_part, + const axutil_env_t * env, + axiom_data_handler_t * data_handler); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_mime_body_part_write_to( + axiom_mime_body_part_t * mime_body_part, + const axutil_env_t * env, + axis2_byte_t ** output_stream, + int *output_stream_size); + + /** Deallocate memory + * @return status code + */ + AXIS2_EXTERN void AXIS2_CALL + axiom_mime_body_part_free( + axiom_mime_body_part_t * mime_body_part, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_mime_body_part_write_to_list( + axiom_mime_body_part_t *mime_body_part, + const axutil_env_t *env, + axutil_array_list_t *list); + + /** + * Creates mime_body_part struct + * @return pointer to newly created mime_body_part + */ + AXIS2_EXTERN axiom_mime_body_part_t *AXIS2_CALL + axiom_mime_body_part_create( + const axutil_env_t * env); + + /** + * Creates mime_body_part struct from a om_text + * @return pointer to newly created mime_body_part + */ + + AXIS2_EXTERN axiom_mime_body_part_t *AXIS2_CALL + axiom_mime_body_part_create_from_om_text( + const axutil_env_t *env, + axiom_text_t *text); + + +#define AXIOM_MIME_BODY_PART_FREE(mime_body_part, env) \ + axiom_mime_body_part_free (mime_body_part, env) + +#define AXIOM_MIME_BODY_PART_ADD_HEADER(mime_body_part, env, name, value) \ + axiom_mime_body_part_add_header (mime_body_part, env, name, value) + +#define AXIOM_MIME_BODY_PART_SET_DATA_HANDLER(mime_body_part, env, data_handler) \ + axiom_mime_body_part_set_data_handler (mime_body_part, env, data_handler) + +#define AXIOM_MIME_BODY_PART_WRITE_TO(mime_body_part, env, output_stream, output_stream_size) \ + axiom_mime_body_part_write_to (mime_body_part, env, output_stream, output_stream_size) + + /** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIOM_MIME_BODY_PART_H */ diff --git a/axiom/src/attachments/data_handler.c b/axiom/src/attachments/data_handler.c new file mode 100644 index 0000000..3be8a9d --- /dev/null +++ b/axiom/src/attachments/data_handler.c @@ -0,0 +1,572 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +struct axiom_data_handler +{ + /* The content type */ + axis2_char_t *mime_type; + + /* If in a file then the file name*/ + axis2_char_t *file_name; + + /* If it is in a buffer then the buffer */ + axis2_byte_t *buffer; + + /* The length of the buffer */ + size_t buffer_len; + + /* Is this a data_handler with a file name or a buffer*/ + axiom_data_handler_type_t data_handler_type; + + /* When parsing whether we have cached it or not */ + axis2_bool_t cached; + + /* The Content Id */ + axis2_char_t *mime_id; + + /* In the case of sending callback this is required */ + void *user_param; + +}; + +/* Creates the data_handler. The file name is not mandatory */ + +AXIS2_EXTERN axiom_data_handler_t *AXIS2_CALL +axiom_data_handler_create( + const axutil_env_t *env, + const axis2_char_t *file_name, + const axis2_char_t *mime_type) +{ + axiom_data_handler_t *data_handler = NULL; + + AXIS2_ENV_CHECK(env, NULL); + data_handler = (axiom_data_handler_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_data_handler_t)); + + if(!data_handler) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create data handler"); + return NULL; + } + + data_handler->mime_type = NULL; + data_handler->file_name = NULL; + data_handler->buffer = NULL; + data_handler->buffer_len = 0; + /* By default, a Data Handler is of type Buffer */ + data_handler->data_handler_type = AXIOM_DATA_HANDLER_TYPE_BUFFER; + data_handler->cached = AXIS2_FALSE; + data_handler->mime_id = NULL; + data_handler->user_param = NULL; + + if(mime_type) + { + data_handler->mime_type = axutil_strdup(env, mime_type); + if(!(data_handler->mime_type)) + { + axiom_data_handler_free(data_handler, env); + return NULL; + } + } + if(file_name) + { + data_handler->file_name = axutil_strdup(env, file_name); + if(!(data_handler->file_name)) + { + axiom_data_handler_free(data_handler, env); + return NULL; + } + data_handler->data_handler_type = AXIOM_DATA_HANDLER_TYPE_FILE; + } + + return data_handler; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_data_handler_free( + axiom_data_handler_t *data_handler, + const axutil_env_t *env) +{ + if(data_handler->file_name) + { + AXIS2_FREE(env->allocator, data_handler->file_name); + } + + if(data_handler->mime_type) + { + AXIS2_FREE(env->allocator, data_handler->mime_type); + } + + if(data_handler->buffer) + { + AXIS2_FREE(env->allocator, data_handler->buffer); + } + + if(data_handler->mime_id) + { + AXIS2_FREE(env->allocator, data_handler->mime_id); + } + + if(data_handler) + { + AXIS2_FREE(env->allocator, data_handler); + } + + return; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_data_handler_get_content_type( + axiom_data_handler_t *data_handler, + const axutil_env_t *env) +{ + return data_handler->mime_type; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_data_handler_set_content_type( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + const axis2_char_t *mime_type) +{ + if(data_handler->mime_type) + { + AXIS2_FREE(env->allocator, data_handler->mime_type); + } + data_handler->mime_type = axutil_strdup(env, mime_type); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_data_handler_get_cached( + axiom_data_handler_t *data_handler, + const axutil_env_t *env) +{ + return data_handler->cached; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_data_handler_set_cached( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + axis2_bool_t cached) +{ + data_handler->cached = cached; +} + +AXIS2_EXTERN axis2_byte_t *AXIS2_CALL +axiom_data_handler_get_input_stream( + axiom_data_handler_t *data_handler, + const axutil_env_t *env) +{ + return data_handler->buffer; +} + +AXIS2_EXTERN size_t AXIS2_CALL +axiom_data_handler_get_input_stream_len( + axiom_data_handler_t *data_handler, + const axutil_env_t *env) +{ + return data_handler->buffer_len; +} + +/* With MTOM caching support this function is no longer used + * Because this will load whole file in to buffer. So for large + * attachment this is not wise */ + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_data_handler_read_from( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + axis2_byte_t **output_stream, + size_t *output_stream_size) +{ + if(data_handler->data_handler_type == AXIOM_DATA_HANDLER_TYPE_BUFFER) + { + *output_stream = data_handler->buffer; + *output_stream_size = data_handler->buffer_len; + } + else if(data_handler->data_handler_type == AXIOM_DATA_HANDLER_TYPE_FILE + && data_handler->file_name) + { + FILE *f = NULL; + axis2_byte_t *byte_stream = NULL; + axis2_byte_t *temp_byte_stream = NULL; + axis2_byte_t *read_stream = NULL; + int byte_stream_size = 0; + int temp_byte_stream_size = 0; + int read_stream_size = 0; + int count = 0; + struct stat stat_p; + + f = fopen(data_handler->file_name, "rb"); + if(!f) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error opening file %s for reading", + data_handler->file_name); + return AXIS2_FAILURE; + } + + if(stat(data_handler->file_name, &stat_p) == -1) + { + fclose(f); + return AXIS2_FAILURE; + } + else if(stat_p.st_size == 0) + { + fclose(f); + *output_stream = NULL; + *output_stream_size = 0; + return AXIS2_SUCCESS; + } + + do + { + read_stream_size = stat_p.st_size; + read_stream = AXIS2_MALLOC(env->allocator, (read_stream_size) * sizeof(axis2_byte_t)); + if(!read_stream) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create binary stream"); + if(byte_stream) + { + AXIS2_FREE(env->allocator, byte_stream); + } + fclose(f); + return AXIS2_FAILURE; + } + count = (int)fread(read_stream, 1, read_stream_size, f); + /* The count lies within the int range */ + if(ferror(f)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in reading file %s", + data_handler->file_name); + if(byte_stream) + { + AXIS2_FREE(env->allocator, byte_stream); + } + if(read_stream) + { + AXIS2_FREE(env->allocator, read_stream); + } + fclose(f); + return AXIS2_FAILURE; + } + + /* copy the read bytes */ + if(count > 0) + { + if(byte_stream) + { + temp_byte_stream = byte_stream; + temp_byte_stream_size = byte_stream_size; + byte_stream_size = temp_byte_stream_size + count; + byte_stream = AXIS2_MALLOC(env->allocator, (byte_stream_size) + * sizeof(axis2_byte_t)); + if(!byte_stream) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "No memory. Cannot create binary stream"); + if(read_stream) + { + AXIS2_FREE(env->allocator, read_stream); + } + if(temp_byte_stream) + { + AXIS2_FREE(env->allocator, temp_byte_stream); + } + fclose(f); + return AXIS2_FAILURE; + } + + memcpy(byte_stream, temp_byte_stream, temp_byte_stream_size); + memcpy(byte_stream + temp_byte_stream_size, read_stream, count); + + if(read_stream) + { + AXIS2_FREE(env->allocator, read_stream); + read_stream_size = 0; + } + if(temp_byte_stream) + { + AXIS2_FREE(env->allocator, temp_byte_stream); + temp_byte_stream = NULL; + temp_byte_stream_size = 0; + } + } + else + { + byte_stream = read_stream; + byte_stream_size = read_stream_size; + read_stream = NULL; + read_stream_size = 0; + } + } + else if(read_stream) + { + AXIS2_FREE(env->allocator, read_stream); + } + } + while(!feof(f)); + + fclose(f); + data_handler->buffer = byte_stream; + data_handler->buffer_len = byte_stream_size; + *output_stream = byte_stream; + *output_stream_size = byte_stream_size; + } + else + { + /* Data Handler File Name is missing */ + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_data_handler_set_binary_data( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + axis2_byte_t *input_stream, + size_t input_stream_len) +{ + data_handler->buffer = input_stream; + data_handler->buffer_len = input_stream_len; + return AXIS2_SUCCESS; +} + +/* This function will write the data in the buffer + * to a file. When caching is being used this will + * not be called , because the parser it self cache + * the attachment while parsing */ + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_data_handler_write_to( + axiom_data_handler_t *data_handler, + const axutil_env_t *env) +{ + if(data_handler->file_name) + { + FILE *f = NULL; + int count = 0; + + f = fopen(data_handler->file_name, "wb"); + if(!f) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error opening file %s for writing", + data_handler->file_name); + return AXIS2_FAILURE; + } + + count = (int)fwrite(data_handler->buffer, 1, data_handler->buffer_len, f); + /* The count lies within the int range */ + + if(ferror(f)) + { + fclose(f); + return AXIS2_FAILURE; + } + fflush(f); + fclose(f); + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_data_handler_set_file_name( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + axis2_char_t *file_name) +{ + if(data_handler->file_name) + { + AXIS2_FREE(env->allocator, data_handler->file_name); + data_handler->file_name = NULL; + } + + if(file_name) + { + data_handler->file_name = axutil_strdup(env, file_name); + if(!(data_handler->file_name)) + { + return AXIS2_FAILURE; + } + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_data_handler_get_file_name( + axiom_data_handler_t *data_handler, + const axutil_env_t *env) +{ + if(data_handler->file_name) + { + return data_handler->file_name; + } + else + { + return NULL; + } +} + +/* This method will add the data_handler binary data to the array_list. + * If it is a buffer the part type is buffer. otherwise it is a file. In the + * case of file the array_list have just the file name and the size. The content + * is not loaded to the memory. + */ + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_data_handler_add_binary_data( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + axutil_array_list_t *list) + +{ + axiom_mime_part_t *binary_part = NULL; + + binary_part = axiom_mime_part_create(env); + + if(!binary_part) + { + return AXIS2_FAILURE; + } + + if(data_handler->data_handler_type == AXIOM_DATA_HANDLER_TYPE_BUFFER) + { + binary_part->part = (axis2_byte_t *)AXIS2_MALLOC(env->allocator, (data_handler->buffer_len) + * sizeof(axis2_byte_t)); + memcpy(binary_part->part, data_handler->buffer, data_handler->buffer_len); + + binary_part->part_size = data_handler->buffer_len; + binary_part->type = AXIOM_MIME_PART_BUFFER; + } + + /* In the case of file we first calculate the file size + * and then add the file name */ + + else if(data_handler->data_handler_type == AXIOM_DATA_HANDLER_TYPE_FILE + && data_handler->file_name) + { + struct stat stat_p; + + if(stat(data_handler->file_name, &stat_p) == -1) + { + return AXIS2_FAILURE; + } + else if(stat_p.st_size == 0) + { + return AXIS2_SUCCESS; + } + else + { + binary_part->file_name = (axis2_char_t *)axutil_strdup(env, data_handler->file_name); + binary_part->part_size = stat_p.st_size; + binary_part->type = AXIOM_MIME_PART_FILE; + } + } + /* In the case of Callback the user should specify the callback name in the + * configuration file. We just set the correct type. Inside the transport + * it will load the callback and send the attachment appropriately */ + + else if(data_handler->data_handler_type == AXIOM_DATA_HANDLER_TYPE_CALLBACK) + { + binary_part->type = AXIOM_MIME_PART_CALLBACK; + binary_part->user_param = data_handler->user_param; + } + + else + { + /* Data Handler File Name is missing */ + return AXIS2_FAILURE; + } + + /* Finaly we add the binary details to the list */ + + axutil_array_list_add(list, env, binary_part); + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_data_handler_get_mime_id( + axiom_data_handler_t *data_handler, + const axutil_env_t *env) +{ + return data_handler->mime_id; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_data_handler_set_mime_id( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + const axis2_char_t *mime_id) +{ + if(data_handler->mime_id) + { + AXIS2_FREE(env->allocator, data_handler->mime_id); + } + data_handler->mime_id = axutil_strdup(env, mime_id); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_data_handler_type_t AXIS2_CALL +axiom_data_handler_get_data_handler_type( + axiom_data_handler_t *data_handler, + const axutil_env_t *env) +{ + return data_handler->data_handler_type; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_data_handler_set_data_handler_type( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + axiom_data_handler_type_t data_handler_type) +{ + data_handler->data_handler_type = data_handler_type; + return; +} + +AXIS2_EXTERN void *AXIS2_CALL +axiom_data_handler_get_user_param( + axiom_data_handler_t *data_handler, + const axutil_env_t *env) +{ + return data_handler->user_param; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_data_handler_set_user_param( + axiom_data_handler_t *data_handler, + const axutil_env_t *env, + void *user_param) +{ + data_handler->user_param = user_param; + return; +} + diff --git a/axiom/src/attachments/mime_body_part.c b/axiom/src/attachments/mime_body_part.c new file mode 100644 index 0000000..186acdb --- /dev/null +++ b/axiom/src/attachments/mime_body_part.c @@ -0,0 +1,284 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axiom_mime_body_part.h" +#include +#include +#include + +struct axiom_mime_body_part +{ + /* hash map to hold header name, value pairs */ + axutil_hash_t *header_map; + axiom_data_handler_t *data_handler; +}; + +/* This method just create a mime_body_part. It does not + * fill the header map. + */ + +AXIS2_EXTERN axiom_mime_body_part_t *AXIS2_CALL +axiom_mime_body_part_create( + const axutil_env_t *env) +{ + axiom_mime_body_part_t *mime_body_part = NULL; + + AXIS2_ENV_CHECK(env, NULL); + mime_body_part = (axiom_mime_body_part_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_mime_body_part_t)); + + if(!mime_body_part) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create MIME body part"); + return NULL; + } + + mime_body_part->header_map = NULL; + mime_body_part->data_handler = NULL; + + mime_body_part->header_map = axutil_hash_make(env); + if(!(mime_body_part->header_map)) + { + axiom_mime_body_part_free(mime_body_part, env); + return NULL; + } + + return mime_body_part; +} + +/* This method will create the mime_body_part and fill the header map with + * default information. Default information are for binary attachments. + * Attachment information is taken from the information in data_handler in passed + * om_text. + */ + +AXIS2_EXTERN axiom_mime_body_part_t *AXIS2_CALL +axiom_mime_body_part_create_from_om_text( + const axutil_env_t *env, + axiom_text_t *text) +{ + axiom_data_handler_t *data_handler = NULL; + axiom_mime_body_part_t *mime_body_part = NULL; + axis2_char_t *content_id = NULL; + axis2_char_t *temp_content_id = NULL; + const axis2_char_t *content_type = AXIOM_MIME_TYPE_OCTET_STREAM; + + mime_body_part = axiom_mime_body_part_create(env); + if(!mime_body_part) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "MIME body part creation failed"); + return NULL; + } + + /* Take the data_handler which is set by the sending applocation. */ + + data_handler = axiom_text_get_data_handler(text, env); + + if(data_handler) + { + content_type = axiom_data_handler_get_content_type(data_handler, env); + } + + AXIOM_MIME_BODY_PART_SET_DATA_HANDLER(mime_body_part, env, data_handler); + content_id = (axis2_char_t *)"<"; + content_id = axutil_stracat(env, content_id, axiom_text_get_content_id(text, env)); + temp_content_id = axutil_stracat(env, content_id, ">"); + + AXIS2_FREE(env->allocator, content_id); + content_id = temp_content_id; + + /* Adding the content-id */ + AXIOM_MIME_BODY_PART_ADD_HEADER(mime_body_part, env, AXIOM_MIME_HEADER_CONTENT_ID, content_id); + + /* Adding the content-type */ + AXIOM_MIME_BODY_PART_ADD_HEADER(mime_body_part, env, AXIOM_MIME_HEADER_CONTENT_TYPE, + axutil_strdup(env, content_type)); + + /* Adding the content-transfer encoding */ + AXIOM_MIME_BODY_PART_ADD_HEADER(mime_body_part, env, + AXIOM_MIME_HEADER_CONTENT_TRANSFER_ENCODING, axutil_strdup(env, + AXIOM_MIME_CONTENT_TRANSFER_ENCODING_BINARY)); + + return mime_body_part; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_mime_body_part_free( + axiom_mime_body_part_t *mime_body_part, + const axutil_env_t *env) +{ + if(mime_body_part->header_map) + { + axutil_hash_index_t *hash_index = NULL; + const void *key = NULL; + void *value = NULL; + for(hash_index = axutil_hash_first(mime_body_part->header_map, env); hash_index; hash_index + = axutil_hash_next(env, hash_index)) + { + axutil_hash_this(hash_index, &key, NULL, &value); + if(value) + { + AXIS2_FREE(env->allocator, value); + } + } + + axutil_hash_free(mime_body_part->header_map, env); + mime_body_part->header_map = NULL; + } + + if(mime_body_part) + { + AXIS2_FREE(env->allocator, mime_body_part); + } + + return; +} + +/* This method will add a mime_header to the hash */ + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_mime_body_part_add_header( + axiom_mime_body_part_t *mime_body_part, + const axutil_env_t *env, + const axis2_char_t *name, + const axis2_char_t *value) +{ + AXIS2_PARAM_CHECK(env->error, name, AXIS2_FAILURE); + + if(!mime_body_part->header_map) + { + return AXIS2_FAILURE; + } + axutil_hash_set(mime_body_part->header_map, name, AXIS2_HASH_KEY_STRING, value); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_mime_body_part_set_data_handler( + axiom_mime_body_part_t *mime_body_part, + const axutil_env_t *env, + axiom_data_handler_t *data_handler) +{ + mime_body_part->data_handler = data_handler; + return AXIS2_SUCCESS; +} + +/* This method will fill the array_list with binary and binary_beader information. + * If the binary is in a file this will not load the file to the memory. Because + * that will cause performance degradation when the file size is large. Instead + * this will add file information to the list so that when writing the message + * through transport_sender it can send the file by chunk. + */ + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_mime_body_part_write_to_list( + axiom_mime_body_part_t *mime_body_part, + const axutil_env_t *env, + axutil_array_list_t *list) +{ + axutil_hash_index_t *hash_index = NULL; + const void *key = NULL; + void *value = NULL; + axis2_char_t *header_str = NULL; + axis2_char_t *temp_header_str = NULL; + int header_str_size = 0; + axis2_status_t status = AXIS2_FAILURE; + axiom_mime_part_t *mime_header_part = NULL; + + /* We have the mime headers in the hash with thier keys + * So first concatenate them to a one string */ + + for(hash_index = axutil_hash_first(mime_body_part->header_map, env); hash_index; hash_index + = axutil_hash_next(env, hash_index)) + { + axutil_hash_this(hash_index, &key, NULL, &value); + if(key && value) + { + /* First conactenate to the already conacatenated stuff */ + + temp_header_str = axutil_stracat(env, header_str, (axis2_char_t *)key); + if(header_str) + { + AXIS2_FREE(env->allocator, header_str); + } + header_str = temp_header_str; + temp_header_str = axutil_stracat(env, header_str, ": "); + AXIS2_FREE(env->allocator, header_str); + header_str = temp_header_str; + + /* Add the new stuff */ + temp_header_str = axutil_stracat(env, header_str, (axis2_char_t *)value); + AXIS2_FREE(env->allocator, header_str); + header_str = temp_header_str; + + /* Next header will be in a new line. So lets add it */ + + temp_header_str = axutil_stracat(env, header_str, AXIS2_CRLF); + AXIS2_FREE(env->allocator, header_str); + header_str = temp_header_str; + } + } + + /* If there is a data handler that's mean there is an attachment. Attachment + * will always start after an additional new line . So let's add it .*/ + + if(mime_body_part->data_handler) + { + temp_header_str = axutil_stracat(env, header_str, AXIS2_CRLF); + AXIS2_FREE(env->allocator, header_str); + header_str = temp_header_str; + } + + if(header_str) + { + header_str_size = axutil_strlen(header_str); + } + + /* Now we have the complete mime_headers string for a particular mime part. + * First wrap it as a mime_part_t .Then add it to the array list so + * later through the transport this can be written to the wire. */ + + mime_header_part = axiom_mime_part_create(env); + + if(mime_header_part) + { + mime_header_part->part = (axis2_byte_t *)header_str; + mime_header_part->part_size = header_str_size; + mime_header_part->type = AXIOM_MIME_PART_BUFFER; + } + else + { + return AXIS2_FAILURE; + } + + axutil_array_list_add(list, env, mime_header_part); + + /* Then if the data_handler is there let's add the binary data, may be + * buffer , may be file name and information. + */ + + if(mime_body_part->data_handler) + { + status = axiom_data_handler_add_binary_data(mime_body_part->data_handler, env, list); + if(status != AXIS2_SUCCESS) + { + return status; + } + } + return AXIS2_SUCCESS; +} diff --git a/axiom/src/attachments/mime_parser.c b/axiom/src/attachments/mime_parser.c new file mode 100644 index 0000000..f36286c --- /dev/null +++ b/axiom/src/attachments/mime_parser.c @@ -0,0 +1,2304 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct axiom_mime_parser +{ + /* This will keep the attachment and its info*/ + axutil_hash_t *mime_parts_map; + + /* This is the actual SOAP part len */ + size_t soap_body_len; + + /* The SOAP part of the message */ + axis2_char_t *soap_body_str; + + /* The size of the buffer we give to the callback to + * read data */ + size_t buffer_size; + + /* The number of buffers */ + int max_buffers; + + /* The attachment dir name, in the case of caching */ + axis2_char_t *attachment_dir; + + /*A pointer to the caching callback */ + axiom_mtom_caching_callback_t *mtom_caching_callback; + + /* The caching callback name specified */ + axis2_char_t *callback_name; + + axis2_char_t **buf_array; + + size_t *len_array; + + int current_buf_num; + + axis2_bool_t end_of_mime; + + axis2_char_t *mime_boundary; + +}; + +struct axiom_search_info +{ + /*String need to be searched*/ + const axis2_char_t *search_str; + + /*The buffers and the lengths need to be searched*/ + axis2_char_t *buffer1; + size_t len1; + axis2_char_t *buffer2; + size_t len2; + + /*Flag to keep what type of search is this buffer has done*/ + axis2_bool_t primary_search; + + /*The offset where we found the pattern entirely in one buffer*/ + size_t match_len1; + + /*when pattern contains in two buffers the length of partial pattern + in buffer2 */ + size_t match_len2; + + /*Whether we need caching or not*/ + axis2_bool_t cached; + + /*A pointer to a user provided storage to which we cache the attachment*/ + void *handler; + + /* Size of the binary when writing to the buffer*/ + size_t binary_size; +}; + +typedef struct axiom_search_info axiom_search_info_t; + +#define AXIOM_MIME_PARSER_CONTENT_ID "content-id" +#define AXIOM_MIME_PARSER_CONTENT_TYPE "content-type" + +#define AXIOM_MIME_PARSER_END_OF_MIME_MAX_COUNT 100 + +static axis2_char_t * +axiom_mime_parser_search_for_soap( + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback, + void *callback_ctx, + int *buf_num, + size_t *len_array, + axis2_char_t **buf_array, + axiom_search_info_t *search_info, + size_t size, + axis2_char_t *mime_boundary, + axiom_mime_parser_t *mime_parser); + +static axis2_char_t * +axiom_mime_parser_search_for_crlf( + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback, + void *callback_ctx, + int *buf_num, + size_t *len_array, + axis2_char_t **buf_array, + axiom_search_info_t *search_info, + size_t size, + axiom_mime_parser_t *mime_parser); + +static size_t +axiom_mime_parser_calculate_part_len( + const axutil_env_t *env, + int buf_num, + size_t *len_list, + int maker, + axis2_char_t *pos, + axis2_char_t *buf); + +static axis2_char_t * +axiom_mime_parser_create_part( + const axutil_env_t *env, + size_t part_len, + int buf_num, + size_t *len_list, + int marker, + axis2_char_t *pos, + axis2_char_t **buf_list, + axiom_mime_parser_t *mime_parser); + +static axis2_char_t * +axiom_mime_parser_search_string( + axiom_search_info_t *search_info, + const axutil_env_t *env); + +static axis2_char_t * +axiom_mime_parser_search_for_attachment( + axiom_mime_parser_t *mime_parser, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback, + void *callback_ctx, + int *buf_num, + size_t *len_array, + axis2_char_t **buf_array, + axiom_search_info_t *search_info, + size_t size, + axis2_char_t *mime_boundary, + axis2_char_t *mime_id, + void *user_param); + +static axis2_status_t +axiom_mime_parser_store_attachment( + const axutil_env_t *env, + axiom_mime_parser_t *mime_parser, + axis2_char_t *mime_id, + axis2_char_t *mime_type, + axis2_char_t *mime_binary, + size_t mime_binary_len, + axis2_bool_t cached); + +static void +axiom_mime_parser_clear_buffers( + const axutil_env_t *env, + axis2_char_t **buf_list, + int free_from, + int free_to); + +static axis2_status_t +axiom_mime_parser_cache_to_buffer( + const axutil_env_t *env, + axis2_char_t *buf, + size_t buf_len, + axiom_search_info_t *search_info, + axiom_mime_parser_t *mime_parser); + +static axis2_bool_t +axiom_mime_parser_is_more_data( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_callback_info_t *callback_info); + +static axis2_char_t * +axiom_mime_parser_process_mime_headers( + const axutil_env_t *env, + axiom_mime_parser_t *mime_parser, + axis2_char_t **mime_id, + axis2_char_t *mime_headers); + +static axis2_status_t +axiom_mime_parser_cache_to_file( + const axutil_env_t* env, + axis2_char_t *buf, + size_t buf_len, + void *handler); + +static void* +axiom_mime_parser_initiate_callback( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_char_t *mime_id, + void *user_param); + +AXIS2_EXTERN axiom_mime_parser_t *AXIS2_CALL +axiom_mime_parser_create( + const axutil_env_t * env) +{ + axiom_mime_parser_t *mime_parser = NULL; + + AXIS2_ENV_CHECK(env, NULL); + mime_parser = (axiom_mime_parser_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_mime_parser_t)); + + if(!mime_parser) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + mime_parser->mime_parts_map = NULL; + mime_parser->soap_body_len = 0; + mime_parser->soap_body_str = NULL; /* shallow copy */ + mime_parser->buffer_size = 1; + mime_parser->max_buffers = AXIOM_MIME_PARSER_MAX_BUFFERS; + mime_parser->attachment_dir = NULL; + mime_parser->mtom_caching_callback = NULL; + mime_parser->callback_name = NULL; + mime_parser->buf_array = NULL; + mime_parser->len_array = NULL; + mime_parser->current_buf_num = 0; + mime_parser->end_of_mime = AXIS2_FALSE; + mime_parser->mime_boundary = NULL; + + mime_parser->mime_parts_map = axutil_hash_make(env); + if(!(mime_parser->mime_parts_map)) + { + axiom_mime_parser_free(mime_parser, env); + return NULL; + } + + return mime_parser; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_mime_parser_free( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + /* The map is passed on to SOAP builder, and SOAP builder take over the + ownership of the map */ + + /* We will unload the callback at the end */ + + if(mime_parser->mtom_caching_callback) + { + axutil_param_t *param = NULL; + param = mime_parser->mtom_caching_callback->param; + + AXIOM_MTOM_CACHING_CALLBACK_FREE(mime_parser->mtom_caching_callback, env); + mime_parser->mtom_caching_callback = NULL; + + if(param) + { + axutil_param_free(param, env); + param = NULL; + } + } + + if(mime_parser->buf_array) + { + AXIS2_FREE(env->allocator, mime_parser->buf_array); + mime_parser->buf_array = NULL; + } + + if(mime_parser->len_array) + { + AXIS2_FREE(env->allocator, mime_parser->len_array); + mime_parser->len_array = NULL; + } + + if(mime_parser) + { + AXIS2_FREE(env->allocator, mime_parser); + } + + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_mime_parser_parse_for_soap( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback, + void *callback_ctx, + axis2_char_t * mime_boundary) +{ + size_t size = 0; + axis2_char_t *soap_str = NULL; + size_t soap_len = 0; + size_t temp_mime_boundary_size = 0; + axis2_char_t *temp_mime_boundary = NULL; + axis2_char_t **buf_array = NULL; + size_t *len_array = NULL; + int buf_num = 0; + axis2_char_t *pos = NULL; + axiom_search_info_t *search_info = NULL; + int part_start = 0; + axis2_bool_t end_of_mime = AXIS2_FALSE; + size_t len = 0; + axis2_char_t *buffer = NULL; + size_t malloc_len = 0; + axis2_callback_info_t *callback_info = NULL; + + callback_info = (axis2_callback_info_t *)callback_ctx; + + /* The user will specify the mime_parser->buffer_size */ + + size = AXIOM_MIME_PARSER_BUFFER_SIZE * (mime_parser->buffer_size); + + /*An array to keep the set of buffers*/ + + buf_array = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t *) * (mime_parser->max_buffers)); + + if(!buf_array) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Failed in creating buffer array"); + return AXIS2_FAILURE; + } + + /*Keeps the corresponding lengths of buffers in buf_array*/ + + len_array = AXIS2_MALLOC(env->allocator, sizeof(size_t) * (mime_parser->max_buffers)); + + if(!len_array) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Failed in creating length array"); + return AXIS2_FAILURE; + } + + mime_parser->buf_array = buf_array; + mime_parser->len_array = len_array; + + temp_mime_boundary = axutil_stracat(env, "--", mime_boundary); + temp_mime_boundary_size = strlen(mime_boundary) + 2; + + /*This struct keeps the pre-post search informations*/ + search_info = AXIS2_MALLOC(env->allocator, sizeof(axiom_search_info_t)); + + /* The first buffer is created */ + buf_array[buf_num] = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (size + 1)); + + /* The buffer is filled from the callback */ + + if(buf_array[buf_num]) + { + len = callback(buf_array[buf_num], (int)size, (void *)callback_ctx); + } + if(len > 0) + { + len_array[buf_num] = len; + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error reading from the stream"); + return AXIS2_FAILURE; + } + + /*starting buffer for the current search*/ + part_start = buf_num; + + /*We are passing the address of the buf_num , beacause that value + is changing inside the method.*/ + + /* Following call to the method will search first \r\n\r\n */ + + pos = axiom_mime_parser_search_for_crlf(env, callback, callback_ctx, &buf_num, len_array, + buf_array, search_info, size, mime_parser); + + if(!pos) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in the message."); + return AXIS2_FAILURE; + } + + /* The patteren contains in one buffer */ + + if((search_info->match_len2 == 0)) + { + /*Readjusting the buffers for the next search and discarding the prevoius + buffers*/ + + /* We need the remaining part in the buffer after the \r\n\r\n*/ + + malloc_len = buf_array[buf_num] + len_array[buf_num] - pos - 4; + if(malloc_len < 0) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in parsing."); + return AXIS2_FAILURE; + } + else + { + /* Here we will create a new buffer of predefined size fill the + * first portion from the remaining part after previous search + * and then fill the remaining from the callback */ + + buffer = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (size + 1)); + + if(malloc_len > 0) + { + memcpy(buffer, pos + 4, malloc_len); + } + + /* Here we need to check for more data, because if the message is too small + * comapred to the reading size there may be no data in the stream , instead + * all the remaining data may be in the buffer.And if there are no more data + * we will set the len to be 0. Otherwise len_array will contain wrong lenghts. + */ + + if(axiom_mime_parser_is_more_data(mime_parser, env, callback_info)) + { + /* There is more data so fill the remaining from the stream*/ + + len = callback(buffer + malloc_len, (int)(size - malloc_len), (void *)callback_ctx); + } + else + { + len = 0; + } + + /* We do not need the data in the previous buffers once we found a particular + * string and after worked with those buffers */ + + axiom_mime_parser_clear_buffers(env, buf_array, part_start, buf_num); + + /* Adding the new buffer to the buffer list */ + + if(len >= 0) + { + buf_array[buf_num] = buffer; + len_array[buf_num] = malloc_len + len; + } + } + } + + /*The pattern divides among two buffers*/ + + else if(search_info->match_len2 > 0) + { + malloc_len = len_array[buf_num] - search_info->match_len2; + if(malloc_len < 0) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in parsing."); + return AXIS2_FAILURE; + } + else + { + buffer = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (size + 1)); + + /* Here the buf_num is the second buffer. We will copy the remaining data + * after the partial string in the second buffer */ + + if(malloc_len > 0) + { + memcpy(buffer, buf_array[buf_num] + search_info->match_len2, malloc_len); + } + if(axiom_mime_parser_is_more_data(mime_parser, env, callback_info)) + { + len = callback(buffer + malloc_len, (int)(size - malloc_len), (void *)callback_ctx); + } + else + { + len = 0; + } + axiom_mime_parser_clear_buffers(env, buf_array, part_start, buf_num); + if(len >= 0) + { + buf_array[buf_num] = buffer; + len_array[buf_num] = malloc_len + len; + } + } + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in parsing."); + return AXIS2_FAILURE; + } + + /*Resetting the previous search data and getting ready + for the next search */ + + part_start = buf_num; + pos = NULL; + malloc_len = 0; + + search_info->match_len1 = 0; + search_info->match_len2 = 0; + + /*In order to extract the soap envelope we need to search for the first + --MIMEBOUNDARY */ + + pos = axiom_mime_parser_search_for_soap(env, callback, callback_ctx, &buf_num, len_array, + buf_array, search_info, size, temp_mime_boundary, mime_parser); + + if(!pos) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error while searching for the SOAP part "); + return AXIS2_FAILURE; + } + + if(search_info->match_len2 == 0) + { + /*Calculating the length of the SOAP str*/ + + soap_len = axiom_mime_parser_calculate_part_len(env, buf_num, len_array, part_start, pos, + buf_array[buf_num]); + if(soap_len > 0) + { + /* Get the SOAP string from the starting and end buffers containing + * the SOAP part */ + + soap_str = axiom_mime_parser_create_part(env, soap_len, buf_num, len_array, part_start, + pos, buf_array, mime_parser); + if(!soap_str) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Error while creating the SOAP part from the message "); + return AXIS2_FAILURE; + } + + malloc_len = len_array[buf_num] - search_info->match_len1 - temp_mime_boundary_size; + if(malloc_len < 0) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in parsing for mime."); + return AXIS2_FAILURE; + } + else + { + /* This will fill the new buffer with remaining data after the + * SOAP */ + + buffer = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (size + 1)); + + memset(buffer, 0, size + 1); + if(malloc_len > 0) + { + memcpy(buffer, pos + temp_mime_boundary_size, malloc_len); + } + if(axiom_mime_parser_is_more_data(mime_parser, env, callback_info)) + { + len = callback(buffer + malloc_len,(int)(size - malloc_len),(void *)callback_ctx); + } + else + { + len = 0; + } + axiom_mime_parser_clear_buffers(env, buf_array, part_start, buf_num); + if(len >= 0) + { + buf_array[buf_num] = buffer; + len_array[buf_num] = malloc_len + len; + } + } + } + else + { + return AXIS2_FAILURE; + } + } + + /* This is the condition where the --MIMEBOUNDARY is divided among two + * buffers */ + + else if(search_info->match_len2 > 0) + { + soap_len = axiom_mime_parser_calculate_part_len(env, buf_num - 1, len_array, part_start, + pos, buf_array[buf_num - 1]); + + if(soap_len > 0) + { + /* Here we pass buf_num-1 because buf_num does not have any thing we want to + * for this particular part. It begins with the latter part of the search string */ + + soap_str = axiom_mime_parser_create_part(env, soap_len, buf_num - 1, len_array, + part_start, pos, buf_array, mime_parser); + if(!soap_str) + { + return AXIS2_FAILURE; + } + + malloc_len = len_array[buf_num] - search_info->match_len2; + if(malloc_len < 0) + { + return AXIS2_FAILURE; + } + else + { + buffer = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (size + 1)); + + if(malloc_len > 0) + { + memcpy(buffer, buf_array[buf_num] + search_info->match_len2, malloc_len); + } + + if(axiom_mime_parser_is_more_data(mime_parser, env, callback_info)) + { + len = callback(buffer + malloc_len,(int)(size - malloc_len),(void *)callback_ctx); + } + else + { + len = 0; + } + axiom_mime_parser_clear_buffers(env, buf_array, part_start, buf_num); + if(len >= 0) + { + buf_array[buf_num] = buffer; + len_array[buf_num] = malloc_len + len; + } + } + } + else + { + return AXIS2_FAILURE; + } + } + + mime_parser->soap_body_str = soap_str; + mime_parser->soap_body_len = soap_len; + mime_parser->current_buf_num = buf_num; + + /* There are multipart/related messages which does not contain attachments + * The only mime_part is the soap envelope. So for those messages the mime + * boundary after the soap will end up with -- + * So we will check that here and if we found then the logic inside the + * while loop will not be executed */ + + end_of_mime = (AXIOM_MIME_BOUNDARY_BYTE == *(buf_array[buf_num])) && (AXIOM_MIME_BOUNDARY_BYTE + == *(buf_array[buf_num] + 1)); + if(end_of_mime) + { + AXIS2_FREE(env->allocator, buf_array[buf_num]); + buf_array[buf_num] = NULL; + } + + if(temp_mime_boundary) + { + AXIS2_FREE(env->allocator, temp_mime_boundary); + temp_mime_boundary = NULL; + } + + if(search_info) + { + AXIS2_FREE(env->allocator, search_info); + search_info = NULL; + } + + mime_parser->end_of_mime = end_of_mime; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axiom_mime_parser_parse_for_attachments( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback, + void *callback_ctx, + axis2_char_t * mime_boundary, + void *user_param) +{ + int count = 0; + axiom_search_info_t *search_info = NULL; + axis2_char_t *pos = NULL; + int part_start = 0; + axis2_char_t **buf_array = NULL; + size_t *len_array = NULL; + int buf_num = 0; + size_t size = 0; + size_t malloc_len = 0; + axis2_callback_info_t *callback_info = NULL; + axis2_char_t *temp_mime_boundary = NULL; + size_t temp_mime_boundary_size = 0; + axis2_bool_t end_of_mime = AXIS2_FALSE; + + callback_info = (axis2_callback_info_t *)callback_ctx; + + search_info = AXIS2_MALLOC(env->allocator, sizeof(axiom_search_info_t)); + + size = AXIOM_MIME_PARSER_BUFFER_SIZE * (mime_parser->buffer_size); + + buf_array = mime_parser->buf_array; + len_array = mime_parser->len_array; + buf_num = mime_parser->current_buf_num; + + /*--MIMEBOUNDARY + mime_headr1:....... + mime_headr2:.... + + Binarstart................. + ...............--MIMEBOUNDARY + */ + + /* This loop will extract all the attachments in the message. The condition + * with the count is needed because if the sender not marked the end of the + * attachment wiht -- then this loop may run infinitely. To prevent that + * this additional condition has been put */ + + temp_mime_boundary = axutil_stracat(env, "--", mime_boundary); + temp_mime_boundary_size = strlen(mime_boundary) + 2; + + while((!(mime_parser->end_of_mime)) && count < AXIOM_MIME_PARSER_END_OF_MIME_MAX_COUNT) + { + /*First we will search for \r\n\r\n*/ + axis2_char_t *mime_id = NULL; + axis2_char_t *mime_type = NULL; + size_t mime_headers_len = 0; + size_t mime_binary_len = 0; + axis2_char_t *mime_binary = NULL; + axis2_char_t *mime_headers = NULL; + axis2_char_t *buffer = NULL; + int len = 0; + axis2_status_t status = AXIS2_FAILURE; + + search_info->match_len1 = 0; + search_info->match_len2 = 0; + pos = NULL; + part_start = buf_num; + + malloc_len = 0; + + count++; + + pos = axiom_mime_parser_search_for_crlf(env, callback, callback_ctx, &buf_num, len_array, + buf_array, search_info, size, mime_parser); + + if(!pos) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in parsing for mime."); + return NULL; + } + + /*The pattern contains in one buffer*/ + if(search_info->match_len2 == 0) + { + /*We found it . so lets seperates the details of this binary into + mime headers.*/ + + mime_headers_len = axiom_mime_parser_calculate_part_len(env, buf_num, len_array, + part_start, pos, buf_array[buf_num]); + if(mime_headers_len > 0) + { + mime_headers = axiom_mime_parser_create_part(env, mime_headers_len, buf_num, + len_array, part_start, pos, buf_array, mime_parser); + + if(!mime_headers) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in parsing for mime headers."); + return NULL; + } + malloc_len = buf_array[buf_num] + len_array[buf_num] - pos - 4; + + /*This should be > 0 , > 0 means there is some part to copy = 0 means + there is nothing to copy*/ + if(malloc_len < 0) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in parsing for mime headers"); + return NULL; + } + + else + { + buffer = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (size + 1)); + + if(malloc_len > 0) + { + memcpy(buffer, pos + 4, malloc_len); + } + + if(axiom_mime_parser_is_more_data(mime_parser, env, callback_info)) + { + len = callback(buffer + malloc_len,(int)(size - malloc_len),(void *)callback_ctx); + } + else + { + len = 0; + } + axiom_mime_parser_clear_buffers(env, buf_array, part_start, buf_num); + if(len >= 0) + { + buf_array[buf_num] = buffer; + len_array[buf_num] = malloc_len + len; + } + } + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in parsing for mime headers."); + return NULL; + } + } + + else if(search_info->match_len2 > 0) + { + /*Now we extract the mime headers */ + + mime_headers_len = axiom_mime_parser_calculate_part_len(env, buf_num - 1, len_array, + part_start, pos, buf_array[buf_num - 1]); + + if(mime_headers_len > 0) + { + mime_headers = axiom_mime_parser_create_part(env, mime_headers_len, buf_num - 1, + len_array, part_start, pos, buf_array, mime_parser); + if(!mime_headers) + { + return NULL; + } + + malloc_len = len_array[buf_num] - search_info->match_len2; + if(malloc_len < 0) + { + return NULL; + } + else + { + buffer = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (size + 1)); + + if(malloc_len > 0) + { + memcpy(buffer, buf_array[buf_num] + search_info->match_len2, malloc_len); + } + if(axiom_mime_parser_is_more_data(mime_parser, env, callback_info)) + { + len = callback(buffer + malloc_len,(int)(size - malloc_len),(void*)callback_ctx); + } + else + { + len = 0; + } + axiom_mime_parser_clear_buffers(env, buf_array, part_start, buf_num); + if(len >= 0) + { + buf_array[buf_num] = buffer; + len_array[buf_num] = malloc_len + len; + } + } + } + else + { + return NULL; + } + } + else + { + return NULL; + } + + pos = NULL; + + search_info->match_len1 = 0; + search_info->match_len2 = 0; + + part_start = buf_num; + malloc_len = 0; + + mime_type + = axiom_mime_parser_process_mime_headers(env, mime_parser, &mime_id, mime_headers); + + if(!mime_id) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Error in parsing for mime headers.Mime id did not find"); + return NULL; + } + + if(!mime_type) + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Mime type did not find"); + } + + /*We extract the mime headers. So lets search for the attachment.*/ + + pos = axiom_mime_parser_search_for_attachment(mime_parser, env, callback, callback_ctx, + &buf_num, len_array, buf_array, search_info, size, temp_mime_boundary, mime_id, + user_param); + + if(pos) + { + /*If it is small we are not caching. Hence the attachment + is in memory. So store it in a buffer. */ + + if(!search_info->cached) + { + if(search_info->match_len2 == 0) + { + /* mime_binary contains the attachment when it does not + * cached */ + + mime_binary_len = axiom_mime_parser_calculate_part_len(env, buf_num, len_array, + part_start, pos, buf_array[buf_num]); + if(mime_binary_len > 0) + { + mime_binary = axiom_mime_parser_create_part(env, mime_binary_len, buf_num, + len_array, part_start, pos, buf_array, mime_parser); + if(!mime_binary) + { + return NULL; + } + } + else + { + return NULL; + } + } + + else if(search_info->match_len2 > 0) + { + mime_binary_len = axiom_mime_parser_calculate_part_len(env, buf_num - 1, + len_array, part_start, pos, buf_array[buf_num - 1]); + + if(mime_binary_len > 0) + { + mime_binary = axiom_mime_parser_create_part(env, mime_binary_len, buf_num + - 1, len_array, part_start, pos, buf_array, mime_parser); + if(!mime_binary) + { + return NULL; + } + } + else + { + return NULL; + } + } + } + + /* The functionality below is common when it is cached or not. It deals with remaining + * after a particualr attachment, Those may be related to a end of mime_boundary or + * another attachment */ + + if(search_info->match_len2 == 0) + { + malloc_len = len_array[buf_num] - search_info->match_len1 - temp_mime_boundary_size; + if(malloc_len < 0) + { + return NULL; + } + else + { + buffer = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (size + 1)); + + if(malloc_len > 0) + { + memcpy(buffer, pos + temp_mime_boundary_size, malloc_len); + } + + /*When the last buffer only containing -- we know this is the end + of the attachments. Hence we don't need to read again*/ + + if(malloc_len != 2) + { + if(axiom_mime_parser_is_more_data(mime_parser, env, callback_info)) + { + len = callback(buffer + malloc_len,(int)(size - malloc_len),(void*)callback_ctx); + } + else + { + len = 0; + } + if(len >= 0) + { + len_array[buf_num] = malloc_len + len; + } + } + + /* This means there is another attachment */ + else + { + len_array[buf_num] = malloc_len; + } + axiom_mime_parser_clear_buffers(env, buf_array, part_start, buf_num); + buf_array[buf_num] = buffer; + } + } + else if(search_info->match_len2 > 0) + { + malloc_len = len_array[buf_num] - search_info->match_len2; + + if(malloc_len < 0) + { + return NULL; + } + else + { + buffer = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (size + 1)); + + if(malloc_len > 0) + { + memcpy(buffer, buf_array[buf_num] + search_info->match_len2, malloc_len); + } + if(malloc_len != 2) + { + if(axiom_mime_parser_is_more_data(mime_parser, env, callback_info)) + { + len = callback(buffer + malloc_len,(int)(size - malloc_len),(void *)callback_ctx); + } + else + { + len = 0; + } + if(len >= 0) + { + len_array[buf_num] = malloc_len + len; + } + } + else + { + len_array[buf_num] = malloc_len; + } + axiom_mime_parser_clear_buffers(env, buf_array, part_start, buf_num); + buf_array[buf_num] = buffer; + } + } + } + else + { + return NULL; + } + + /*We have the attachment now either cached or not. So lets put it in the mime_parts + * hash map with the mime_id. Remember at this moment we have already processed the + * mime_headers and mime_id is already there */ + + /* In the case user has not specified the callback or the attachment dir . So we cached it to a memory + * buffer. Hence the data_handler type we need to create is different */ + + if((search_info->cached) && (!mime_parser->attachment_dir) && (!mime_parser->callback_name)) + { + mime_binary = (axis2_char_t *)search_info->handler; + mime_binary_len = search_info->binary_size; + } + + /* Storing the attachment in the hash map with the id*/ + + status = axiom_mime_parser_store_attachment(env, mime_parser, mime_id, mime_type, + mime_binary, mime_binary_len, search_info->cached); + + /*Check wether we encounter --MIMEBOUNDARY-- to find the end of mime*/ + + if(buf_array[buf_num]) + { + /* Here we check for the end of mime */ + + end_of_mime = (AXIOM_MIME_BOUNDARY_BYTE == *(buf_array[buf_num])) + && (AXIOM_MIME_BOUNDARY_BYTE == *(buf_array[buf_num] + 1)); + if(end_of_mime) + { + AXIS2_FREE(env->allocator, buf_array[buf_num]); + buf_array[buf_num] = NULL; + } + mime_parser->end_of_mime = end_of_mime; + } + + if(mime_headers) + { + AXIS2_FREE(env->allocator, mime_headers); + mime_headers = NULL; + } + + if(status != AXIS2_SUCCESS) + { + return NULL; + } + } + + /*Do the necessary cleaning */ + + /*if (buf_array) + { + AXIS2_FREE(env->allocator, buf_array); + buf_array = NULL; + } + + if (len_array) + { + AXIS2_FREE(env->allocator, len_array); + len_array = NULL; + }*/ + + if(temp_mime_boundary) + { + AXIS2_FREE(env->allocator, temp_mime_boundary); + temp_mime_boundary = NULL; + } + + if(search_info) + { + AXIS2_FREE(env->allocator, search_info); + search_info = NULL; + } + + return mime_parser->mime_parts_map; + +} + +/*This method will search for \r\n\r\n */ + +static axis2_char_t * +axiom_mime_parser_search_for_crlf( + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback, + void *callback_ctx, + int *buf_num, + size_t *len_array, + axis2_char_t **buf_array, + axiom_search_info_t *search_info, + size_t size, + axiom_mime_parser_t *mime_parser) +{ + axis2_char_t *found = NULL; + int len = 0; + + search_info->search_str = "\r\n\r\n"; + search_info->buffer1 = NULL; + search_info->buffer2 = NULL; + search_info->len1 = 0; + search_info->len2 = 0; + search_info->match_len1 = 0; + search_info->match_len2 = 0; + search_info->primary_search = AXIS2_FALSE; + search_info->cached = AXIS2_FALSE; + search_info->handler = NULL; + search_info->binary_size = 0; + + /*First do a search in the first buffer*/ + + if(buf_array[*buf_num]) + { + search_info->buffer1 = buf_array[*buf_num]; + search_info->len1 = len_array[*buf_num]; + found = axiom_mime_parser_search_string(search_info, env); + } + + while(!found) + { + /*Let's read another buffer and do a boundary search in both*/ + + *buf_num = *buf_num + 1; + buf_array[*buf_num] = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (size + 1)); + + if(buf_array[*buf_num]) + { + len = callback(buf_array[*buf_num], (int)size, (void *)callback_ctx); + } + if(len > 0) + { + len_array[*buf_num] = len; + search_info->buffer2 = buf_array[*buf_num]; + search_info->len2 = len; + found = axiom_mime_parser_search_string(search_info, env); + } + else + { + break; + } + if(!found) + { + /*Let's do a full search in the second buffer*/ + + search_info->buffer1 = buf_array[*buf_num]; + search_info->len1 = len_array[*buf_num]; + search_info->primary_search = AXIS2_FALSE; + search_info->buffer2 = NULL; + search_info->len2 = 0; + found = axiom_mime_parser_search_string(search_info, env); + } + } + + return found; +} + +/* This method will search for the mime_boundary after the SOAP part + * of the message */ + +static axis2_char_t * +axiom_mime_parser_search_for_soap( + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback, + void *callback_ctx, + int *buf_num, + size_t *len_array, + axis2_char_t **buf_array, + axiom_search_info_t *search_info, + size_t size, + axis2_char_t *mime_boundary, + axiom_mime_parser_t *mime_parser) +{ + axis2_char_t *found = NULL; + int len = 0; + + /* What we need to search is the mime_boundary */ + + search_info->search_str = mime_boundary; + search_info->buffer1 = NULL; + search_info->buffer2 = NULL; + search_info->len1 = 0; + search_info->len2 = 0; + search_info->match_len1 = 0; + search_info->match_len2 = 0; + search_info->primary_search = AXIS2_FALSE; + + if(buf_array[*buf_num]) + { + search_info->buffer1 = buf_array[*buf_num]; + search_info->len1 = len_array[*buf_num]; + found = axiom_mime_parser_search_string(search_info, env); + + /* Inside this search primary_search flag will be set to TRUE */ + } + + while(!found) + { + /* We need to create the second buffer and do the search for the + * mime_boundary in the both the buffers */ + + *buf_num = *buf_num + 1; + buf_array[*buf_num] = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (size + 1)); + + if(buf_array[*buf_num]) + { + len = callback(buf_array[*buf_num], (int)size, (void *)callback_ctx); + } + if(len > 0) + { + /* In this search we are matching end part of the first + * buffer and starting part of the previous buffer */ + len_array[*buf_num] = len; + search_info->buffer2 = buf_array[*buf_num]; + search_info->len2 = len; + found = axiom_mime_parser_search_string(search_info, env); + } + else + { + break; + } + if(!found) + { + search_info->buffer1 = buf_array[*buf_num]; + search_info->len1 = len_array[*buf_num]; + search_info->primary_search = AXIS2_FALSE; + search_info->buffer2 = NULL; + search_info->len2 = 0; + found = axiom_mime_parser_search_string(search_info, env); + } + } + + return found; +} + +/*The caching is done in this function. Caching happens when we did not + find the mime_boundary in initial two buffers. So the maximum size + that we are keeping in memory is 2 * size. This size can be configurable from + the aixs.xml. The caching may starts when the search failed with the + second buffer. + In this logic first we will search for a callback to cache. If it is not + there then we will search for a directory to save the file. If it is also + not there then the attachment will be in memory. + */ + +static axis2_char_t * +axiom_mime_parser_search_for_attachment( + axiom_mime_parser_t *mime_parser, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback, + void *callback_ctx, + int *buf_num, + size_t *len_array, + axis2_char_t **buf_array, + axiom_search_info_t *search_info, + size_t size, + axis2_char_t *mime_boundary, + axis2_char_t *mime_id, + void *user_param) +{ + axis2_char_t *found = NULL; + int len = 0; + axis2_status_t status = AXIS2_FAILURE; + axis2_char_t *temp = NULL; + size_t temp_length = 0; + axis2_char_t *file_name = NULL; + + search_info->search_str = mime_boundary; + search_info->buffer1 = NULL; + search_info->buffer2 = NULL; + search_info->len1 = 0; + search_info->len2 = 0; + search_info->match_len1 = 0; + search_info->match_len2 = 0; + search_info->primary_search = AXIS2_FALSE; + search_info->cached = AXIS2_FALSE; + search_info->handler = NULL; + + /*First search in the incoming buffer*/ + + if(buf_array[*buf_num]) + { + search_info->buffer1 = buf_array[*buf_num]; + search_info->len1 = len_array[*buf_num]; + found = axiom_mime_parser_search_string(search_info, env); + } + + while(!found) + { + if(search_info->cached) + { + if(mime_parser->callback_name) + { + if(!(search_info->handler)) + { + /* If the callback is not loaded yet then we load it*/ + if(!mime_parser->mtom_caching_callback) + { + search_info->handler = axiom_mime_parser_initiate_callback(mime_parser, + env, mime_id, user_param); + if(!(search_info->handler)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Caching Callback is not loaded"); + return NULL; + } + } + } + /*So lets cache the previous buffer which has undergone the + full search and the partial search. */ + + if(mime_parser->mtom_caching_callback) + { + /* Caching callback is loaded. So we can cache the previous buffer */ + status + = AXIOM_MTOM_CACHING_CALLBACK_CACHE(mime_parser->mtom_caching_callback, + env, buf_array[*buf_num - 1], (int)len_array[*buf_num - 1], + search_info->handler); + } + } + + else if(mime_parser->attachment_dir) + { + if(!(search_info->handler)) + { + /* If the File is not opened yet we will open it*/ + + axis2_char_t *encoded_mime_id = NULL; + + /* Some times content-ids urls, hence we need to encode them + * becasue we can't create files with / */ + + encoded_mime_id = AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t)) + * (strlen(mime_id))); + memset(encoded_mime_id, 0, strlen(mime_id)); + encoded_mime_id = axutil_url_encode(env, encoded_mime_id, mime_id, (int)strlen( + mime_id)); + if(!encoded_mime_id) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Mime Id encoding failed"); + return NULL; + } + + file_name = axutil_stracat(env, mime_parser->attachment_dir, encoded_mime_id); + AXIS2_FREE(env->allocator, encoded_mime_id); + encoded_mime_id = NULL; + + if(!file_name) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Caching file name creation error"); + return NULL; + } + search_info->handler = (void *)fopen(file_name, "ab+"); + if(!(search_info->handler)) + { + return NULL; + } + } + + /*So lets cache the previous buffer which has undergone the + full search and the partial search. */ + + status = axiom_mime_parser_cache_to_file(env, buf_array[*buf_num - 1], + len_array[*buf_num - 1], search_info->handler); + } + + else + { + /* Here the user has not specified the caching File location. So we are + * not going to cache. Instead we store the attachment in the buffer */ + status = axiom_mime_parser_cache_to_buffer(env, buf_array[*buf_num - 1], + len_array[*buf_num - 1], search_info, mime_parser); + } + + if(status == AXIS2_FAILURE) + { + return NULL; + } + /*Here we interchange the buffers.*/ + + temp = buf_array[*buf_num - 1]; + buf_array[*buf_num - 1] = buf_array[*buf_num]; + buf_array[*buf_num] = temp; + temp_length = len_array[*buf_num - 1]; + len_array[*buf_num - 1] = len_array[*buf_num]; + len_array[*buf_num] = temp_length; + if(buf_array[*buf_num]) + { + /*The cached buffer is the one which get filled.*/ + len = callback(buf_array[*buf_num], (int)size, (void *)callback_ctx); + } + } + + /*Size of the data in memory not yet risen to the caching threasold + *So we can create the second buffer */ + else + { + *buf_num = *buf_num + 1; + buf_array[*buf_num] = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (size + 1)); + + if(buf_array[*buf_num]) + { + len = callback(buf_array[*buf_num], (int)size, (void *)callback_ctx); + } + } + + /*Doing a complete search in newly cretaed buffer*/ + + if(len > 0) + { + len_array[*buf_num] = len; + search_info->buffer2 = buf_array[*buf_num]; + search_info->len2 = len; + found = axiom_mime_parser_search_string(search_info, env); + } + else + { + break; + } + + /* Now there are two buffers. If the searching string is not + * here then we must cache the first buffer */ + + if(!found) + { + /*So now we must start caching*/ + search_info->buffer1 = buf_array[*buf_num]; + search_info->len1 = len_array[*buf_num]; + search_info->primary_search = AXIS2_FALSE; + search_info->buffer2 = NULL; + search_info->len2 = 0; + found = axiom_mime_parser_search_string(search_info, env); + if(!found) + { + /* So at the begining of the next search we start + * that only after caching this data */ + search_info->cached = AXIS2_TRUE; + } + } + } + + /* Here we are out of the loop. If there is no error then this means + * the searching string is found */ + if(search_info->cached && found) + { + /* If the attachment is cached then we need to cache the + * final buffer */ + + if(search_info->match_len2 == 0) + { + /* This is the case where we found the whole string in one buffer + * So we need to cache previous buffer and the data up to the starting + * point of the search string in the current buffer */ + + /* deduct last 2 CRLF character. + * For buffering case, it will be done when creating datahandler.*/ + + if(mime_parser->mtom_caching_callback) + { + status = AXIOM_MTOM_CACHING_CALLBACK_CACHE(mime_parser->mtom_caching_callback, env, + buf_array[*buf_num - 1], (int)len_array[*buf_num - 1], search_info->handler); + if(status == AXIS2_SUCCESS) + { + status + = AXIOM_MTOM_CACHING_CALLBACK_CACHE(mime_parser->mtom_caching_callback, + env, buf_array[*buf_num], (int)(found - buf_array[*buf_num] - 2), + search_info->handler); + } + } + + else if(mime_parser->attachment_dir) + { + status = axiom_mime_parser_cache_to_file(env, buf_array[*buf_num - 1], + len_array[*buf_num - 1], search_info->handler); + if(status == AXIS2_SUCCESS) + { + status = axiom_mime_parser_cache_to_file(env, buf_array[*buf_num], found + - buf_array[*buf_num] - 2, search_info->handler); + } + } + + /* If the callback or a file is not there then the data is appended to the buffer */ + + else + { + status = axiom_mime_parser_cache_to_buffer(env, buf_array[*buf_num - 1], + len_array[*buf_num - 1], search_info, mime_parser); + if(status == AXIS2_SUCCESS) + { + status = axiom_mime_parser_cache_to_buffer(env, buf_array[*buf_num], found + - buf_array[*buf_num], search_info, mime_parser); + } + } + } + else if(search_info->match_len2 > 0) + { + /*Here the curent buffer has partial mime boundary. So we need + to cache only the previous buffer. */ + + if(mime_parser->mtom_caching_callback) + { + status = AXIOM_MTOM_CACHING_CALLBACK_CACHE(mime_parser->mtom_caching_callback, env, + buf_array[*buf_num - 1], (int)(search_info->match_len1 - 2), search_info->handler); + } + + else if(mime_parser->attachment_dir) + { + status = axiom_mime_parser_cache_to_file(env, buf_array[*buf_num - 1], + search_info->match_len1 - 2, search_info->handler); + } + else + { + status = axiom_mime_parser_cache_to_buffer(env, buf_array[*buf_num - 1], + search_info->match_len1, search_info, mime_parser); + } + } + else + { + return NULL; + } + + if(status == AXIS2_FAILURE) + { + return NULL; + } + } + + /* Parsing is done so lets close the relative handlers */ + + if(search_info->handler) + { + if(mime_parser->mtom_caching_callback) + { + status = AXIOM_MTOM_CACHING_CALLBACK_CLOSE_HANDLER(mime_parser->mtom_caching_callback, + env, search_info->handler); + if(status == AXIS2_FAILURE) + { + return NULL; + } + } + + else if(mime_parser->attachment_dir) + { + if(fclose((FILE *)(search_info->handler)) == 0) + { + status = AXIS2_SUCCESS; + } + else + { + status = AXIS2_FAILURE; + } + + AXIS2_FREE(env->allocator, file_name); + file_name = NULL; + + if(status == AXIS2_FAILURE) + { + return NULL; + } + } + } + return found; +} + +/*following two functions are used to extract important information + from the buffer list. eg: SOAP, MIME_HEADERS*/ + +/*marker is the starting buffer of the required + part and pos is the end point of that part */ + +static size_t +axiom_mime_parser_calculate_part_len( + const axutil_env_t *env, + int buf_num, + size_t *len_list, + int marker, + axis2_char_t *pos, + axis2_char_t *buf) +{ + size_t part_len = 0; + int i = 0; + + for(i = marker; i < buf_num; i++) + { + part_len += len_list[i]; + } + + part_len = part_len + (pos - buf); + + return part_len; +} + +static axis2_char_t * +axiom_mime_parser_create_part( + const axutil_env_t *env, + size_t part_len, + int buf_num, + size_t *len_list, + int marker, + axis2_char_t *pos, + axis2_char_t **buf_list, + axiom_mime_parser_t *mime_parser) +{ + /*We will copy the set of buffers which contains the required part. + This part can be the SOAP message , mime headers or the mime + binary in the case of none cahced.*/ + + axis2_char_t *part_str = NULL; + int i = 0; + size_t temp = 0; + + part_str = AXIS2_MALLOC(env->allocator, sizeof(char) * (part_len + 1)); + + if(!part_str) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Failed in creating buffer"); + return NULL; + } + + /* Copy from the part starting buffer to the + * curent buffer */ + + for(i = marker; i < buf_num; i++) + { + if(buf_list[i]) + { + memcpy(part_str + temp, buf_list[i], len_list[i]); + temp += len_list[i]; + } + } + /* Finally we are copying from the final portion */ + + memcpy(part_str + temp, buf_list[i], pos - buf_list[i]); + + part_str[part_len] = '\0'; + + return part_str; +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axiom_mime_parser_get_mime_parts_map( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env) +{ + return mime_parser->mime_parts_map; +} + +AXIS2_EXTERN size_t AXIS2_CALL +axiom_mime_parser_get_soap_body_len( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env) +{ + return mime_parser->soap_body_len; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_mime_parser_get_soap_body_str( + axiom_mime_parser_t * mime_parser, + const axutil_env_t * env) +{ + return mime_parser->soap_body_str; +} + +/*This is the new search function. This will first do a + search for the entire search string.Then will do a search + for the partial string which can be divided among two buffers.*/ + +static axis2_char_t * +axiom_mime_parser_search_string( + axiom_search_info_t *search_info, + const axutil_env_t *env) +{ + axis2_char_t *pos = NULL; + axis2_char_t *old_pos = NULL; + axis2_char_t *found = NULL; + size_t str_length = 0; + size_t search_length = 0; + + str_length = strlen(search_info->search_str); + + /*First lets search the entire buffer*/ + if(!search_info->primary_search) + { + old_pos = search_info->buffer1; + + do + { + /*find the first byte. We need to adhere to this + approach rather than straightaway using strstr + because the buffer1 can be containg binary data*/ + + pos = NULL; + + search_length = search_info->buffer1 + search_info->len1 - old_pos - str_length + 1; + + if(search_length < 0) + { + break; + } + + if(old_pos) + { + pos = memchr(old_pos, *(search_info->search_str), search_length); + } + + /* found it so lets check the remaining */ + + if(pos) + { + found = axutil_strstr(pos, search_info->search_str); + if(found) + { + search_info->match_len1 = found - search_info->buffer1; + break; + } + else + { + old_pos = pos + 1; + } + } + } + while(pos); + } + + search_info->primary_search = AXIS2_TRUE; + + if(found) + { + return found; + } + + /*So we didn't find the string in the buffer + lets check whether it is divided in two buffers*/ + + else + { + size_t offset = 0; + pos = NULL; + old_pos = NULL; + found = NULL; + search_length = 0; + + if(search_info->buffer2) + { + old_pos = search_info->buffer1 + search_info->len1 - str_length + 1; + do + { + /*First check the starting byte*/ + pos = NULL; + found = NULL; + + search_length = search_info->buffer1 + search_info->len1 - old_pos; + + if(search_length < 0) + { + break; + } + + pos = memchr(old_pos, *(search_info->search_str), search_length); + + if(pos) + { + offset = search_info->buffer1 + search_info->len1 - pos; + + /*First match the beginng to offset in buffer1*/ + + if(offset > 0) + { + if(memcmp(pos, search_info->search_str, offset) == 0) + { + found = pos; + } + + /*We found something in buffer1 so lets match the + remaining in buffer2*/ + + if(found) + { + if(memcmp(search_info->buffer2, search_info->search_str + offset, + str_length - offset) == 0) + { + search_info->match_len2 = str_length - offset; + search_info->match_len1 = found - search_info->buffer1; + break; + } + else + { + old_pos = pos + 1; + } + } + else + { + old_pos = pos + 1; + } + } + } + } + while(pos); + + /* We will set this to AXIS2_FALSE so when the next time this + * search method is called it will do a full search first for buffer1 */ + search_info->primary_search = AXIS2_FALSE; + + return found; + } + else + { + return NULL; + } + } +} + +/* This method creates a data_handler out of the attachment + * and store the data_handler in the mime_parts map */ + +static axis2_status_t +axiom_mime_parser_store_attachment( + const axutil_env_t *env, + axiom_mime_parser_t *mime_parser, + axis2_char_t *mime_id, + axis2_char_t *mime_type, + axis2_char_t *mime_binary, + size_t mime_binary_len, + axis2_bool_t cached) +{ + if(mime_parser->mime_parts_map) + { + if(mime_id) + { + axiom_data_handler_t *data_handler = NULL; + + /* Handling the case where attachment is cached using a callback */ + + if(mime_parser->callback_name && cached) + { + data_handler = axiom_data_handler_create(env, NULL, mime_type); + if(data_handler) + { + axiom_data_handler_set_cached(data_handler, env, AXIS2_TRUE); + axiom_data_handler_set_data_handler_type(data_handler, env, + AXIOM_DATA_HANDLER_TYPE_CALLBACK); + } + } + + /* Handling the case where attachment is cached to a file*/ + + else if(mime_parser->attachment_dir && cached) + { + axis2_char_t *attachment_location = NULL; + axis2_char_t *encoded_mime_id = NULL; + + /* Some times content-ids urls, hence we need to encode them + * becasue we can't create files with / */ + + encoded_mime_id = AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t)) * (strlen( + mime_id))); + memset(encoded_mime_id, 0, strlen(mime_id)); + encoded_mime_id = axutil_url_encode( + env, encoded_mime_id, mime_id, (int)strlen(mime_id)); + if(!encoded_mime_id) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Mime Id encoding failed"); + return AXIS2_FAILURE; + } + + attachment_location = axutil_stracat(env, mime_parser->attachment_dir, + encoded_mime_id); + + AXIS2_FREE(env->allocator, encoded_mime_id); + encoded_mime_id = NULL; + + if(attachment_location) + { + + data_handler = axiom_data_handler_create(env, attachment_location, mime_type); + if(data_handler) + { + axiom_data_handler_set_cached(data_handler, env, AXIS2_TRUE); + + } + AXIS2_FREE(env->allocator, attachment_location); + attachment_location = NULL; + } + } + + /* Attachment is in memory, either it is small to be cached or + * user does not provided the attachment cached directory */ + + else if(mime_binary) + { + data_handler = axiom_data_handler_create(env, NULL, mime_type); + if(data_handler) + { + axiom_data_handler_set_binary_data(data_handler, env, mime_binary, + mime_binary_len - 2); + } + } + axiom_data_handler_set_mime_id(data_handler, env, mime_id); + + axutil_hash_set(mime_parser->mime_parts_map, mime_id, AXIS2_HASH_KEY_STRING, + data_handler); + if(mime_type) + { + AXIS2_FREE(env->allocator, mime_type); + } + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Mime Id or Mime rype not found"); + return AXIS2_FAILURE; + /*axis2_char_t temp_boundry[1024]; + sprintf(temp_boundry, "--%s--", mime_boundary); + if (body_mime && axutil_strstr(body_mime, temp_boundry)) + { + break; + }*/ + } + return AXIS2_SUCCESS; + } + else + { + return AXIS2_FAILURE; + } +} + +/* This method will process the mime_headers for a particualr + attacment and return the mime_id */ + +static axis2_char_t * +axiom_mime_parser_process_mime_headers( + const axutil_env_t *env, + axiom_mime_parser_t *mime_parser, + axis2_char_t **mime_id, + axis2_char_t *mime_headers) +{ + axis2_char_t *id = NULL; + axis2_char_t *type = NULL; + axis2_char_t *pos = NULL; + + /* Get the MIME ID */ + if(mime_headers) + { + id = axutil_strcasestr(mime_headers, AXIOM_MIME_HEADER_CONTENT_ID); + type = axutil_strcasestr(mime_headers, AXIOM_MIME_HEADER_CONTENT_TYPE); + if(type) + { + axis2_char_t *end = NULL; + axis2_char_t *temp_type = NULL; + type += axutil_strlen(AXIOM_MIME_HEADER_CONTENT_TYPE); + while(type && *type && *type != ':') + { + type++; + } + type++; + while(type && *type && *type == ' ') + { + type++; + } + end = type; + while(end && *end && !isspace((int)*end)) + { + end++; + } + if((end - type) > 0) + { + temp_type = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * ((end - type) + 1)); + if(!temp_type) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "No memory. Failed in creating Content-Type"); + return NULL; + } + memcpy(temp_type, type, (end - type)); + temp_type[end - type] = '\0'; + type = temp_type; + } + } + if(id) + { + id += axutil_strlen(AXIOM_MIME_HEADER_CONTENT_ID); + while(id && *id && *id != ':') + { + id++; + } + if(id) + { + while(id && *id && *id != '<') + { + id++; + } + id++; + pos = axutil_strstr(id, ">"); + if(pos) + { + int mime_id_len = 0; + mime_id_len = (int)(pos - id); + *mime_id = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * mime_id_len + 1); + /* The MIME ID will be freed by the SOAP builder */ + if(*mime_id) + { + memcpy(*mime_id, id, mime_id_len); + (*mime_id)[mime_id_len] = '\0'; + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "No memory. Failed in creating MIME ID"); + return NULL; + } + } + } + } + else + { + /*axis2_char_t temp_boundry[1024]; + sprintf(temp_boundry, "--%s--", mime_boundary); + if (body_mime && axutil_strstr(body_mime, temp_boundry)) + { + break; + }*/ + return NULL; + } + return type; + } + else + { + return NULL; + } +} + +/*This is used to free some unwanted buffers. For example we did + not want the buffers which contains the data before the soap + envelope starts. */ + +static void +axiom_mime_parser_clear_buffers( + const axutil_env_t *env, + axis2_char_t **buf_list, + int free_from, + int free_to) +{ + int i = 0; + + for(i = free_from; i <= free_to; i++) + { + if(buf_list[i]) + { + AXIS2_FREE(env->allocator, buf_list[i]); + buf_list[i] = NULL; + } + } + return; +} + +/* Instead of caching to a file this method will cache it + * to a buffer */ + +static axis2_status_t +axiom_mime_parser_cache_to_buffer( + const axutil_env_t *env, + axis2_char_t *buf, + size_t buf_len, + axiom_search_info_t *search_info, + axiom_mime_parser_t *mime_parser) +{ + axis2_char_t *data_buffer = NULL; + axis2_char_t *temp_buf = NULL; + size_t mime_binary_len = 0; + + temp_buf = (axis2_char_t *)search_info->handler; + mime_binary_len = search_info->binary_size + buf_len; + + if(mime_binary_len > 0) + { + data_buffer = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (mime_binary_len)); + + if(data_buffer) + { + if(temp_buf && search_info->binary_size > 0) + { + memcpy(data_buffer, temp_buf, search_info->binary_size); + AXIS2_FREE(env->allocator, temp_buf); + temp_buf = NULL; + } + memcpy(data_buffer + (search_info->binary_size), buf, buf_len); + search_info->binary_size = mime_binary_len; + search_info->handler = (void *)data_buffer; + + return AXIS2_SUCCESS; + } + else + { + return AXIS2_FAILURE; + } + } + else + { + return AXIS2_FAILURE; + } +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_mime_parser_set_buffer_size( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + int size) +{ + mime_parser->buffer_size = size; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_mime_parser_set_max_buffers( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + int num) +{ + mime_parser->max_buffers = num; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_mime_parser_set_attachment_dir( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_char_t *attachment_dir) +{ + mime_parser->attachment_dir = attachment_dir; +} + +/* Set the path of the caching callnack to be loaded */ + +AXIS2_EXTERN void AXIS2_CALL +axiom_mime_parser_set_caching_callback_name( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_char_t *callback_name) +{ + mime_parser->callback_name = callback_name; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_mime_parser_set_mime_boundary( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_char_t *mime_boundary) +{ + mime_parser->mime_boundary = mime_boundary; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_mime_parser_get_mime_boundary( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env) +{ + return mime_parser->mime_boundary; +} + +/* Load the caching callback dll */ + +static void* +axiom_mime_parser_initiate_callback( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_char_t *mime_id, + void *user_param) +{ + axutil_dll_desc_t *dll_desc = NULL; + axutil_param_t *impl_info_param = NULL; + void *ptr = NULL; + + if(mime_parser->callback_name) + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Trying to load module = %s", + mime_parser->callback_name); + dll_desc = axutil_dll_desc_create(env); + axutil_dll_desc_set_name(dll_desc, env, mime_parser->callback_name); + impl_info_param = axutil_param_create(env, NULL, dll_desc); + /*Set the free function*/ + axutil_param_set_value_free(impl_info_param, env, axutil_dll_desc_free_void_arg); + axutil_class_loader_init(env); + ptr = axutil_class_loader_create_dll(env, impl_info_param); + + if(!ptr) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to load the module %s. ERROR", + mime_parser->callback_name); + return NULL; + } + + mime_parser->mtom_caching_callback = (axiom_mtom_caching_callback_t *)ptr; + mime_parser->mtom_caching_callback->param = impl_info_param; + mime_parser->mtom_caching_callback->user_param = user_param; + + return AXIOM_MTOM_CACHING_CALLBACK_INIT_HANDLER(mime_parser->mtom_caching_callback, env, + mime_id); + } + + else + { + return NULL; + } + +} + +/* This method will tell whether there are more data in the + * stream */ + +static axis2_bool_t +axiom_mime_parser_is_more_data( + axiom_mime_parser_t *mime_parser, + const axutil_env_t *env, + axis2_callback_info_t *callback_info) +{ + /* In the case of axutil_http_chunked stream it is the + * end of chunk */ + + if(callback_info->chunked_stream) + { + if(axutil_http_chunked_stream_get_end_of_chunks(callback_info->chunked_stream, env)) + { + return AXIS2_FALSE; + } + else + { + return AXIS2_TRUE; + } + } + + /* When we are using content length or any wrapped + * stream it will be the unread_length */ + + else if(callback_info->unread_len == 0) + { + return AXIS2_FALSE; + } + else + { + return AXIS2_TRUE; + } +} + +static axis2_status_t +axiom_mime_parser_cache_to_file( + const axutil_env_t* env, + axis2_char_t *buf, + size_t buf_len, + void *handler) +{ + size_t len = 0; + FILE *fp = NULL; + + fp = (FILE *)handler; + + len = fwrite(buf, 1, buf_len, fp); + if(len < 0) + { + return AXIS2_FAILURE; + } + else + { + return AXIS2_SUCCESS; + } +} + diff --git a/axiom/src/attachments/mime_part.c b/axiom/src/attachments/mime_part.c new file mode 100644 index 0000000..8343327 --- /dev/null +++ b/axiom/src/attachments/mime_part.c @@ -0,0 +1,535 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "axiom_mime_body_part.h" +#include +#include +#include + + +static axis2_status_t +axiom_mime_part_write_body_part_to_list( + const axutil_env_t *env, + axutil_array_list_t *list, + axiom_mime_body_part_t *part, + axis2_char_t *boundary); + +static axis2_status_t +axiom_mime_part_write_mime_boundary( + const axutil_env_t *env, + axutil_array_list_t *list, + axis2_char_t *boundary); + +static axis2_status_t +axiom_mime_part_finish_adding_parts( + const axutil_env_t *env, + axutil_array_list_t *list, + axis2_char_t *boundary); + +/* This method will create a mime_part + * A mime part will encapsulate a buffer + * a file or a callback to load the attachment + which needs to be send */ + +AXIS2_EXTERN axiom_mime_part_t *AXIS2_CALL +axiom_mime_part_create( + const axutil_env_t *env) +{ + axiom_mime_part_t *mime_part = NULL; + mime_part = AXIS2_MALLOC(env->allocator, sizeof(axiom_mime_part_t)); + + if(mime_part) + { + mime_part->part = NULL; + mime_part->file_name = NULL; + mime_part->part_size = 0; + mime_part->type = AXIOM_MIME_PART_UNKNOWN; + mime_part->user_param = NULL; + + return mime_part; + } + else + { + return NULL; + } +} + +/* Frees the mime_part */ + +AXIS2_EXTERN void AXIS2_CALL +axiom_mime_part_free( + axiom_mime_part_t *mime_part, + const axutil_env_t *env) +{ + if(mime_part) + { + if(mime_part->type == AXIOM_MIME_PART_BUFFER) + { + if(mime_part->part) + { + AXIS2_FREE(env->allocator, mime_part->part); + mime_part->part = NULL; + } + } + else if(mime_part->type == AXIOM_MIME_PART_FILE) + { + if(mime_part->file_name) + { + AXIS2_FREE(env->allocator, mime_part->file_name); + mime_part->file_name = NULL; + } + } + + AXIS2_FREE(env->allocator, mime_part); + mime_part = NULL; + } + return; +} + +/* This method will create a mime_boundary buffer + * and based on the buffer creates a mime_part. + * This will be added to the array_list so later in the trasnport + * this can be put to the wire. */ + +static axis2_status_t +axiom_mime_part_write_mime_boundary( + const axutil_env_t *env, + axutil_array_list_t *list, + axis2_char_t *boundary) +{ + axis2_byte_t *byte_buffer = NULL; + axis2_byte_t *byte_stream = NULL; + int size = 0; + axiom_mime_part_t *boundary_part = NULL; + + boundary_part = axiom_mime_part_create(env); + + byte_buffer = (axis2_byte_t *)boundary; + size = axutil_strlen(boundary); + + byte_stream = AXIS2_MALLOC(env->allocator, (size + 2) * sizeof(axis2_byte_t)); + if(!byte_stream) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create byte stream"); + return AXIS2_FAILURE; + } + + /* Mime boundary is always in the following form + --MimeBoundary */ + + byte_stream[0] = AXIOM_MIME_BOUNDARY_BYTE; + byte_stream[1] = AXIOM_MIME_BOUNDARY_BYTE; + + memcpy(byte_stream + 2, byte_buffer, size); + + boundary_part->part = byte_stream; + boundary_part->part_size = size + 2; + boundary_part->type = AXIOM_MIME_PART_BUFFER; + + axutil_array_list_add(list, env, boundary_part); + + return AXIS2_SUCCESS; +} + +/* This method will add the attachment file related information + to the list. It will create a mime_part from those information + and add to the list. If there are not data_handlers in the mime_body + then this method just add the headers. */ + +static axis2_status_t +axiom_mime_part_write_body_part_to_list( + const axutil_env_t *env, + axutil_array_list_t *list, + axiom_mime_body_part_t *part, + axis2_char_t *boundary) +{ + axiom_mime_part_t *crlf1 = NULL; + axiom_mime_part_t *crlf2 = NULL; + axis2_status_t status = AXIS2_SUCCESS; + + /* We are adding accoarding to the following format here. + * --MimeBoundary + * mime_header1 + * mime_header2 + * mime_header3 */ + + status = axiom_mime_part_write_mime_boundary(env, list, boundary); + + if(status != AXIS2_SUCCESS) + { + return status; + } + + /* Then we will add the new line charator after + * the mime_boundary */ + + crlf1 = axiom_mime_part_create(env); + + crlf1->part = (axis2_byte_t *)axutil_strdup(env, AXIS2_CRLF); + crlf1->part_size = 2; + crlf1->type = AXIOM_MIME_PART_BUFFER; + + axutil_array_list_add(list, env, crlf1); + + /*This method will fill the list with mime_headers and + *if there is an attachment with attachment details*/ + + axiom_mime_body_part_write_to_list(part, env, list); + + /* Then add the next \r\n after the attachment */ + + crlf2 = axiom_mime_part_create(env); + + crlf2->part = (axis2_byte_t *)axutil_strdup(env, AXIS2_CRLF); + crlf2->part_size = 2; + crlf2->type = AXIOM_MIME_PART_BUFFER; + + axutil_array_list_add(list, env, crlf2); + + return AXIS2_SUCCESS; +} + +/* This methos will add the final mime_boundary + * It is in --MimeBoundary-- format */ + +static axis2_status_t +axiom_mime_part_finish_adding_parts( + const axutil_env_t *env, + axutil_array_list_t *list, + axis2_char_t *boundary) +{ + axis2_byte_t *byte_buffer = NULL; + axis2_byte_t *byte_stream = NULL; + int size = 0; + axiom_mime_part_t *final_part = NULL; + + size = axutil_strlen(boundary); + byte_buffer = (axis2_byte_t *)boundary; + + /* There is -- before and after so the length of the + * actual part is mime_boundary_len + 4 */ + + byte_stream = AXIS2_MALLOC(env->allocator, (size + 4) * sizeof(axis2_byte_t)); + if(!byte_stream) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create byte stream"); + return AXIS2_FAILURE; + } + + /* Adding the starting -- */ + + byte_stream[0] = AXIOM_MIME_BOUNDARY_BYTE; + byte_stream[1] = AXIOM_MIME_BOUNDARY_BYTE; + if(byte_buffer) + { + memcpy(byte_stream + 2, byte_buffer, size); + } + else + { + AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "Byte buffer not available for writing"); + } + + /* Adding the final -- */ + + byte_stream[size + 2] = AXIOM_MIME_BOUNDARY_BYTE; + byte_stream[size + 3] = AXIOM_MIME_BOUNDARY_BYTE; + + /* Now we add this as an mime_part to + * the list. */ + + final_part = axiom_mime_part_create(env); + + if(!final_part) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create final_part"); + return AXIS2_FAILURE; + } + + final_part->part = byte_stream; + final_part->part_size = size + 4; + final_part->type = AXIOM_MIME_PART_BUFFER; + + axutil_array_list_add(list, env, final_part); + + return AXIS2_SUCCESS; +} + +/* This is the method which creates the content-type string + which is in the HTTP header or in mime_headers*/ + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axiom_mime_part_get_content_type_for_mime( + const axutil_env_t *env, + axis2_char_t *boundary, + axis2_char_t *content_id, + axis2_char_t *char_set_encoding, + const axis2_char_t *soap_content_type) +{ + axis2_char_t *content_type_string = NULL; + axis2_char_t *temp_content_type_string = NULL; + + content_type_string = axutil_strdup(env, AXIOM_MIME_TYPE_MULTIPART_RELATED); + if(!content_type_string) + { + AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "Creation of Content-Type string failed"); + return NULL; + } + temp_content_type_string = axutil_stracat(env, content_type_string, "; "); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + if(boundary) + { + temp_content_type_string = + axutil_stracat(env, content_type_string, + AXIOM_MIME_HEADER_FIELD_BOUNDARY "="); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + temp_content_type_string = axutil_stracat(env, content_type_string, boundary); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + temp_content_type_string = axutil_stracat(env, content_type_string, "; "); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + } temp_content_type_string = + axutil_stracat(env, content_type_string, + AXIOM_MIME_HEADER_FIELD_TYPE "=\"" AXIOM_MIME_TYPE_XOP_XML "\""); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + temp_content_type_string = axutil_stracat(env, content_type_string, "; "); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + if(content_id) + { + temp_content_type_string = + axutil_stracat(env, content_type_string, + AXIOM_MIME_HEADER_FIELD_START "=\"<"); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + temp_content_type_string = axutil_stracat(env, content_type_string, content_id); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + temp_content_type_string = axutil_stracat(env, content_type_string, ">\""); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + temp_content_type_string = axutil_stracat(env, content_type_string, "; "); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + } + if(soap_content_type) + { + temp_content_type_string = + axutil_stracat(env, content_type_string, + AXIOM_MIME_HEADER_FIELD_START_INFO "=\""); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + temp_content_type_string = axutil_stracat(env, content_type_string, soap_content_type); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + temp_content_type_string = axutil_stracat(env, content_type_string, "\"; "); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + } + if(char_set_encoding) + { + temp_content_type_string = + axutil_stracat(env, content_type_string, + AXIOM_MIME_HEADER_FIELD_CHARSET "=\""); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + temp_content_type_string = axutil_stracat(env, content_type_string, char_set_encoding); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + temp_content_type_string = axutil_stracat(env, content_type_string, "\""); + AXIS2_FREE(env->allocator, content_type_string); + content_type_string = temp_content_type_string; + } + + return content_type_string; +} + +/* This method is the core of attachment sending + * part. It will build each and every part and put them in + * an array_list. Instead of a big buffer we pass the array_list + * with small buffers and attachment locations. */ + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axiom_mime_part_create_part_list( + const axutil_env_t *env, + axis2_char_t *soap_body, + axutil_array_list_t *binary_node_list, + axis2_char_t *boundary, + axis2_char_t *content_id, + axis2_char_t *char_set_encoding, + const axis2_char_t *soap_content_type) +{ + axis2_status_t status = AXIS2_FAILURE; + axis2_char_t *header_value = NULL; + axis2_char_t *temp_header_value = NULL; + axis2_char_t *content_id_string = NULL; + axis2_char_t *temp_content_id_string = NULL; + axiom_mime_body_part_t *root_mime_body_part = NULL; + axis2_char_t *soap_body_buffer = NULL; + axutil_array_list_t *part_list = NULL; + axiom_mime_part_t *soap_part = NULL; + + part_list = axutil_array_list_create(env, 0); + + if(!part_list) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create part list array"); + return NULL; + } + + /* This mime_body part just keeps the mime_headers of the + * SOAP part. Since it is not created from an axiom_text + * this will not contain an attachment*/ + + root_mime_body_part = axiom_mime_body_part_create(env); + + if(!root_mime_body_part) + { + return NULL; + } + + /* In order to understand the following code which creates + * mime_headers go through the code with a sample mtom message */ + + /* Adding Content-Type Header */ + header_value = axutil_strdup(env, AXIOM_MIME_TYPE_XOP_XML + ";" AXIOM_MIME_HEADER_FIELD_CHARSET "="); + temp_header_value = axutil_stracat(env, header_value, char_set_encoding); + AXIS2_FREE(env->allocator, header_value); + header_value = temp_header_value; + temp_header_value = axutil_stracat(env, header_value, ";" + AXIOM_MIME_HEADER_FIELD_TYPE "=\""); + AXIS2_FREE(env->allocator, header_value); + header_value = temp_header_value; + temp_header_value = axutil_stracat(env, header_value, soap_content_type); + AXIS2_FREE(env->allocator, header_value); + header_value = temp_header_value; + temp_header_value = axutil_stracat(env, header_value, "\";"); + AXIS2_FREE(env->allocator, header_value); + header_value = temp_header_value; + AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env, AXIOM_MIME_HEADER_CONTENT_TYPE, + header_value); + + /* Adding Content Transfer Encoding header */ + + AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env, + AXIOM_MIME_HEADER_CONTENT_TRANSFER_ENCODING, axutil_strdup(env, + AXIOM_MIME_CONTENT_TRANSFER_ENCODING_BINARY)); + + /* Adding Content ID header */ + + content_id_string = (axis2_char_t *)"<"; + content_id_string = axutil_stracat(env, content_id_string, content_id); + temp_content_id_string = axutil_stracat(env, content_id_string, ">"); + AXIS2_FREE(env->allocator, content_id_string); + content_id_string = temp_content_id_string; + AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env, AXIOM_MIME_HEADER_CONTENT_ID, + content_id_string); + + /* Now first insert the headers needed for SOAP */ + + /* After calling this method we have mime_headers of the SOAP envelope + * as a mime_part in the array_list */ + + status = axiom_mime_part_write_body_part_to_list(env, part_list, root_mime_body_part, boundary); + + if(status == AXIS2_FAILURE) + { + return NULL; + } + + /* Now add the SOAP body */ + + AXIOM_MIME_BODY_PART_FREE(root_mime_body_part, env); + root_mime_body_part = NULL; + + soap_part = axiom_mime_part_create(env); + + if(!soap_part) + { + return NULL; + } + + /* The atachment's mime_boundary will start after a new line charator */ + + soap_body_buffer = axutil_stracat(env, soap_body, AXIS2_CRLF); + + soap_part->part = (axis2_byte_t *)soap_body_buffer; + soap_part->part_size = (int)axutil_strlen(soap_body_buffer); + soap_part->type = AXIOM_MIME_PART_BUFFER; + + axutil_array_list_add(part_list, env, soap_part); + + /* Now we need to add each binary attachment to the array_list */ + + if(binary_node_list) + { + int j = 0; + for(j = 0; j < axutil_array_list_size(binary_node_list, env); j++) + { + /* Getting each attachment text node from the node list */ + + axiom_text_t *text = (axiom_text_t *)axutil_array_list_get(binary_node_list, env, j); + if(text) + { + axiom_mime_body_part_t *mime_body_part = NULL; + mime_body_part = axiom_mime_body_part_create_from_om_text(env, text); + + /* Let's fill the mime_part arraylist with attachment data*/ + if(!mime_body_part) + { + return NULL; + } + + /* This call will create mime_headers for the attachment and put + * them to the array_list. Then put the attachment file_name to the + * list */ + + status = axiom_mime_part_write_body_part_to_list(env, part_list, mime_body_part, + boundary); + + if(status == AXIS2_FAILURE) + { + return NULL; + } + + AXIOM_MIME_BODY_PART_FREE(mime_body_part, env); + mime_body_part = NULL; + } + } + } + + /* Now we have the SOAP message, all the attachments and headers are added to the list. + * So let's add the final mime_boundary with -- at the end */ + + status = axiom_mime_part_finish_adding_parts(env, part_list, boundary); + if(status == AXIS2_FAILURE) + { + return NULL; + } + return part_list; +} + diff --git a/axiom/src/om/Makefile.am b/axiom/src/om/Makefile.am new file mode 100644 index 0000000..40db6c5 --- /dev/null +++ b/axiom/src/om/Makefile.am @@ -0,0 +1,35 @@ +lib_LTLIBRARIES = libaxis2_axiom.la +libaxis2_axiom_la_SOURCES = om_attribute.c \ + om_document.c \ + om_node.c \ + om_text.c \ + om_data_source.c \ + om_comment.c \ + om_element.c \ + om_output.c \ + om_doctype.c \ + om_namespace.c \ + om_processing_instruction.c \ + om_stax_builder.c \ + om_children_iterator.c \ + om_children_qname_iterator.c \ + om_child_element_iterator.c \ + om_children_with_specific_attribute_iterator.c \ + om_navigator.c + +libaxis2_axiom_la_LIBADD = $(top_builddir)/src/soap/libaxis2_soap.la \ + $(top_builddir)/src/attachments/libaxis2_attachments.la \ + $(top_builddir)/src/util/libaxis2_axiom_util.la \ + ../parser/${WRAPPER_DIR}/libaxis2_parser.la \ + ../../../util/src/libaxutil.la + +libaxis2_axiom_la_LDFLAGS = -version-info $(VERSION_NO) + +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/src/parser \ + -I$(top_builddir)/src/om \ + -I$(top_builddir)/src/attachments \ + -I ../../../util/include + +EXTRA_DIST = axiom_namespace_internal.h axiom_node_internal.h axiom_stax_builder_internal.h + diff --git a/axiom/src/om/axiom_namespace_internal.h b/axiom/src/om/axiom_namespace_internal.h new file mode 100644 index 0000000..833de7f --- /dev/null +++ b/axiom/src/om/axiom_namespace_internal.h @@ -0,0 +1,46 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_NAMESPACE_INTERNAL_H +#define AXIOM_NAMESPACE_INTERNAL_H + +/** @defgroup axiom AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_namespace_set_uri( + axiom_namespace_t * ns, + const axutil_env_t * env, + const axis2_char_t * ns_uri); + +#ifdef __cplusplus +} +#endif + +#endif /** AXIOM_NAMESPACE_H */ diff --git a/axiom/src/om/axiom_node_internal.h b/axiom/src/om/axiom_node_internal.h new file mode 100644 index 0000000..6e9adb4 --- /dev/null +++ b/axiom/src/om/axiom_node_internal.h @@ -0,0 +1,165 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_NODE_INTERNAL_H +#define AXIOM_NODE_INTERNAL_H + +/** @defgroup axiom AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_node OM Node + * @ingroup axiom + * @{ + */ + struct axiom_document; + struct axiom_stax_builder; + + /** + * Sets a parent node to a given node, if a parent already exist for this node + * then it is detached before seting the parent internal function; + * @param om_node child node to whom a parent to be added. , cannot be NULL. + * @param env Environment. MUST NOT be NULL, . + * @param parent_node the node that will be set as parent. , cannot be NULL. + * @return satus of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_set_parent( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * parent); + + /** + * Sets a node as first child of om_node + * @param om_node om_node + * @param env environment, MUST NOT be NULL. + * @param first_child child to be set as first child + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_set_first_child( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * first_child); + + /** + * Sets previous sibling + * @param om_node + * @param env environment, MUST NOT be NULL. + * @param prev_sibling + * @return status of the op, AXIS2_SUCCESS on success + * AXIS2_FAILURE on error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_set_previous_sibling( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * prev_sibling); + + /** + * Sets next sibling + * @param om_node + * @param env environment, MUST NOT be NULL. + * @param last_sibling + * @return status of the op, AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_set_next_sibling( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * next_sibling); + + /** + * Sets node type + * @param om_node + * @param env environment, MUST NOT be NULL. + * @param type type of the node + * @return status code of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_set_node_type( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_types_t type); + + /** + * Sets data element + * @param om_node node struct + * @param env environment, MUST NOT be NULL. + * @param data_element + * @return status code of the op AXIS2_SUCCESS on success, + * AXIS2_FAILURE on error + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_set_data_element( + axiom_node_t * om_node, + const axutil_env_t * env, + void *data_element); + + /** + * Sets the build status , if the node if completety build, this attribute is + * set to AXIS2_TRUE , otherwise AXIS2_FALSE + * @param om_node + * @param env environment, MUST NOT be NULL. + * @param done + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_set_complete( + axiom_node_t * om_node, + const axutil_env_t * env, + axis2_bool_t done); + + /** + * This functions is only to be used by builder + * do not use this function + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_set_document( + axiom_node_t * om_node, + const axutil_env_t * env, + struct axiom_document *om_doc); + + /** + * Sets the builder + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_node_set_builder( + axiom_node_t * om_node, + const axutil_env_t * env, + struct axiom_stax_builder *builder); + + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** AXIOM_NODE_INTERNAL_H */ diff --git a/axiom/src/om/axiom_stax_builder_internal.h b/axiom/src/om/axiom_stax_builder_internal.h new file mode 100644 index 0000000..788ecf6 --- /dev/null +++ b/axiom/src/om/axiom_stax_builder_internal.h @@ -0,0 +1,75 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_STAX_BUILDER_INTERNAL_H +#define AXIOM_STAX_BUILDER_INTERNAL_H + +/** @defgroup axiom AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_stax builder + * @ingroup axiom + * @{ + */ + + AXIS2_EXTERN int AXIS2_CALL + axiom_stax_builder_get_current_event( + axiom_stax_builder_t * builder, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_stax_builder_set_lastnode( + axiom_stax_builder_t * builder, + const axutil_env_t * env, + axiom_node_t * om_node); + + AXIS2_EXTERN axiom_node_t *AXIS2_CALL + axiom_stax_builder_get_lastnode( + axiom_stax_builder_t * builder, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_stax_builder_set_element_level( + axiom_stax_builder_t * builder, + const axutil_env_t * env, + int element_level); + + AXIS2_EXTERN int AXIS2_CALL + axiom_stax_builder_get_element_level( + axiom_stax_builder_t * builder, + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** AXIOM_STAX_BUILDER_INTERNAL_H */ diff --git a/axiom/src/om/om_attribute.c b/axiom/src/om/om_attribute.c new file mode 100644 index 0000000..9d2a81e --- /dev/null +++ b/axiom/src/om/om_attribute.c @@ -0,0 +1,433 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +struct axiom_attribute +{ + + /** localname of this attribute */ + axutil_string_t *localname; + + /** value of this attribute */ + axutil_string_t *value; + + /** attribute namespace */ + axiom_namespace_t *ns; + + /** store qname here */ + axutil_qname_t *qname; + int ref; +}; + +AXIS2_EXTERN axiom_attribute_t *AXIS2_CALL +axiom_attribute_create( + const axutil_env_t * env, + const axis2_char_t * localname, + const axis2_char_t * value, + axiom_namespace_t * ns) +{ + axiom_attribute_t *attribute = NULL; + + AXIS2_ENV_CHECK(env, NULL); + /* localname is mandatory */ + AXIS2_PARAM_CHECK(env->error, localname, NULL); + + attribute = (axiom_attribute_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_attribute_t)); + if(!attribute) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + /** initialize fields */ + attribute->localname = NULL; + attribute->value = NULL; + attribute->ns = NULL; + attribute->qname = NULL; + + attribute->localname = axutil_string_create(env, localname); + if(!(attribute->localname)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_FREE(env->allocator, attribute); + return NULL; + } + if(value) + { + attribute->value = axutil_string_create(env, value); + if(!(attribute->value)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + axutil_string_free(attribute->localname, env); + AXIS2_FREE(env->allocator, attribute); + return NULL; + } + } + attribute->ns = ns; + + attribute->ref = 0; + + return attribute; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_attribute_free( + axiom_attribute_t * attribute, + const axutil_env_t * env) +{ + if(--attribute->ref > 0) + { + return; + } + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(attribute->localname) + { + axutil_string_free(attribute->localname, env); + } + if(attribute->value) + { + axutil_string_free(attribute->value, env); + } + if(attribute->qname) + { + axutil_qname_free(attribute->qname, env); + } + + AXIS2_FREE(env->allocator, attribute); + + return; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_attribute_free_void_arg( + void *attribute, + const axutil_env_t * env) +{ + axiom_attribute_t *om_attribute_l = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + om_attribute_l = (axiom_attribute_t *)attribute; + axiom_attribute_free(om_attribute_l, env); + return; +} + +AXIS2_EXTERN axutil_qname_t *AXIS2_CALL +axiom_attribute_get_qname( + axiom_attribute_t * attribute, + const axutil_env_t * env) +{ + axutil_qname_t *qname = NULL; + AXIS2_ENV_CHECK(env, NULL); + if(!(attribute->qname)) + { + if(attribute->ns) + { + qname = axutil_qname_create(env, axutil_string_get_buffer(attribute-> localname, env), + axiom_namespace_get_uri(attribute->ns, env), axiom_namespace_get_prefix( + attribute-> ns, env)); + } + else + { + qname = axutil_qname_create(env, axutil_string_get_buffer(attribute-> localname, env), + NULL, NULL); + } + attribute->qname = qname; + return qname; + } + return attribute->qname; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_attribute_serialize( + axiom_attribute_t * attribute, + const axutil_env_t * env, + axiom_output_t * om_output) +{ + int status = AXIS2_SUCCESS; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); + + if(attribute->ns) + { + axis2_char_t *uri = NULL; + axis2_char_t *prefix = NULL; + + uri = axiom_namespace_get_uri(attribute->ns, env); + prefix = axiom_namespace_get_prefix(attribute->ns, env); + + if((uri) && (NULL != prefix) && (axutil_strcmp(prefix, "") != 0)) + { + status = axiom_output_write(om_output, env, AXIOM_ATTRIBUTE, 4, + axutil_string_get_buffer(attribute-> localname, env), axutil_string_get_buffer( + attribute-> value, env), uri, prefix); + } + else if(uri) + { + status = axiom_output_write(om_output, env, AXIOM_ATTRIBUTE, 3, + axutil_string_get_buffer(attribute-> localname, env), axutil_string_get_buffer( + attribute-> value, env), uri); + } + } + else + { + status = axiom_output_write(om_output, env, AXIOM_ATTRIBUTE, 2, axutil_string_get_buffer( + attribute-> localname, env), axutil_string_get_buffer(attribute->value, env)); + } + return status; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_attribute_get_localname( + axiom_attribute_t * attribute, + const axutil_env_t * env) +{ + if(attribute->localname) + { + return (axis2_char_t *)axutil_string_get_buffer(attribute->localname, env); + } + return NULL; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_attribute_get_value( + axiom_attribute_t * attribute, + const axutil_env_t * env) +{ + if(attribute->value) + { + return (axis2_char_t *)axutil_string_get_buffer(attribute->value, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL +axiom_attribute_get_namespace( + axiom_attribute_t * attribute, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + return attribute->ns; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_attribute_set_localname( + axiom_attribute_t * attribute, + const axutil_env_t * env, + const axis2_char_t * localname) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + + if(attribute->localname) + { + axutil_string_free(attribute->localname, env); + attribute->localname = NULL; + } + + attribute->localname = axutil_string_create(env, localname); + + if(!(attribute->localname)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_attribute_set_value( + axiom_attribute_t * attribute, + const axutil_env_t * env, + const axis2_char_t * value) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + + if(attribute->value) + { + axutil_string_free(attribute->value, env); + attribute->value = NULL; + } + + attribute->value = axutil_string_create(env, value); + if(!(attribute->value)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_attribute_set_namespace( + axiom_attribute_t * attribute, + const axutil_env_t * env, + axiom_namespace_t * om_namespace) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_FUNC_PARAM_CHECK(om_namespace, env, AXIS2_FAILURE); + attribute->ns = om_namespace; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_attribute_t *AXIS2_CALL +axiom_attribute_clone( + axiom_attribute_t * attribute, + const axutil_env_t * env) +{ + axiom_attribute_t *cloned_attr = NULL; + if(!attribute) + return NULL; + AXIS2_ENV_CHECK(env, NULL); + + /** namespace is not cloned since it is a shollow copy*/ + cloned_attr = axiom_attribute_create_str(env, attribute->localname, attribute->value, + attribute->ns); + if(cloned_attr) + { + return cloned_attr; + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_attribute_increment_ref( + struct axiom_attribute * om_attribute, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + om_attribute->ref++; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_attribute_t *AXIS2_CALL +axiom_attribute_create_str( + const axutil_env_t * env, + axutil_string_t * localname, + axutil_string_t * value, + axiom_namespace_t * ns) +{ + axiom_attribute_t *attribute = NULL; + + AXIS2_ENV_CHECK(env, NULL); + /* localname is mandatory */ + AXIS2_PARAM_CHECK(env->error, localname, NULL); + + attribute = (axiom_attribute_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_attribute_t)); + if(!attribute) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + /** initialize fields */ + attribute->localname = NULL; + attribute->value = NULL; + attribute->ns = NULL; + attribute->qname = NULL; + + attribute->localname = axutil_string_clone(localname, env); + if(!(attribute->localname)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_FREE(env->allocator, attribute); + return NULL; + } + if(value) + { + attribute->value = axutil_string_clone(value, env); + if(!(attribute->value)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + axutil_string_free(attribute->localname, env); + AXIS2_FREE(env->allocator, attribute); + return NULL; + } + } + attribute->ns = ns; + + attribute->ref = 0; + + return attribute; +} + +AXIS2_EXTERN axutil_string_t *AXIS2_CALL +axiom_attribute_get_localname_str( + axiom_attribute_t * attribute, + const axutil_env_t * env) +{ + return attribute->localname; +} + +AXIS2_EXTERN axutil_string_t *AXIS2_CALL +axiom_attribute_get_value_str( + axiom_attribute_t * attribute, + const axutil_env_t * env) +{ + return attribute->value; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_attribute_set_localname_str( + axiom_attribute_t * attribute, + const axutil_env_t * env, + axutil_string_t * localname) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + + if(attribute->localname) + { + axutil_string_free(attribute->localname, env); + attribute->localname = NULL; + } + + attribute->localname = axutil_string_clone(localname, env); + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_attribute_set_value_str( + axiom_attribute_t * attribute, + const axutil_env_t * env, + axutil_string_t * value) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + + if(attribute->value) + { + axutil_string_free(attribute->value, env); + attribute->value = NULL; + } + + attribute->value = axutil_string_clone(value, env); + if(!(attribute->value)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} diff --git a/axiom/src/om/om_child_element_iterator.c b/axiom/src/om/om_child_element_iterator.c new file mode 100644 index 0000000..622cfbd --- /dev/null +++ b/axiom/src/om/om_child_element_iterator.c @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +struct axiom_child_element_iterator +{ + axiom_node_t *current_child; + axiom_node_t *last_child; + axis2_bool_t next_called; + axis2_bool_t remove_called; +}; + +AXIS2_EXTERN axiom_child_element_iterator_t *AXIS2_CALL +axiom_child_element_iterator_create( + const axutil_env_t * env, + axiom_node_t * current_child) +{ + axiom_child_element_iterator_t *iterator = NULL; + AXIS2_ENV_CHECK(env, NULL); + + iterator = (axiom_child_element_iterator_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_child_element_iterator_t)); + + if(!iterator) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + iterator->current_child = current_child; + iterator->last_child = NULL; + + iterator->next_called = AXIS2_FALSE; + iterator->remove_called = AXIS2_FALSE; + + return iterator; +} + +AXIS2_EXTERN void AXIS2_CALL axiom_child_element_iterator_free( + void *iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_FREE(env->allocator, iterator); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_child_element_iterator_remove( + axiom_child_element_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, iterator, AXIS2_FAILURE); + + if(!(iterator->next_called)) + return AXIS2_FAILURE; + if(iterator->remove_called) + return AXIS2_FAILURE; + + iterator->remove_called = AXIS2_TRUE; + + if(!(iterator->last_child)) + return AXIS2_FAILURE; + axiom_node_free_tree(iterator->last_child, env); + iterator->last_child = NULL; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_child_element_iterator_has_next( + axiom_child_element_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return (iterator->current_child) ? AXIS2_TRUE : AXIS2_FALSE; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL axiom_child_element_iterator_next( + axiom_child_element_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + iterator->next_called = AXIS2_TRUE; + iterator->remove_called = AXIS2_FALSE; + if (iterator->current_child) + { + iterator->last_child = iterator->current_child; + do + { + iterator->current_child = + axiom_node_get_next_sibling(iterator->current_child, env); + + } + while (iterator->current_child && + (axiom_node_get_node_type(iterator->current_child, env) + != AXIOM_ELEMENT)); + + return iterator->last_child; + } + return NULL; +} diff --git a/axiom/src/om/om_children_iterator.c b/axiom/src/om/om_children_iterator.c new file mode 100644 index 0000000..42046e5 --- /dev/null +++ b/axiom/src/om/om_children_iterator.c @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +struct axiom_children_iterator +{ + axiom_node_t *first_child; + axiom_node_t *current_child; + axiom_node_t *last_child; + axis2_bool_t next_called; + axis2_bool_t remove_called; +}; + +AXIS2_EXTERN axiom_children_iterator_t *AXIS2_CALL +axiom_children_iterator_create( + const axutil_env_t * env, + axiom_node_t * current_child) +{ + axiom_children_iterator_t *iterator = NULL; + AXIS2_ENV_CHECK(env, NULL); + + iterator = (axiom_children_iterator_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_children_iterator_t)); + + if(!iterator) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + iterator->current_child = NULL; + iterator->last_child = NULL; + iterator->first_child = NULL; + + iterator->next_called = AXIS2_FALSE; + iterator->remove_called = AXIS2_FALSE; + + iterator->first_child = current_child; + iterator->current_child = current_child; + + return iterator; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_children_iterator_free( + axiom_children_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + + AXIS2_FREE(env->allocator, iterator); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_children_iterator_remove( + axiom_children_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, iterator, AXIS2_FAILURE); + + if(!(iterator->next_called)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_ITERATOR_NEXT_METHOD_HAS_NOT_YET_BEEN_CALLED, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + if(iterator->remove_called) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_ITERATOR_REMOVE_HAS_ALREADY_BEING_CALLED, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + iterator->remove_called = AXIS2_TRUE; + + if(!(iterator->last_child)) + { + return AXIS2_FAILURE; + } + axiom_node_free_tree(iterator->last_child, env); + iterator->last_child = NULL; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_children_iterator_has_next( + axiom_children_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return (iterator->current_child) ? AXIS2_TRUE : AXIS2_FALSE; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_children_iterator_next( + axiom_children_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + iterator->next_called = AXIS2_TRUE; + iterator->remove_called = AXIS2_FALSE; + if(iterator->current_child) + { + iterator->last_child = iterator->current_child; + iterator->current_child = axiom_node_get_next_sibling(iterator->current_child, env); + return iterator->last_child; + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_children_iterator_reset( + axiom_children_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + iterator->current_child = iterator->first_child; + return AXIS2_SUCCESS; +} diff --git a/axiom/src/om/om_children_qname_iterator.c b/axiom/src/om/om_children_qname_iterator.c new file mode 100644 index 0000000..d508a9e --- /dev/null +++ b/axiom/src/om/om_children_qname_iterator.c @@ -0,0 +1,190 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +struct axiom_children_qname_iterator +{ + axiom_node_t *current_child; + axiom_node_t *last_child; + axis2_bool_t next_called; + axis2_bool_t remove_called; + axutil_qname_t *given_qname; + axis2_bool_t need_to_move_forward; + axis2_bool_t matching_node_found; + +}; + +AXIS2_EXTERN axiom_children_qname_iterator_t *AXIS2_CALL +axiom_children_qname_iterator_create( + const axutil_env_t * env, + axiom_node_t * current_child, + axutil_qname_t * given_qname) +{ + axiom_children_qname_iterator_t *iterator = NULL; + + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, current_child, NULL); + + iterator = (axiom_children_qname_iterator_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_children_qname_iterator_t)); + + if(!iterator) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + iterator->current_child = NULL; + iterator->last_child = NULL; + iterator->need_to_move_forward = AXIS2_TRUE; + iterator->matching_node_found = AXIS2_FALSE; + iterator->next_called = AXIS2_FALSE; + iterator->remove_called = AXIS2_FALSE; + iterator->given_qname = NULL; + + iterator->current_child = current_child; + if(given_qname) + { + iterator->given_qname = axutil_qname_clone(given_qname, env); + if(!(iterator->given_qname)) + { + axiom_children_qname_iterator_free(iterator, env); + return NULL; + } + } + + return iterator; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_children_qname_iterator_free( + axiom_children_qname_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + + if(iterator->given_qname) + { + axutil_qname_free(iterator->given_qname, env); + } + AXIS2_FREE(env->allocator, iterator); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_children_qname_iterator_remove( + axiom_children_qname_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, iterator, AXIS2_FAILURE); + + if(!(iterator->next_called)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_ITERATOR_NEXT_METHOD_HAS_NOT_YET_BEEN_CALLED, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + if(iterator->remove_called) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_ITERATOR_REMOVE_HAS_ALREADY_BEING_CALLED, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + iterator->remove_called = AXIS2_TRUE; + + if(!(iterator->last_child)) + return AXIS2_FAILURE; + axiom_node_free_tree(iterator->last_child, env); + iterator->last_child = NULL; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_children_qname_iterator_has_next( + axiom_children_qname_iterator_t * iterator, + const axutil_env_t * env) +{ + while(iterator->need_to_move_forward) + { + if(iterator->current_child) + { + axiom_element_t *om_element = NULL; + axutil_qname_t *element_qname = NULL; + + if(axiom_node_get_node_type(iterator->current_child, env) == AXIOM_ELEMENT) + { + om_element = (axiom_element_t *)axiom_node_get_data_element( + iterator-> current_child, env); + } + + if(om_element) + { + element_qname = axiom_element_get_qname(om_element, env, iterator->current_child); + } + + if(om_element && axutil_qname_equals(element_qname, env, iterator->given_qname)) + { + iterator->matching_node_found = AXIS2_TRUE; + iterator->need_to_move_forward = AXIS2_FALSE; + } + else + { + iterator->current_child = axiom_node_get_next_sibling(iterator->current_child, env); + if(iterator->current_child) + { + iterator->need_to_move_forward = AXIS2_TRUE; + iterator->matching_node_found = AXIS2_TRUE; + } + else + { + iterator->need_to_move_forward = AXIS2_FALSE; + iterator->matching_node_found = AXIS2_FALSE; + } + } + } + else + { + iterator->need_to_move_forward = AXIS2_FALSE; + } + } + return iterator->matching_node_found; + +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_children_qname_iterator_next( + axiom_children_qname_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + iterator->need_to_move_forward = AXIS2_TRUE; + iterator->matching_node_found = AXIS2_FALSE; + iterator->next_called = AXIS2_TRUE; + iterator->remove_called = AXIS2_FALSE; + + iterator->last_child = iterator->current_child; + if(iterator->current_child) + { + iterator->current_child = axiom_node_get_next_sibling(iterator->current_child, env); + } + return iterator->last_child; +} + diff --git a/axiom/src/om/om_children_with_specific_attribute_iterator.c b/axiom/src/om/om_children_with_specific_attribute_iterator.c new file mode 100644 index 0000000..8f2e463 --- /dev/null +++ b/axiom/src/om/om_children_with_specific_attribute_iterator.c @@ -0,0 +1,177 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +struct axiom_children_with_specific_attribute_iterator +{ + axiom_node_t *current_child; + axiom_node_t *last_child; + axis2_bool_t next_called; + axis2_bool_t remove_called; + axutil_qname_t *attr_qname; + axis2_char_t *attr_value; + axis2_bool_t detach; +}; + +AXIS2_EXTERN axiom_children_with_specific_attribute_iterator_t *AXIS2_CALL +axiom_children_with_specific_attribute_iterator_create( + const axutil_env_t * env, + axiom_node_t * current_child, + axutil_qname_t * attr_qname, + axis2_char_t * attr_value, + axis2_bool_t detach) +{ + axiom_children_with_specific_attribute_iterator_t *iterator = NULL; + + AXIS2_PARAM_CHECK(env->error, current_child, NULL); + AXIS2_PARAM_CHECK(env->error, attr_qname, NULL); + AXIS2_PARAM_CHECK(env->error, attr_value, NULL); + iterator = (axiom_children_with_specific_attribute_iterator_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_children_with_specific_attribute_iterator_t)); + + if(!iterator) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + iterator->current_child = NULL; + iterator->last_child = NULL; + + iterator->next_called = AXIS2_FALSE; + iterator->remove_called = AXIS2_FALSE; + + iterator->attr_qname = axutil_qname_clone(attr_qname, env); + iterator->attr_value = attr_value; + iterator->detach = detach; + + return iterator; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_children_with_specific_attribute_iterator_free( + axiom_children_with_specific_attribute_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + if(iterator->attr_qname) + { + axutil_qname_free(iterator->attr_qname, env); + } + AXIS2_FREE(env->allocator, iterator); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_children_with_specific_attribute_iterator_remove( + axiom_children_with_specific_attribute_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, iterator, AXIS2_FAILURE); + + if(!(iterator->next_called)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_ITERATOR_NEXT_METHOD_HAS_NOT_YET_BEEN_CALLED, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + if(iterator->remove_called) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_ITERATOR_REMOVE_HAS_ALREADY_BEING_CALLED, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + iterator->remove_called = AXIS2_TRUE; + + if(!(iterator->last_child)) + return AXIS2_FAILURE; + axiom_node_free_tree(iterator->last_child, env); + iterator->last_child = NULL; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_children_with_specific_attribute_iterator_has_next( + axiom_children_with_specific_attribute_iterator_t * iterator, + const axutil_env_t * env) +{ + axis2_bool_t matching_node_found = AXIS2_FALSE; + axis2_bool_t need_to_move_forward = AXIS2_TRUE; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(!(iterator->current_child)) + { + return AXIS2_FALSE; + } + while(need_to_move_forward) + { + if(axiom_node_get_node_type(iterator->current_child, env) == AXIOM_ELEMENT) + { + axiom_attribute_t *om_attr = NULL; + axiom_element_t *om_ele = NULL; + om_ele = (axiom_element_t *)axiom_node_get_data_element(iterator-> current_child, env); + om_attr = axiom_element_get_attribute(om_ele, env, iterator->attr_qname); + break; + /*if (om_attr && + (axutil_strcmp(axiom_attribute_get_value(om_attr, env), + iterator->attr_value) == 0)) + { + matching_node_found = AXIS2_TRUE; + need_to_move_forward = AXIS2_FALSE; + } + else + { + iterator->current_child = + axiom_node_get_next_sibling(iterator->current_child, env); + need_to_move_forward = (iterator->current_child != NULL); + + }*/ + } + else + { + + iterator->current_child = axiom_node_get_next_sibling(iterator->current_child, env); + need_to_move_forward = (iterator->current_child != NULL); + } + + } + return matching_node_found; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_children_with_specific_attribute_iterator_next( + axiom_children_with_specific_attribute_iterator_t * iterator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, iterator, NULL); + + iterator->next_called = AXIS2_TRUE; + iterator->remove_called = AXIS2_FALSE; + iterator->last_child = iterator->current_child; + iterator->current_child = axiom_node_get_next_sibling(iterator->current_child, env); + if(iterator->last_child && iterator->detach + && (axiom_node_get_parent(iterator->last_child, env))) + { + axiom_node_free_tree(iterator->last_child, env); + } + return iterator->last_child; +} diff --git a/axiom/src/om/om_comment.c b/axiom/src/om/om_comment.c new file mode 100644 index 0000000..ad17f74 --- /dev/null +++ b/axiom/src/om/om_comment.c @@ -0,0 +1,142 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "axiom_node_internal.h" +#include + +struct axiom_comment +{ + + /** comment text */ + axis2_char_t *value; +}; + +AXIS2_EXTERN axiom_comment_t *AXIS2_CALL +axiom_comment_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * value, + axiom_node_t ** node) +{ + axiom_comment_t *comment = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, value, NULL); + AXIS2_PARAM_CHECK(env->error, node, NULL); + *node = NULL; + *node = axiom_node_create(env); + if(!*node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + comment = (axiom_comment_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_comment_t)); + if(!comment) + { + AXIS2_FREE(env->allocator, (*node)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + comment->value = NULL; + + if(value) + { + comment->value = (axis2_char_t *)axutil_strdup(env, value); + if(!comment->value) + { + AXIS2_FREE(env->allocator, comment); + AXIS2_FREE(env->allocator, (*node)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + } + + axiom_node_set_data_element((*node), env, comment); + axiom_node_set_node_type((*node), env, AXIOM_COMMENT); + + if(parent) + { + axiom_node_add_child(parent, env, (*node)); + } + + return comment; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_comment_free( + axiom_comment_t * comment, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(comment->value) + { + AXIS2_FREE(env->allocator, comment->value); + } + AXIS2_FREE(env->allocator, comment); + return; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_comment_get_value( + axiom_comment_t * comment, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + return comment->value; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_comment_set_value( + axiom_comment_t * comment, + const axutil_env_t * env, + const axis2_char_t * value) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + if(comment->value) + { + AXIS2_FREE(env->allocator, comment->value); + } + + comment->value = (axis2_char_t *)axutil_strdup(env, value); + + if(!comment->value) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_comment_serialize( + axiom_comment_t * comment, + const axutil_env_t * env, + axiom_output_t * om_output) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); + + if(comment->value) + { + return axiom_output_write(om_output, env, AXIOM_COMMENT, 1, comment->value); + } + return AXIS2_FAILURE; +} diff --git a/axiom/src/om/om_data_source.c b/axiom/src/om/om_data_source.c new file mode 100644 index 0000000..3959e49 --- /dev/null +++ b/axiom/src/om/om_data_source.c @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "axiom_node_internal.h" +#include +#include +#include +#include +#include + +/********************* axiom_data_source_struct ***************/ + +struct axiom_data_source +{ + + /** stream holding serialized XML string */ + axutil_stream_t *stream; +}; + +AXIS2_EXTERN axiom_data_source_t *AXIS2_CALL +axiom_data_source_create( + const axutil_env_t * env, + axiom_node_t * parent, + axiom_node_t ** node) +{ + + axiom_data_source_t *data_source = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, node, NULL); + + *node = axiom_node_create(env); + + if(!(*node)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + data_source = (axiom_data_source_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_data_source_t)); + if(!data_source) + { + AXIS2_FREE(env->allocator, *node); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + axiom_node_set_data_element((*node), env, data_source); + axiom_node_set_node_type((*node), env, AXIOM_DATA_SOURCE); + axiom_node_set_complete((*node), env, AXIS2_FALSE); + + data_source->stream = NULL; + + data_source->stream = axutil_stream_create_basic(env); + if(!(data_source->stream)) + { + AXIS2_FREE(env->allocator, *node); + AXIS2_FREE(env->allocator, data_source); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + if(parent && axiom_node_get_node_type(parent, env) == AXIOM_ELEMENT) + { + axiom_node_add_child(parent, env, (*node)); + } + + return data_source; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_data_source_free( + axiom_data_source_t * data_source, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + + if(data_source->stream) + { + axutil_stream_free(data_source->stream, env); + } + + AXIS2_FREE(env->allocator, data_source); + + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_data_source_serialize( + axiom_data_source_t * data_source, + const axutil_env_t * env, + axiom_output_t * om_output) +{ + int status = AXIS2_SUCCESS; + axis2_char_t *data = NULL; + unsigned int data_len = 0; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); + + data = axutil_stream_get_buffer(data_source->stream, env); + data_len = axutil_stream_get_len(data_source->stream, env); + if(data) + { + data[data_len] = '\0'; + status = axiom_output_write(om_output, env, AXIOM_DATA_SOURCE, 1, data); + } + return status; +} + +AXIS2_EXTERN axutil_stream_t *AXIS2_CALL +axiom_data_source_get_stream( + axiom_data_source_t * data_source, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + return data_source->stream; +} diff --git a/axiom/src/om/om_doctype.c b/axiom/src/om/om_doctype.c new file mode 100644 index 0000000..fa5616b --- /dev/null +++ b/axiom/src/om/om_doctype.c @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "axiom_node_internal.h" + +struct axiom_doctype +{ + + /** Doctype value */ + axis2_char_t *value; +}; + +AXIS2_EXTERN axiom_doctype_t *AXIS2_CALL +axiom_doctype_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * value, + axiom_node_t ** node) +{ + axiom_doctype_t *doctype = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, node, NULL); + + *node = axiom_node_create(env); + if(!*node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + doctype = (axiom_doctype_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_doctype_t)); + + if(!doctype) + { + AXIS2_FREE(env->allocator, (*node)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + doctype->value = NULL; + + if(value) + { + doctype->value = (axis2_char_t *)axutil_strdup(env, value); + if(!doctype->value) + { + AXIS2_FREE(env->allocator, doctype); + AXIS2_FREE(env->allocator, (*node)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + } + + axiom_node_set_data_element((*node), env, doctype); + axiom_node_set_node_type((*node), env, AXIOM_DOCTYPE); + + if(parent) + { + axiom_node_add_child(parent, env, (*node)); + } + + return doctype; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_doctype_free( + axiom_doctype_t * om_doctype, + const axutil_env_t * env) +{ + if(om_doctype) + { + if(om_doctype->value) + { + AXIS2_FREE(env->allocator, om_doctype->value); + } + AXIS2_FREE(env->allocator, om_doctype); + } + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_doctype_set_value( + axiom_doctype_t * om_doctype, + const axutil_env_t * env, + const axis2_char_t * value) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + om_doctype->value = (axis2_char_t *)axutil_strdup(env, value); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_doctype_get_value( + axiom_doctype_t * om_doctype, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + return om_doctype->value; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_doctype_serialize( + axiom_doctype_t * om_doctype, + const axutil_env_t * env, + axiom_output_t * om_output) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); + + if(om_doctype->value) + return axiom_output_write(om_output, env, AXIOM_DOCTYPE, 1, om_doctype->value); + + return AXIS2_FAILURE; +} diff --git a/axiom/src/om/om_document.c b/axiom/src/om/om_document.c new file mode 100644 index 0000000..149edec --- /dev/null +++ b/axiom/src/om/om_document.c @@ -0,0 +1,263 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +struct axiom_document +{ + + /** root element */ + axiom_node_t *root_element; + + /** last child */ + axiom_node_t *last_child; + + /** first child */ + axiom_node_t *first_child; + + /** done building the document */ + axis2_bool_t done; + + /** builder of the document */ + struct axiom_stax_builder *builder; + + /** char set encoding */ + axis2_char_t *char_set_encoding; + + /** XML version */ + axis2_char_t *xml_version; +}; + +AXIS2_EXTERN axiom_document_t *AXIS2_CALL +axiom_document_create( + const axutil_env_t * env, + axiom_node_t * root, + axiom_stax_builder_t * builder) +{ + axiom_document_t *document = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + document = (axiom_document_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_document_t)); + + if(!document) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + document->builder = builder; + document->root_element = root; + document->first_child = root; + document->last_child = root; + document->xml_version = XML_VERSION; + document->char_set_encoding = CHAR_SET_ENCODING; + document->done = AXIS2_FALSE; + + return document; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_document_free( + axiom_document_t * document, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + + if(document->root_element) + { + axiom_node_free_tree(document->root_element, env); + } + AXIS2_FREE(env->allocator, document); + return; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_document_free_self( + axiom_document_t * document, + const axutil_env_t * env) +{ + AXIS2_FREE(env->allocator, document); + return; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_document_build_next( + axiom_document_t * document, + const axutil_env_t * env) +{ + axiom_node_t *last_child = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + if(!document->builder) + { + return NULL; + } + + if(!(document->root_element)) + { + last_child = axiom_stax_builder_next(document->builder, env); + if(last_child) + { + document->last_child = last_child; + document->root_element = last_child; + } + return last_child; + } + else if((document->root_element) && (axiom_node_is_complete(document->root_element, env) + == AXIS2_TRUE)) + return NULL; /* Nothing wrong but done with pulling */ + + last_child = axiom_stax_builder_next(document->builder, env); + if(last_child) + { + document->last_child = last_child; + } + return last_child; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_document_get_root_element( + axiom_document_t * document, + const axutil_env_t * env) +{ + axiom_node_t *node = NULL; + AXIS2_ENV_CHECK(env, NULL); + + if(document->root_element) + { + return document->root_element; + } + node = axiom_document_build_next(document, env); + + if(document->root_element) + { + return document->root_element; + } + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_DOCUMENT_STATE_ROOT_NULL, AXIS2_FAILURE); + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_document_set_root_element( + axiom_document_t * document, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + + if(document->root_element) + { + axiom_node_free_tree(document->root_element, env); + document->root_element = node; + return AXIS2_SUCCESS; + } + else + { + document->root_element = node; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_document_build_all( + struct axiom_document * document, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + if(!document) + { + return NULL; + } + if(!document->root_element) + { + axiom_document_get_root_element(document, env); + } + if(document->root_element) + { + do + { + axiom_node_t *ret_val = NULL; + ret_val = axiom_document_build_next(document, env); + if(!ret_val) + { + if(axiom_node_is_complete(document->root_element, env) == AXIS2_TRUE) + { + + /** document is completly build */ + return document->root_element; + } + else + { + + /** error occurred */ + return NULL; + } + } + } + while(!axiom_node_is_complete(document->root_element, env)); + return document->root_element; + } + else + return NULL; +} + +AXIS2_EXTERN axiom_stax_builder_t *AXIS2_CALL +axiom_document_get_builder( + axiom_document_t * document, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + return document->builder; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_document_set_builder( + axiom_document_t * document, + const axutil_env_t * env, + axiom_stax_builder_t * builder) +{ + document->builder = builder; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_document_serialize( + axiom_document_t * document, + const axutil_env_t * env, + axiom_output_t * om_output) +{ + if(!document) + return AXIS2_FAILURE; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + if(!(document->root_element)) + { + axiom_document_get_root_element(document, env); + } + if(document->root_element) + { + return axiom_node_serialize(document->root_element, env, om_output); + } + else + { + return AXIS2_FAILURE; + } +} diff --git a/axiom/src/om/om_element.c b/axiom/src/om/om_element.c new file mode 100644 index 0000000..84982cd --- /dev/null +++ b/axiom/src/om/om_element.c @@ -0,0 +1,1818 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "axiom_node_internal.h" +#include +#include +#include +#include +#include +#include + +struct axiom_element +{ + + /** Element's namespace */ + axiom_namespace_t *ns; + + /** Element's local name */ + axutil_string_t *localname; + + /** List of attributes */ + axutil_hash_t *attributes; + + /** List of namespaces */ + axutil_hash_t *namespaces; + + axutil_qname_t *qname; + + axiom_child_element_iterator_t *child_ele_iter; + + axiom_children_iterator_t *children_iter; + + axiom_children_qname_iterator_t *children_qname_iter; + + axis2_char_t *text_value; + + int next_ns_prefix_number; + + axis2_bool_t is_empty; + +}; + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_element_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * localname, + axiom_namespace_t * ns, + axiom_node_t ** node) +{ + axiom_element_t *element; + AXIS2_ENV_CHECK(env, NULL); + + if(!localname || !node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "localname or node is NULL"); + return NULL; + } + + (*node) = axiom_node_create(env); + if(!(*node)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No Memory"); + return NULL; + } + element = (axiom_element_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_element_t)); + + if(!element) + { + AXIS2_FREE(env->allocator, (*node)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No Memory"); + return NULL; + } + element->ns = NULL; + element->localname = NULL; + element->attributes = NULL; + element->namespaces = NULL; + element->qname = NULL; + element->child_ele_iter = NULL; + element->children_iter = NULL; + element->children_qname_iter = NULL; + element->text_value = NULL; + element->next_ns_prefix_number = 0; + element->is_empty = AXIS2_FALSE; + + element->localname = axutil_string_create(env, localname); + if(!element->localname) + { + AXIS2_FREE(env->allocator, element); + AXIS2_FREE(env->allocator, (*node)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + if(parent) + { + axiom_node_add_child(parent, env, (*node)); + } + axiom_node_set_complete((*node), env, AXIS2_FALSE); + axiom_node_set_node_type((*node), env, AXIOM_ELEMENT); + axiom_node_set_data_element((*node), env, element); + + if(ns) + { + axis2_char_t *uri = NULL; + axis2_char_t *prefix = NULL; + + uri = axiom_namespace_get_uri(ns, env); + prefix = axiom_namespace_get_prefix(ns, env); + + /* + if (prefix && axutil_strcmp(prefix, "") == 0) + { + element->ns = NULL; + return element; + } + */ + element->ns = axiom_element_find_namespace(element, env, *node, uri, prefix); + + if(element->ns) + { + if(ns != element->ns) + { + axiom_namespace_free(ns, env); + ns = NULL; + } + } + + if(!(element->ns)) + { + if(axiom_element_declare_namespace(element, env, *node, ns) == AXIS2_SUCCESS) + { + element->ns = ns; + } + } + + /*if (prefix && axutil_strcmp(prefix, "") == 0) + { + element->ns = NULL; + } + */ + } + + return element; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_element_create_with_qname( + const axutil_env_t * env, + axiom_node_t * parent, + const axutil_qname_t * qname, + axiom_node_t ** node) +{ + axiom_element_t *element = NULL; + axis2_char_t *localpart = NULL; + + AXIS2_ENV_CHECK(env, NULL); + if(!qname || !node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "qname or node is NULL"); + return NULL; + } + localpart = axutil_qname_get_localpart(qname, env); + if(!localpart) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "localpart is NULL"); + return NULL; + } + element = axiom_element_create(env, parent, localpart, NULL, node); + if(!element) + { + return NULL; + } + + if(*node) + { + axiom_element_t *om_element = NULL; + axis2_char_t *temp_nsuri = NULL; + axis2_char_t *temp_prefix = NULL; + axiom_namespace_t *ns = NULL; + + om_element = ((axiom_element_t *)axiom_node_get_data_element((*node), env)); + temp_nsuri = axutil_qname_get_uri(qname, env); + temp_prefix = axutil_qname_get_prefix(qname, env); + if(!om_element) + { + return NULL; + } + + if((!temp_nsuri) || (axutil_strcmp(temp_nsuri, "") == 0)) + { + + /** no namespace uri is available in given qname + no need to bother about it + */ + return om_element; + } + + om_element->ns = axiom_element_find_namespace(om_element, env, (*node), temp_nsuri, + temp_prefix); + + if(!(element->ns)) + { + + /** could not find a namespace so declare namespace */ + ns = axiom_namespace_create(env, temp_nsuri, temp_prefix); + if(ns && axiom_element_declare_namespace(om_element, env, *node, ns) == AXIS2_SUCCESS) + { + (element->ns) = ns; + return om_element; + } + else + { + if(ns) + { + axiom_namespace_free(ns, env); + } + axiom_element_free(om_element, env); + AXIS2_FREE(env->allocator, *node); + return NULL; + } + } + } + return element; +} + +AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL +axiom_element_find_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node, + const axis2_char_t * uri, + const axis2_char_t * prefix) +{ + axiom_node_t *parent = NULL; + AXIS2_ENV_CHECK(env, NULL); + + if(!element_node || !om_element) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "element_node or om_element is NULL"); + return NULL; + } + if(!axiom_node_get_data_element(element_node, env) || axiom_node_get_node_type(element_node, + env) != AXIOM_ELEMENT) + { + /* wrong element type or null node */ + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Wrong element type or null node"); + return NULL; + } + + if(om_element->namespaces) + { + void *ns = NULL; + + if(uri && (!prefix || axutil_strcmp(prefix, "") == 0)) + { + + /** check for a default namepsace */ + axiom_namespace_t *default_ns = NULL; + axutil_hash_index_t *hashindex; + + default_ns = axiom_element_get_default_namespace(om_element, env, element_node); + if(default_ns) + { + axis2_char_t *default_uri = NULL; + default_uri = axiom_namespace_get_uri(default_ns, env); + + if(axutil_strcmp(uri, default_uri) == 0) + { + return default_ns; + } + } + + /** prefix is null , so iterate the namespaces hash to find the namespace */ + for(hashindex = axutil_hash_first(om_element->namespaces, env); hashindex; hashindex + = axutil_hash_next(env, hashindex)) + { + axutil_hash_this(hashindex, NULL, NULL, &ns); + if(ns) + { + axiom_namespace_t *temp_ns = NULL; + axis2_char_t *temp_nsuri = NULL; + temp_ns = (axiom_namespace_t *)ns; + temp_nsuri = axiom_namespace_get_uri(temp_ns, env); + + if(axutil_strcmp(temp_nsuri, uri) == 0) + { + /** namespace uri matches, so free hashindex and return ns*/ + AXIS2_FREE(env->allocator, hashindex); + return (axiom_namespace_t *)(ns); + } + temp_ns = NULL; + temp_nsuri = NULL; + ns = NULL; + } + } + ns = NULL; + } + else if(prefix) + { + + /** prefix is not null get namespace directly if exist */ + ns = axutil_hash_get(om_element->namespaces, prefix, AXIS2_HASH_KEY_STRING); + if(ns) + { + axiom_namespace_t *found_ns = NULL; + axis2_char_t *found_uri = NULL; + found_ns = (axiom_namespace_t *)ns; + found_uri = axiom_namespace_get_uri(found_ns, env); + if(uri) + { + /* if uri provided, return found ns only if uri matches */ + return (axutil_strcmp(found_uri, uri) == 0) ? found_ns : NULL; + } + return found_ns; + } + } + } + + /** could not find the namespace in current element scope + look in the parent */ + + parent = axiom_node_get_parent(element_node, env); + + if(parent) + { + if(axiom_node_get_node_type(parent, env) == AXIOM_ELEMENT) + { + axiom_element_t *om_element = NULL; + om_element = (axiom_element_t *)axiom_node_get_data_element(parent, env); + if(om_element) + + { /** parent exist, parent is om element so find in parent*/ + return axiom_element_find_namespace(om_element, env, parent, uri, prefix); + } + } + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_declare_namespace_assume_param_ownership( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_namespace_t * ns) +{ + axis2_char_t *prefix = NULL; + axis2_char_t *uri = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(!ns || !om_element) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "namespace or om_element is NULL"); + return AXIS2_FAILURE; + } + + uri = axiom_namespace_get_uri(ns, env); + prefix = axiom_namespace_get_prefix(ns, env); + + if(!(om_element->namespaces)) + { + om_element->namespaces = axutil_hash_make(env); + if(!(om_element->namespaces)) + { + return AXIS2_FAILURE; + } + } + if(prefix) + { + axutil_hash_set(om_element->namespaces, prefix, AXIS2_HASH_KEY_STRING, ns); + } + else + { + axis2_char_t *key = NULL; + key = AXIS2_MALLOC(env->allocator, sizeof(char) * 10); + memset(key, 0, sizeof(char) * 10); + om_element->next_ns_prefix_number++; + key[0] = '\0'; + axutil_hash_set(om_element->namespaces, key, AXIS2_HASH_KEY_STRING, ns); + } + axiom_namespace_increment_ref(ns, env); + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_declare_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * node, + axiom_namespace_t * ns) +{ + axiom_namespace_t *declared_ns = NULL; + axis2_char_t *prefix = NULL; + axis2_char_t *uri = NULL; + + if(!node || !ns || !om_element) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "node or namespace or om_element is NULL"); + return AXIS2_FAILURE; + } + + uri = axiom_namespace_get_uri(ns, env); + prefix = axiom_namespace_get_prefix(ns, env); + + declared_ns = axiom_element_find_namespace(om_element, env, node, uri, prefix); + + if(declared_ns) + { + if(axiom_namespace_equals(ns, env, declared_ns) == AXIS2_TRUE) + { + /*Namespace already declared, so return */ + return AXIS2_SUCCESS; + } + } + + if(!(om_element->namespaces)) + { + om_element->namespaces = axutil_hash_make(env); + if(!(om_element->namespaces)) + { + return AXIS2_FAILURE; + } + } + if(prefix) + { + axutil_hash_set(om_element->namespaces, prefix, AXIS2_HASH_KEY_STRING, ns); + } + else + { + axis2_char_t *key = NULL; + key = AXIS2_MALLOC(env->allocator, sizeof(char) * 10); + memset(key, 0, sizeof(char) * 10); + om_element->next_ns_prefix_number++; + key[0] = '\0'; + axutil_hash_set(om_element->namespaces, key, AXIS2_HASH_KEY_STRING, ns); + } + axiom_namespace_increment_ref(ns, env); + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL +axiom_element_find_declared_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + const axis2_char_t * uri, + const axis2_char_t * prefix) +{ + axutil_hash_index_t *hash_index = NULL; + void *ns = NULL; + AXIS2_ENV_CHECK(env, NULL); + + if(!(om_element->namespaces)) + { + return NULL; + } + if(uri && (!prefix || axutil_strcmp(prefix, "") == 0)) + { + /** prefix null iterate the namespace hash for matching uri */ + for(hash_index = axutil_hash_first(om_element->namespaces, env); hash_index; hash_index + = axutil_hash_next(env, hash_index)) + { + axutil_hash_this(hash_index, NULL, NULL, &ns); + if(ns) + { + axiom_namespace_t *temp_ns = NULL; + axis2_char_t *temp_nsuri = NULL; + temp_ns = (axiom_namespace_t *)(ns); + temp_nsuri = axiom_namespace_get_uri(temp_ns, env); + if(axutil_strcmp(temp_nsuri, uri) == 0) + { + AXIS2_FREE(env->allocator, hash_index); + return temp_ns; + } + temp_ns = NULL; + temp_nsuri = NULL; + } + } + ns = NULL; + return NULL; + } + else if(prefix) + { + axiom_namespace_t *found_ns = NULL; + ns = axutil_hash_get(om_element->namespaces, prefix, AXIS2_HASH_KEY_STRING); + if(ns) + { + axis2_char_t *found_uri = NULL; + found_ns = (axiom_namespace_t *)ns; + found_uri = axiom_namespace_get_uri(found_ns, env); + /* If uri provided, ensure this namespace found by prefix matches the uri */ + if(uri) + { + return (axutil_strcmp(found_uri, uri) == 0) ? found_ns : NULL; + } + return found_ns; + } + } + return NULL; +} + +AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL +axiom_element_find_namespace_with_qname( + axiom_element_t * element, + const axutil_env_t * env, + axiom_node_t * node, + axutil_qname_t * qname) +{ + AXIS2_ENV_CHECK(env, NULL); + if(!element || !node || !qname) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "element or node or qname is NULL"); + return NULL; + } + + if(axutil_qname_get_uri(qname, env)) + { + return axiom_element_find_namespace(element, env, node, axutil_qname_get_uri(qname, env), + axutil_qname_get_prefix(qname, env)); + } + else + { + return NULL; + } +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_add_attribute( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_attribute_t * attribute, + axiom_node_t * element_node) +{ + + axutil_qname_t *qname = NULL; + axiom_namespace_t *om_namespace = NULL; + axiom_namespace_t *temp_ns = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, attribute, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, element_node, AXIS2_FAILURE); + + /* ensure the attribute's namespace structure is declared */ + om_namespace = axiom_attribute_get_namespace(attribute, env); + if(om_namespace) + { + temp_ns = axiom_element_find_namespace(om_element, env, element_node, + axiom_namespace_get_uri(om_namespace, env), axiom_namespace_get_prefix(om_namespace, + env)); + if(temp_ns != om_namespace) + { + axis2_status_t status; + /* as the attribute's namespace structure is not declared in scope, + declare it here */ + status = axiom_element_declare_namespace_assume_param_ownership(om_element, env, + om_namespace); + if(status != AXIS2_SUCCESS) + { + return status; + } + } + } + + if(!(om_element->attributes)) + { + om_element->attributes = axutil_hash_make(env); + if(!(om_element->attributes)) + { + return AXIS2_FAILURE; + } + } + + qname = axiom_attribute_get_qname(attribute, env); + if(qname) + { + axis2_char_t *name = axutil_qname_to_string(qname, env); + axutil_hash_set(om_element->attributes, name, AXIS2_HASH_KEY_STRING, attribute); + axiom_attribute_increment_ref(attribute, env); + } + return ((qname) ? AXIS2_SUCCESS : AXIS2_FAILURE); +} + +AXIS2_EXTERN axiom_attribute_t *AXIS2_CALL +axiom_element_get_attribute( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_qname_t * qname) +{ + axis2_char_t *name = NULL; + axiom_attribute_t *attr = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, qname, NULL); + + name = axutil_qname_to_string(qname, env); + + if((om_element->attributes) && name) + { + attr = (axiom_attribute_t *)(axutil_hash_get(om_element->attributes, name, + AXIS2_HASH_KEY_STRING)); + } + return attr; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_element_free( + axiom_element_t * om_element, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + if(!om_element) + { + return; + } + + if(om_element->localname) + { + axutil_string_free(om_element->localname, env); + } + if(om_element->ns) + { + /* it is the responsibility of the element where the namespace is declared to free it */ + } + if(om_element->attributes) + { + axutil_hash_index_t *hi; + void *val = NULL; + + for(hi = axutil_hash_first(om_element->attributes, env); hi; hi = axutil_hash_next(env, hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + + if(val) + { + axiom_attribute_free((axiom_attribute_t *)val, env); + } + } + axutil_hash_free(om_element->attributes, env); + } + + if(om_element->namespaces) + { + axutil_hash_index_t *hi; + void *val = NULL; + for(hi = axutil_hash_first(om_element->namespaces, env); hi; hi = axutil_hash_next(env, hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + if(val) + { + axiom_namespace_free((axiom_namespace_t *)val, env); + } + } + axutil_hash_free(om_element->namespaces, env); + } + if(om_element->qname) + { + axutil_qname_free(om_element->qname, env); + } + if(om_element->children_iter) + { + axiom_children_iterator_free(om_element->children_iter, env); + } + if(om_element->child_ele_iter) + { + AXIOM_CHILD_ELEMENT_ITERATOR_FREE(om_element->child_ele_iter, env); + } + if(om_element->children_qname_iter) + { + axiom_children_qname_iterator_free(om_element->children_qname_iter, env); + } + if(om_element->text_value) + { + AXIS2_FREE(env->allocator, om_element->text_value); + } + AXIS2_FREE(env->allocator, om_element); + + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_serialize_start_part( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_output_t * om_output, + axiom_node_t * ele_node) +{ + int status = AXIS2_SUCCESS; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); + + if(om_element->is_empty) + { + if(om_element->ns) + { + axis2_char_t *uri = NULL; + axis2_char_t *prefix = NULL; + + uri = axiom_namespace_get_uri(om_element->ns, env); + prefix = axiom_namespace_get_prefix(om_element->ns, env); + + if((uri) && (prefix) && (axutil_strcmp(prefix, "") != 0)) + { + status = axiom_output_write(om_output, env, AXIOM_ELEMENT, 4, + axutil_string_get_buffer(om_element-> localname, env), uri, prefix, NULL); + } + else if(uri) + { + status = axiom_output_write(om_output, env, AXIOM_ELEMENT, 4, + axutil_string_get_buffer(om_element-> localname, env), uri, NULL, NULL); + } + } + else + { + status = axiom_output_write(om_output, env, AXIOM_ELEMENT, 4, axutil_string_get_buffer( + om_element-> localname, env), NULL, NULL, NULL); + } + } + else + { + if(om_element->ns) + { + axis2_char_t *uri = NULL; + axis2_char_t *prefix = NULL; + + uri = axiom_namespace_get_uri(om_element->ns, env); + prefix = axiom_namespace_get_prefix(om_element->ns, env); + + if((uri) && (prefix) && (axutil_strcmp(prefix, "") != 0)) + { + status = axiom_output_write(om_output, env, AXIOM_ELEMENT, 3, + axutil_string_get_buffer(om_element-> localname, env), uri, prefix); + } + else if(uri) + { + status = axiom_output_write(om_output, env, AXIOM_ELEMENT, 2, + axutil_string_get_buffer(om_element-> localname, env), uri); + } + } + else + { + status = axiom_output_write(om_output, env, AXIOM_ELEMENT, 1, axutil_string_get_buffer( + om_element-> localname, env)); + } + } + if(om_element->attributes) + { + axutil_hash_index_t *hi; + void *val; + for(hi = axutil_hash_first(om_element->attributes, env); hi; hi = axutil_hash_next(env, hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + + if(val) + { + status = axiom_attribute_serialize((axiom_attribute_t *)val, env, om_output); + } + else + { + status = AXIS2_FAILURE; + } + } + } + + if(om_element->namespaces) + { + axutil_hash_index_t *hi; + void *val; + for(hi = axutil_hash_first(om_element->namespaces, env); hi; hi = axutil_hash_next(env, hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + + if(val) + { + status = axiom_namespace_serialize((axiom_namespace_t *)val, env, om_output); + } + else + { + status = AXIS2_FAILURE; + } + } + } + + return status; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_serialize_end_part( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_output_t * om_output) +{ + int status = AXIS2_SUCCESS; + AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); + status = axiom_output_write(om_output, env, AXIOM_ELEMENT, 0); + return status; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_element_get_localname( + axiom_element_t * om_element, + const axutil_env_t * env) +{ + if(om_element->localname) + return (axis2_char_t *)axutil_string_get_buffer(om_element->localname, env); + else + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_set_localname( + axiom_element_t * om_element, + const axutil_env_t * env, + const axis2_char_t * localname) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + if(om_element->localname) + { + axutil_string_free(om_element->localname, env); + om_element->localname = NULL; + } + om_element->localname = axutil_string_create(env, localname); + if(!(om_element->localname)) + { + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL +axiom_element_get_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * ele_node) +{ + axiom_namespace_t *ns = NULL; + AXIS2_ENV_CHECK(env, NULL); + + if(om_element->ns) + { + ns = om_element->ns; + } + else + { + ns = axiom_element_get_default_namespace(om_element, env, ele_node); + + } + return ns; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_set_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_namespace_t * ns, + axiom_node_t * node) +{ + axiom_namespace_t *om_ns = NULL; + axis2_status_t status = AXIS2_SUCCESS; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, ns, AXIS2_FAILURE); + om_ns = axiom_element_find_namespace(om_element, env, node, axiom_namespace_get_uri(ns, env), + axiom_namespace_get_prefix(ns, env)); + if(!om_ns) + { + status = axiom_element_declare_namespace(om_element, env, node, ns); + if(status == AXIS2_FAILURE) + { + return AXIS2_FAILURE; + } + om_element->ns = ns; + } + else + { + om_element->ns = om_ns; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_set_namespace_assume_param_ownership( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_namespace_t * ns) +{ + om_element->ns = ns; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axiom_element_get_all_attributes( + axiom_element_t * om_element, + const axutil_env_t * env) +{ + + return om_element->attributes; +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axiom_element_get_namespaces( + axiom_element_t * om_element, + const axutil_env_t * env) +{ + return om_element->namespaces; +} + +AXIS2_EXTERN axutil_qname_t *AXIS2_CALL +axiom_element_get_qname( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * ele_node) +{ + axiom_namespace_t *ns = NULL; + AXIS2_ENV_CHECK(env, NULL); + + if(om_element->qname) + { + return om_element->qname; + } + else + { + ns = axiom_element_get_namespace(om_element, env, ele_node); + if(ns) + { + if(axiom_namespace_get_prefix(ns, env)) + { + om_element->qname = axutil_qname_create(env, axutil_string_get_buffer( + om_element->localname, env), axiom_namespace_get_uri(ns, env), + axiom_namespace_get_prefix(ns, env)); + } + else + { + om_element->qname = axutil_qname_create(env, axutil_string_get_buffer( + om_element->localname, env), axiom_namespace_get_uri(ns, env), NULL); + } + } + else + { + om_element->qname = axutil_qname_create(env, axutil_string_get_buffer( + om_element->localname, env), NULL, NULL); + } + } + return om_element->qname; +} + +AXIS2_EXTERN axiom_children_iterator_t *AXIS2_CALL +axiom_element_get_children( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node) +{ + AXIS2_PARAM_CHECK(env->error, element_node, NULL); + + if(!om_element->children_iter) + { + om_element->children_iter = axiom_children_iterator_create(env, axiom_node_get_first_child( + element_node, env)); + } + else + { + axiom_children_iterator_reset(om_element->children_iter, env); + } + return om_element->children_iter; +} + +AXIS2_EXTERN axiom_children_qname_iterator_t *AXIS2_CALL +axiom_element_get_children_with_qname( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_qname_t * element_qname, + axiom_node_t * element_node) +{ + AXIS2_PARAM_CHECK(env->error, element_node, NULL); + if(om_element->children_qname_iter) + { + axiom_children_qname_iterator_free(om_element->children_qname_iter, env); + om_element->children_qname_iter = NULL; + } + om_element->children_qname_iter = axiom_children_qname_iterator_create(env, + axiom_node_get_first_child(element_node, env), element_qname); + return om_element->children_qname_iter; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_element_get_first_child_with_qname( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_qname_t * element_qname, + axiom_node_t * element_node, + axiom_node_t ** child_node) +{ + axiom_node_t *om_node = NULL; + axiom_children_qname_iterator_t *children_iterator = NULL; + + AXIS2_PARAM_CHECK(env->error, element_qname, NULL); + AXIS2_PARAM_CHECK(env->error, element_node, NULL); + + om_node = axiom_node_get_first_child(element_node, env); + if(!om_node) + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "There are no child elements for the node"); + return NULL; + } + children_iterator = axiom_children_qname_iterator_create(env, om_node, element_qname); + if(!children_iterator) + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Could not create children qname iterator"); + return NULL; + } + om_node = NULL; + if(axiom_children_qname_iterator_has_next(children_iterator, env)) + { + om_node = axiom_children_qname_iterator_next(children_iterator, env); + } + if(om_node && (axiom_node_get_node_type(om_node, env) == AXIOM_ELEMENT)) + { + axiom_children_qname_iterator_free(children_iterator, env); + + if(child_node) + { + *child_node = om_node; + } + return (axiom_element_t *)axiom_node_get_data_element(om_node, env); + } + + axiom_children_qname_iterator_free(children_iterator, env); + + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_remove_attribute( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_attribute_t * om_attribute) +{ + axutil_qname_t *qname = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_attribute, AXIS2_FAILURE); + + qname = axiom_attribute_get_qname(om_attribute, env); + if(qname && (om_element->attributes)) + { + axis2_char_t *name = NULL; + name = axutil_qname_to_string(qname, env); + if(name) + { + axutil_hash_set(om_element->attributes, name, AXIS2_HASH_KEY_STRING, NULL); + return AXIS2_SUCCESS; + } + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_element_get_first_element( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node, + axiom_node_t ** first_ele_node) +{ + axiom_node_t *temp_node = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, element_node, NULL); + + temp_node = axiom_node_get_first_child(element_node, env); + while(temp_node) + { + if(axiom_node_get_node_type(temp_node, env) == AXIOM_ELEMENT) + { + if(first_ele_node) + { + *first_ele_node = temp_node; + } + return (axiom_element_t *)axiom_node_get_data_element(temp_node, env); + } + else + { + temp_node = axiom_node_get_next_sibling(temp_node, env); + } + } + return NULL; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_element_get_text( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node) +{ + axis2_char_t *dest = NULL; + const axis2_char_t *temp_text = NULL; + axiom_text_t *text_node = NULL; + axiom_node_t *temp_node = NULL; + + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, element_node, NULL); + + if(om_element->text_value) + { + AXIS2_FREE(env->allocator, om_element->text_value); + om_element->text_value = NULL; + } + + temp_node = axiom_node_get_first_child(element_node, env); + + while(temp_node) + { + if(axiom_node_get_node_type(temp_node, env) == AXIOM_TEXT) + { + int dest_len = 0; + int curr_len = 0; + axis2_char_t *temp_dest = NULL; + + text_node = (axiom_text_t *)axiom_node_get_data_element(temp_node, env); + if(text_node) + { + temp_text = axiom_text_get_value(text_node, env); + if(dest && temp_text && axutil_strcmp(temp_text, "") != 0) + { + dest_len = axutil_strlen(dest); + curr_len = dest_len + axutil_strlen(temp_text); + temp_dest = AXIS2_MALLOC(env->allocator, (curr_len + 1) * sizeof(axis2_char_t)); + + memcpy(temp_dest, dest, dest_len * sizeof(axis2_char_t)); + memcpy((temp_dest + dest_len * sizeof(axis2_char_t)), temp_text, curr_len + - dest_len); + + temp_dest[curr_len] = '\0'; + + AXIS2_FREE(env->allocator, dest); + dest = NULL; + dest = temp_dest; + } + else if(!dest && temp_text && axutil_strcmp(temp_text, "") != 0) + { + dest = axutil_strdup(env, temp_text); + } + } + } + temp_node = axiom_node_get_next_sibling(temp_node, env); + } + + om_element->text_value = dest; + return om_element->text_value; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_set_text( + axiom_element_t * om_element, + const axutil_env_t * env, + const axis2_char_t * text, + axiom_node_t * element_node) +{ + axiom_node_t *temp_node, *next_node; + axiom_text_t *om_text = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, text, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, element_node, AXIS2_FAILURE); + + next_node = axiom_node_get_first_child(element_node, env); + while(next_node) + { + temp_node = next_node; + next_node = axiom_node_get_next_sibling(temp_node, env); + if(axiom_node_get_node_type(temp_node, env) == AXIOM_TEXT) + { + axiom_node_free_tree(temp_node, env); + } + } + + om_text = axiom_text_create(env, NULL, text, &temp_node); + axiom_node_add_child(element_node, env, temp_node); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_element_to_string( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node) +{ + return axiom_node_to_string(element_node, env); +} + +AXIS2_EXTERN axiom_child_element_iterator_t *AXIS2_CALL +axiom_element_get_child_elements( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node) +{ + axiom_node_t *first_node = NULL; + axiom_element_t *ele = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, element_node, NULL); + ele = axiom_element_get_first_element(om_element, env, element_node, &first_node); + if(om_element->child_ele_iter) + { + return om_element->child_ele_iter; + } + else if(ele && first_node) + { + om_element->child_ele_iter = axiom_child_element_iterator_create(env, first_node); + return om_element->child_ele_iter; + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_build( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * om_ele_node) +{ + axiom_stax_builder_t *builder = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + AXIS2_PARAM_CHECK(env->error, om_ele_node, AXIS2_FAILURE); + if(axiom_node_get_node_type(om_ele_node, env) != AXIOM_ELEMENT) + { + return AXIS2_FAILURE; + } + + builder = axiom_node_get_builder(om_ele_node, env); + if(!builder) + { + return AXIS2_FAILURE; + } + while(!axiom_node_is_complete(om_ele_node, env) + && !axiom_stax_builder_is_complete(builder, env)) + { + void *value = NULL; + value = axiom_stax_builder_next(builder, env); + if(!value) + { + return AXIS2_FAILURE; + } + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL +axiom_element_get_default_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * element_node) +{ + axiom_node_t *parent_node = NULL; + axiom_namespace_t *default_ns = NULL; + + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, element_node, NULL); + + if(om_element->namespaces) + { + default_ns = axutil_hash_get(om_element->namespaces, "", AXIS2_HASH_KEY_STRING); + if(default_ns) + { + return default_ns; + } + } + + parent_node = axiom_node_get_parent(element_node, env); + if((parent_node) && (axiom_node_get_node_type(parent_node, env) == AXIOM_ELEMENT)) + { + axiom_element_t *parent_ele = NULL; + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(parent_ele) + { + return axiom_element_get_default_namespace(parent_ele, env, parent_node); + } + } + return NULL; +} + +/** + * declared a default namespace explicitly + */ +AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL +axiom_element_declare_default_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axis2_char_t * uri) +{ + axiom_namespace_t *default_ns = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, uri, NULL); + + if(axutil_strcmp(uri, "") == 0) + { + return NULL; + } + + default_ns = axiom_namespace_create(env, uri, ""); + if(!default_ns) + { + return NULL; + } + if(!om_element->namespaces) + { + om_element->namespaces = axutil_hash_make(env); + if(!(om_element->namespaces)) + { + axiom_namespace_free(default_ns, env); + return NULL; + } + } + + axutil_hash_set(om_element->namespaces, "", AXIS2_HASH_KEY_STRING, default_ns); + axiom_namespace_increment_ref(default_ns, env); + return default_ns; +} + +/** + * checks for the namespace in the context of this element + * with the given prefix + */ + +AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL +axiom_element_find_namespace_uri( + axiom_element_t * om_element, + const axutil_env_t * env, + const axis2_char_t * prefix, + axiom_node_t * element_node) +{ + axiom_node_t *parent_node = NULL; + axiom_namespace_t *ns = NULL; + + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, element_node, NULL); + AXIS2_PARAM_CHECK(env->error, prefix, NULL); + + if(om_element->namespaces) + { + ns = axutil_hash_get(om_element->namespaces, prefix, AXIS2_HASH_KEY_STRING); + if(ns) + { + return ns; + } + } + + parent_node = axiom_node_get_parent(element_node, env); + if((parent_node) && (axiom_node_get_node_type(parent_node, env) == AXIOM_ELEMENT)) + { + axiom_element_t *parent_ele = NULL; + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(parent_ele) + { + return axiom_element_find_namespace_uri(parent_ele, env, prefix, parent_node); + } + } + return NULL; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_element_get_attribute_value( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_qname_t * qname) +{ + axis2_char_t *name = NULL; + axiom_attribute_t *attr = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, qname, NULL); + + name = axutil_qname_to_string(qname, env); + + if((om_element->attributes) && (NULL != name)) + { + attr = (axiom_attribute_t *)axutil_hash_get(om_element->attributes, name, + AXIS2_HASH_KEY_STRING); + if(attr) + { + return axiom_attribute_get_value(attr, env); + } + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_set_namespace_with_no_find_in_current_scope( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_namespace_t * om_ns) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_ns, AXIS2_FAILURE); + om_element->ns = om_ns; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axiom_element_extract_attributes( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * ele_node) +{ + axutil_hash_index_t *hi = NULL; + axutil_hash_t *ht_cloned = NULL; + + axiom_attribute_t *om_attr = NULL; + axiom_attribute_t *cloned_attr = NULL; + + axiom_namespace_t *om_ns = NULL; + /*axiom_namespace_t *cloned_ns = NULL; */ + + axis2_char_t *key = NULL; + axutil_qname_t *qn = NULL; + + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + if(!om_element->attributes) + { + return NULL; + } + ht_cloned = axutil_hash_make(env); + if(!ht_cloned) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + for(hi = axutil_hash_first(om_element->attributes, env); hi; hi = axutil_hash_next(env, hi)) + { + void *val = NULL; + axutil_hash_this(hi, NULL, NULL, &val); + if(val) + { + om_attr = (axiom_attribute_t *)val; + cloned_attr = axiom_attribute_clone(om_attr, env); + + om_ns = axiom_attribute_get_namespace(om_attr, env); + if(om_ns) + { + /*cloned_ns = axiom_namespace_clone(om_ns, env); */ + /*axiom_attribute_set_namespace(cloned_attr, env, cloned_ns); */ + axiom_attribute_set_namespace(cloned_attr, env, om_ns); + } + qn = axiom_attribute_get_qname(cloned_attr, env); + key = axutil_qname_to_string(qn, env); + axutil_hash_set(ht_cloned, key, AXIS2_HASH_KEY_STRING, cloned_attr); + } + val = NULL; + key = NULL; + qn = NULL; + om_attr = NULL; + cloned_attr = NULL; + om_ns = NULL; + /*cloned_ns = NULL; */ + } + return ht_cloned; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_element_get_attribute_value_by_name( + axiom_element_t * om_element, + const axutil_env_t * env, + axis2_char_t * attr_name) +{ + axutil_hash_index_t *hi = NULL; + + AXIS2_PARAM_CHECK(env->error, attr_name, NULL); + if(!om_element->attributes) + { + return NULL; + } + for(hi = axutil_hash_first(om_element->attributes, env); hi; hi = axutil_hash_next(env, hi)) + { + void *attr = NULL; + axiom_attribute_t *om_attr = NULL; + axutil_hash_this(hi, NULL, NULL, &attr); + if(attr) + { + axis2_char_t *this_attr_name; + axis2_char_t *this_attr_value; + axis2_char_t *attr_qn_str = NULL; + axiom_namespace_t *attr_ns = NULL; + axis2_char_t *prefix = NULL; + + om_attr = (axiom_attribute_t *)attr; + this_attr_name = axiom_attribute_get_localname(om_attr, env); + this_attr_value = axiom_attribute_get_value(om_attr, env); + attr_ns = axiom_attribute_get_namespace(om_attr, env); + if(attr_ns) + { + prefix = axiom_namespace_get_prefix(attr_ns, env); + if(prefix) + { + axis2_char_t *tmp_val = NULL; + tmp_val = axutil_stracat(env, prefix, ":"); + attr_qn_str = axutil_stracat(env, tmp_val, this_attr_name); + if(tmp_val) + { + AXIS2_FREE(env->allocator, tmp_val); + tmp_val = NULL; + } + } + } + else + { + attr_qn_str = axutil_strdup(env, this_attr_name); + } + + if(attr_qn_str && axutil_strcmp(attr_qn_str, attr_name) == 0) + { + AXIS2_FREE(env->allocator, attr_qn_str); + attr_qn_str = NULL; + AXIS2_FREE(env->allocator, hi); + return this_attr_value; + } + + AXIS2_FREE(env->allocator, attr_qn_str); + attr_qn_str = NULL; + } + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_element_create_str( + const axutil_env_t * env, + axiom_node_t * parent, + axutil_string_t * localname, + axiom_namespace_t * ns, + axiom_node_t ** node) +{ + axiom_element_t *element; + AXIS2_ENV_CHECK(env, NULL); + + if(!localname || !node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "localname or node is NULL"); + return NULL; + } + + (*node) = axiom_node_create(env); + if(!(*node)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + element = (axiom_element_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_element_t)); + + if(!element) + { + AXIS2_FREE(env->allocator, (*node)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + element->ns = NULL; + element->localname = NULL; + element->attributes = NULL; + element->namespaces = NULL; + element->qname = NULL; + element->child_ele_iter = NULL; + element->children_iter = NULL; + element->children_qname_iter = NULL; + element->text_value = NULL; + element->next_ns_prefix_number = 0; + element->is_empty = AXIS2_FALSE; + + element->localname = axutil_string_clone(localname, env); + if(!element->localname) + { + AXIS2_FREE(env->allocator, element); + AXIS2_FREE(env->allocator, (*node)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + if(parent) + { + axiom_node_add_child(parent, env, (*node)); + } + axiom_node_set_complete((*node), env, AXIS2_FALSE); + axiom_node_set_node_type((*node), env, AXIOM_ELEMENT); + axiom_node_set_data_element((*node), env, element); + + if(ns) + { + axis2_char_t *uri = NULL; + axis2_char_t *prefix = NULL; + + uri = axiom_namespace_get_uri(ns, env); + prefix = axiom_namespace_get_prefix(ns, env); + + element->ns = axiom_element_find_namespace(element, env, *node, uri, prefix); + if(!(element->ns)) + { + if(axiom_element_declare_namespace(element, env, *node, ns) == AXIS2_SUCCESS) + { + element->ns = ns; + } + } + if(prefix && axutil_strcmp(prefix, "") == 0) + { + element->ns = NULL; + } + } + + return element; +} + +AXIS2_EXTERN axutil_string_t *AXIS2_CALL +axiom_element_get_localname_str( + axiom_element_t * om_element, + const axutil_env_t * env) +{ + return om_element->localname; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_element_set_localname_str( + axiom_element_t * om_element, + const axutil_env_t * env, + axutil_string_t * localname) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + + if(om_element->localname) + { + axutil_string_free(om_element->localname, env); + om_element->localname = NULL; + } + + om_element->localname = axutil_string_clone(localname, env); + + if(!(om_element->localname)) + { + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_element_get_is_empty( + axiom_element_t * om_element, + const axutil_env_t * env) +{ + return om_element->is_empty; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_element_set_is_empty( + axiom_element_t * om_element, + const axutil_env_t * env, + axis2_bool_t is_empty) +{ + om_element->is_empty = is_empty; +} + +/** + * Scan the parents of the element, to determine which namespaces are inscope for the + * the element and its children. + */ +AXIS2_EXTERN axutil_hash_t * AXIS2_CALL +axiom_element_gather_parent_namespaces( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * om_node) +{ + axutil_hash_t *inscope_namespaces = NULL; + axiom_node_t *parent_node = om_node; + + while((parent_node = axiom_node_get_parent(parent_node, env)) && (axiom_node_get_node_type( + parent_node, env) == AXIOM_ELEMENT)) + { + axiom_element_t *parent_element = (axiom_element_t *)axiom_node_get_data_element( + parent_node, env); + axutil_hash_t *parent_namespaces = axiom_element_get_namespaces(parent_element, env); + if(parent_namespaces) + { + axutil_hash_index_t *hi; + void *val; + for(hi = axutil_hash_first(parent_namespaces, env); hi; hi = axutil_hash_next(env, hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + if(val) + { + /* Check if prefix is already associated with some namespace in node being detached */ + if(!axiom_element_find_declared_namespace(om_element, env, NULL, + axiom_namespace_get_prefix((axiom_namespace_t *)val, env))) + { + axis2_char_t *key = axiom_namespace_get_prefix((axiom_namespace_t *)val, + env); + if(!key) + key = ""; + /* Check if prefix already associated with some namespace in a parent node */ + if(!(inscope_namespaces && axutil_hash_get(inscope_namespaces, key, + AXIS2_HASH_KEY_STRING))) + { + /* Remember this namespace as needing to be declared, if used */ + if(!inscope_namespaces) + inscope_namespaces = axutil_hash_make(env); + if(inscope_namespaces) + axutil_hash_set(inscope_namespaces, key, AXIS2_HASH_KEY_STRING, val); + } + } + } + } + } + } + + return inscope_namespaces; +} + +/** + * Test if the provided namespace pointer is declared in a parent namespace + * If so, redeclare it in the provided root element + */ +AXIS2_EXTERN void AXIS2_CALL +axiom_element_use_parent_namespace( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * om_node, + axiom_namespace_t *ns, + axiom_element_t * root_element, + axutil_hash_t *inscope_namespaces) +{ + if(ns && inscope_namespaces) + { + axiom_namespace_t *parent_ns; + axis2_char_t *key = axiom_namespace_get_prefix(ns, env); + if(!key) + key = ""; + + parent_ns = axutil_hash_get(inscope_namespaces, key, AXIS2_HASH_KEY_STRING); + /* Check if namespace is a namespace declared in a parent and not also + declared at an intermediate level */ + if(parent_ns && (parent_ns == ns) && (ns != axiom_element_find_namespace(om_element, env, + om_node, axiom_namespace_get_uri(ns, env), axiom_namespace_get_prefix(ns, env)))) + { + /* Redeclare this parent namespace at the level of the element being detached */ + axiom_element_declare_namespace_assume_param_ownership(root_element, env, parent_ns); + /* Remove the namespace from the inscope parent namespaces now that it has + been redeclared. */ + axutil_hash_set(inscope_namespaces, key, AXIS2_HASH_KEY_STRING, NULL); + } + } +} + +/** + * For each child node, determine if it uses a namespace from a parent of the node being detached + * If so, re-declare that namespace in the node being detached + */ +AXIS2_EXTERN void AXIS2_CALL +axiom_element_redeclare_parent_namespaces( + axiom_element_t * om_element, + const axutil_env_t * env, + axiom_node_t * om_node, + axiom_element_t * root_element, + axutil_hash_t *inscope_namespaces) +{ + axiom_node_t *child_node; + axutil_hash_t * attributes; + + if(!om_element || !om_node || !inscope_namespaces) + return; + + /* ensure the element's namespace is declared */ + axiom_element_use_parent_namespace(om_element, env, om_node, om_element->ns, root_element, + inscope_namespaces); + + /* for each attribute, ensure the attribute's namespace is declared */ + attributes = om_element->attributes; + if(attributes) + { + axutil_hash_index_t *hi; + void *val; + for(hi = axutil_hash_first(attributes, env); hi; hi = axutil_hash_next(env, hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + if(val) + { + axiom_element_use_parent_namespace(om_element, env, om_node, + axiom_attribute_get_namespace((axiom_attribute_t *)val, env), root_element, + inscope_namespaces); + } + } + } + + /* ensure the namespaces in all the children are declared */ + child_node = axiom_node_get_first_child(om_node, env); + while(child_node && (axutil_hash_count(inscope_namespaces) > 0)) + { + if(axiom_node_get_node_type(child_node, env) == AXIOM_ELEMENT) + { + axiom_element_redeclare_parent_namespaces(axiom_node_get_data_element(child_node, env), + env, child_node, root_element, inscope_namespaces); + } + child_node = axiom_node_get_next_sibling(child_node, env); + } +} diff --git a/axiom/src/om/om_namespace.c b/axiom/src/om/om_namespace.c new file mode 100644 index 0000000..2d9df2f --- /dev/null +++ b/axiom/src/om/om_namespace.c @@ -0,0 +1,385 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "axiom_namespace_internal.h" + +struct axiom_namespace +{ + + /** namespace URI */ + axutil_string_t *uri; + + /** namespace prefix */ + axutil_string_t *prefix; + + axis2_char_t *key; + + int ref; +}; + +AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL +axiom_namespace_create( + const axutil_env_t * env, + const axis2_char_t * uri, + const axis2_char_t * prefix) +{ + axiom_namespace_t *om_namespace = NULL; + + AXIS2_ENV_CHECK(env, NULL); + if(!uri) + { + uri = ""; + } + + om_namespace = (axiom_namespace_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_namespace_t)); + if(!om_namespace) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + om_namespace->ref = 0; + om_namespace->prefix = NULL; + om_namespace->uri = NULL; + om_namespace->key = NULL; + + om_namespace->uri = axutil_string_create(env, uri); + if(!om_namespace->uri) + { + AXIS2_FREE(env->allocator, om_namespace); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + if(prefix) + { + om_namespace->prefix = axutil_string_create(env, prefix); + if(!om_namespace->prefix) + { + AXIS2_FREE(env->allocator, om_namespace); + AXIS2_FREE(env->allocator, om_namespace->uri); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + } + + return om_namespace; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_namespace_free( + axiom_namespace_t * om_namespace, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(--om_namespace->ref > 0) + { + return; + } + + if(om_namespace->prefix) + { + axutil_string_free(om_namespace->prefix, env); + } + + if(om_namespace->uri) + { + axutil_string_free(om_namespace->uri, env); + } + + if(om_namespace->key) + { + AXIS2_FREE(env->allocator, om_namespace->key); + } + + AXIS2_FREE(env->allocator, om_namespace); + + return; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_namespace_equals( + axiom_namespace_t * om_namespace, + const axutil_env_t * env, + axiom_namespace_t * om_namespace1) +{ + int uris_differ = 0; + int prefixes_differ = 0; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_namespace, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_namespace1, AXIS2_FAILURE); + + if(!om_namespace || !om_namespace1) + { + return AXIS2_FALSE; + } + + if(om_namespace->uri && om_namespace1->uri) + { + uris_differ = axutil_strcmp(axutil_string_get_buffer(om_namespace->uri, env), + axutil_string_get_buffer(om_namespace1->uri, env)); + } + else + { + uris_differ = (om_namespace->uri || om_namespace1->uri); + } + + if(om_namespace->prefix && om_namespace1->prefix) + { + prefixes_differ = axutil_strcmp(axutil_string_get_buffer(om_namespace->prefix, env), + axutil_string_get_buffer(om_namespace1->prefix, env)); + } + else + { + prefixes_differ = (om_namespace->prefix || om_namespace1->prefix); + } + + return (!uris_differ && !prefixes_differ); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_namespace_serialize( + axiom_namespace_t * om_namespace, + const axutil_env_t * env, + axiom_output_t * om_output) +{ + int status = AXIS2_SUCCESS; + if(!om_namespace) + { + return AXIS2_FAILURE; + } + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); + + if(om_namespace->uri && NULL != om_namespace->prefix && axutil_strcmp(axutil_string_get_buffer( + om_namespace->prefix, env), "") != 0) + { + status = axiom_output_write(om_output, env, AXIOM_NAMESPACE, 2, axutil_string_get_buffer( + om_namespace-> prefix, env), axutil_string_get_buffer(om_namespace->uri, env)); + } + else if(om_namespace->uri) + { + status = axiom_output_write(om_output, env, AXIOM_NAMESPACE, 2, NULL, + axutil_string_get_buffer(om_namespace->uri, env)); + } + return status; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_namespace_get_uri( + axiom_namespace_t * om_namespace, + const axutil_env_t * env) +{ + if(om_namespace->uri) + { + return (axis2_char_t *)axutil_string_get_buffer(om_namespace->uri, env); + } + return NULL; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_namespace_get_prefix( + axiom_namespace_t * om_namespace, + const axutil_env_t * env) +{ + if(om_namespace->prefix) + { + return (axis2_char_t *)axutil_string_get_buffer(om_namespace->prefix, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL +axiom_namespace_clone( + axiom_namespace_t * om_namespace, + const axutil_env_t * env) +{ + axiom_namespace_t *cloned_ns = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + cloned_ns = axiom_namespace_create_str(env, om_namespace->uri, om_namespace->prefix); + if(cloned_ns) + { + return cloned_ns; + } + return NULL; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_namespace_to_string( + axiom_namespace_t * om_namespace, + const axutil_env_t * env) +{ + axis2_char_t *temp_str = NULL; + AXIS2_ENV_CHECK(env, NULL); + if(om_namespace->key) + { + AXIS2_FREE(env->allocator, om_namespace->key); + om_namespace->key = NULL; + } + if((om_namespace->uri) && (NULL != om_namespace->prefix)) + { + temp_str = axutil_stracat(env, axutil_string_get_buffer(om_namespace->uri, env), "|"); + om_namespace->key = axutil_stracat(env, temp_str, axutil_string_get_buffer( + om_namespace->prefix, env)); + if(temp_str) + { + AXIS2_FREE(env->allocator, temp_str); + temp_str = NULL; + } + } + else if((om_namespace->uri) && !(om_namespace->prefix)) + { + om_namespace->key = axutil_strdup(env, axutil_string_get_buffer(om_namespace->uri, env)); + if(!(om_namespace->key)) + { + return NULL; + } + } + return om_namespace->key; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_namespace_set_uri( + axiom_namespace_t * om_namespace, + const axutil_env_t * env, + const axis2_char_t * uri) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, uri, AXIS2_FAILURE); + + if(om_namespace->uri) + { + axutil_string_free(om_namespace->uri, env); + om_namespace->uri = NULL; + } + + om_namespace->uri = axutil_string_create(env, uri); + if(!(om_namespace->uri)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_namespace_increment_ref( + struct axiom_namespace * om_namespace, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + om_namespace->ref++; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL +axiom_namespace_create_str( + const axutil_env_t * env, + axutil_string_t * uri, + axutil_string_t * prefix) +{ + axiom_namespace_t *om_namespace = NULL; + + AXIS2_ENV_CHECK(env, NULL); + if(!uri) + { + uri = axutil_string_create(env, ""); + } + + om_namespace = (axiom_namespace_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_namespace_t)); + if(!om_namespace) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + om_namespace->ref = 0; + om_namespace->prefix = NULL; + om_namespace->uri = NULL; + om_namespace->key = NULL; + + om_namespace->uri = axutil_string_clone(uri, env); + if(!om_namespace->uri) + { + AXIS2_FREE(env->allocator, om_namespace); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + if(prefix) + { + om_namespace->prefix = axutil_string_clone(prefix, env); + if(!om_namespace->prefix) + { + AXIS2_FREE(env->allocator, om_namespace); + AXIS2_FREE(env->allocator, om_namespace->uri); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + } + + return om_namespace; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_namespace_set_uri_str( + axiom_namespace_t * om_namespace, + const axutil_env_t * env, + axutil_string_t * uri) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, uri, AXIS2_FAILURE); + + if(om_namespace->uri) + { + axutil_string_free(om_namespace->uri, env); + om_namespace->uri = NULL; + } + + om_namespace->uri = axutil_string_clone(uri, env); + if(!(om_namespace->uri)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axutil_string_t *AXIS2_CALL +axiom_namespace_get_uri_str( + axiom_namespace_t * om_namespace, + const axutil_env_t * env) +{ + return om_namespace->uri; +} + +AXIS2_EXTERN axutil_string_t *AXIS2_CALL +axiom_namespace_get_prefix_str( + axiom_namespace_t * om_namespace, + const axutil_env_t * env) +{ + return om_namespace->prefix; +} diff --git a/axiom/src/om/om_navigator.c b/axiom/src/om/om_navigator.c new file mode 100644 index 0000000..c0405b8 --- /dev/null +++ b/axiom/src/om/om_navigator.c @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +static void +axiom_navigator_update_next_node( + axiom_navigator_t * om_navigator, + const axutil_env_t * env); + +struct axiom_navigator +{ + axiom_node_t *node; + + axis2_bool_t visited; + + axiom_node_t *next; + + axiom_node_t *root; + + axis2_bool_t backtracked; + + axis2_bool_t end; + + axis2_bool_t start; + +}; + +AXIS2_EXTERN axiom_navigator_t *AXIS2_CALL +axiom_navigator_create( + const axutil_env_t * env, + axiom_node_t * om_node) +{ + axiom_navigator_t *om_navigator = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, om_node, NULL); + + om_navigator = (axiom_navigator_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_navigator_t)); + if(!om_navigator) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + om_navigator->node = NULL; + om_navigator->visited = AXIS2_FALSE; + om_navigator->next = NULL; + om_navigator->root = NULL; + om_navigator->end = AXIS2_FALSE; + om_navigator->start = AXIS2_TRUE; + om_navigator->backtracked = AXIS2_FALSE; + + om_navigator->next = om_node; + om_navigator->root = om_node; + + return om_navigator; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_navigator_free( + axiom_navigator_t * om_navigator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_FREE(env->allocator, om_navigator); + return; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_navigator_is_navigable( + axiom_navigator_t * om_navigator, + const axutil_env_t * env) +{ + if(AXIS2_TRUE == om_navigator->end) + { + return AXIS2_FALSE; + } + else + { + if(om_navigator->next) + { + return AXIS2_TRUE; + } + } + return AXIS2_FALSE; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_navigator_is_completed( + axiom_navigator_t * om_navigator, + const axutil_env_t * env) +{ + return om_navigator->end; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_navigator_visited( + axiom_navigator_t * om_navigator, + const axutil_env_t * env) +{ + return om_navigator->visited; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_navigator_next( + axiom_navigator_t * om_navigator, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + if(!om_navigator->next) + { + return NULL; + } + + om_navigator->node = om_navigator->next; + om_navigator->visited = om_navigator->backtracked; + om_navigator->backtracked = AXIS2_FALSE; + + axiom_navigator_update_next_node(om_navigator, env); + + /** set the starting and ending flags */ + if(om_navigator->root == om_navigator->next) + { + if(!(om_navigator->start)) + { + om_navigator->end = AXIS2_TRUE; + } + else + { + om_navigator->start = AXIS2_FALSE; + } + } + return om_navigator->node; +} + +/** this method encapsulate searching logic */ +static void +axiom_navigator_update_next_node( + axiom_navigator_t * om_navigator, + const axutil_env_t * env) +{ + if(!om_navigator) + { + return; + } + + if(!om_navigator->next) + { + return; + } + + if((AXIOM_ELEMENT == axiom_node_get_node_type(om_navigator->next, env)) + && !(om_navigator->visited)) + { + if(axiom_node_get_first_child(om_navigator->next, env)) + { + om_navigator->next = axiom_node_get_first_child(om_navigator->next, env); + } + else if(AXIS2_TRUE == axiom_node_is_complete(om_navigator->next, env)) + { + om_navigator->backtracked = AXIS2_TRUE; + } + else + { + om_navigator->next = NULL; + } + } + else + { + axiom_node_t *parent = NULL; + axiom_node_t *next_sibling = NULL; + + next_sibling = axiom_node_get_next_sibling(om_navigator->next, env); + + parent = axiom_node_get_parent(om_navigator->next, env); + + if(next_sibling) + { + om_navigator->next = next_sibling; + } + else if((parent) && axiom_node_is_complete(parent, env)) + { + om_navigator->next = parent; + om_navigator->backtracked = AXIS2_TRUE; + } + else + { + om_navigator->next = NULL; + } + } +} diff --git a/axiom/src/om/om_node.c b/axiom/src/om/om_node.c new file mode 100644 index 0000000..9b525aa --- /dev/null +++ b/axiom/src/om/om_node.c @@ -0,0 +1,1455 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axiom_node_internal.h" +#include "axiom_stax_builder_internal.h" +#include +#include +#include +#include +#include +#include +#include +#include + +struct axiom_node +{ + + /** document only available if build through builder */ + struct axiom_document *om_doc; + + axiom_stax_builder_t *builder; + + /** parent node */ + axiom_node_t *parent; + + /** previous sibling */ + axiom_node_t *prev_sibling; + + /** next sibling */ + axiom_node_t *next_sibling; + + /** first child */ + axiom_node_t *first_child; + + /** last child */ + axiom_node_t *last_child; + + /** node type, indicates the type stored in data_element */ + axiom_types_t node_type; + + /** done true means that this node is completely built , false otherwise */ + int done; + + /** instances of an om struct, whose type is defined by node type */ + void *data_element; + +}; + +static axiom_node_t * +axiom_node_detach_without_namespaces( + axiom_node_t * om_node, + const axutil_env_t * env); + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_node_create( + const axutil_env_t * env) +{ + axiom_node_t *node = NULL; + AXIS2_ENV_CHECK(env, NULL); + + node = (axiom_node_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_node_t)); + if(!node) + { + env->error->error_number = AXIS2_ERROR_NO_MEMORY; + return NULL; + } + node->first_child = NULL; + node->last_child = NULL; + node->next_sibling = NULL; + node->prev_sibling = NULL; + node->parent = NULL; + node->node_type = AXIOM_INVALID; + node->done = AXIS2_FALSE; + node->data_element = NULL; + node->om_doc = NULL; + node->builder = NULL; + return node; +} + +AXIS2_EXTERN axiom_node_t* AXIS2_CALL +axiom_node_create_from_buffer( + const axutil_env_t * env, + axis2_char_t *buffer) +{ + axiom_xml_reader_t *reader = NULL; + axiom_stax_builder_t *builder = NULL; + axiom_document_t *document = NULL; + axiom_node_t *om_node = NULL; + + reader = axiom_xml_reader_create_for_memory(env, buffer, axutil_strlen(buffer), "UTF-8", + AXIS2_XML_PARSER_TYPE_BUFFER); + + if(!reader) + { + return NULL; + } + + builder = axiom_stax_builder_create(env, reader); + + if(!builder) + { + return NULL; + } + document = axiom_stax_builder_get_document(builder, env); + if(!document) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Document is null for deserialization"); + return NULL; + } + + om_node = axiom_document_get_root_element(document, env); + + if(!om_node) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Root element of the document is not found"); + return NULL; + } + axiom_document_build_all(document, env); + + axiom_stax_builder_free_self(builder, env); + + return om_node; +} + +static void +axiom_node_free_detached_subtree( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + /* Free any child nodes first */ + if(om_node->first_child) + { + axiom_node_t *child_node = om_node->first_child, *next_sibling; + while(child_node) + { + next_sibling = child_node->next_sibling; + axiom_node_free_detached_subtree(child_node, env); + child_node = next_sibling; + } + } + + if(om_node->node_type == AXIOM_ELEMENT) + { + if(om_node->data_element) + { + axiom_element_free((axiom_element_t *)(om_node->data_element), env); + } + } + else if(om_node->node_type == AXIOM_COMMENT) + { + if(om_node->data_element) + { + axiom_comment_free((axiom_comment_t *)(om_node->data_element), env); + } + } + else if(om_node->node_type == AXIOM_DOCTYPE) + { + /*axiom_doctype_free((axiom_doctype_t*)(om_node->data_element), env); */ + } + else if(om_node->node_type == AXIOM_PROCESSING_INSTRUCTION) + { + if(om_node->data_element) + { + axiom_processing_instruction_free( + (axiom_processing_instruction_t *)(om_node->data_element), env); + } + } + else if(om_node->node_type == AXIOM_TEXT) + { + if(om_node->data_element) + { + axiom_text_free((axiom_text_t *)(om_node->data_element), env); + } + } + else if(om_node->node_type == AXIOM_DATA_SOURCE) + { + if(om_node->data_element) + { + axiom_data_source_free((axiom_data_source_t *)(om_node->data_element), env); + } + } + + AXIS2_FREE(env->allocator, om_node); + + return; +} + +/** + * This free function will free an om_element and all the children contained in it + * If the node is still attached to the tree, it will be detached first + */ +AXIS2_EXTERN void AXIS2_CALL +axiom_node_free_tree( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + if(!om_node) + { + return; + } + + /* Detach this node before freeing it and its subtree. */ + axiom_node_detach_without_namespaces(om_node, env); + + /* Free this node and its subtree */ + axiom_node_free_detached_subtree(om_node, env); + + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_add_child( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * child) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, child, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); + + if(child->parent) + { + child = axiom_node_detach(child, env); + } + + if(!(om_node->first_child)) + { + om_node->first_child = child; + } + else + { + axiom_node_t *last_sib = NULL; + last_sib = om_node->last_child; + if(last_sib) + { + last_sib->next_sibling = child; + child->prev_sibling = last_sib; + } + } + + child->parent = om_node; + om_node->last_child = child; + return AXIS2_SUCCESS; +} + +/** + * Detach the node without regard to any namespace references in the node or + * its children. + */ +static axiom_node_t * +axiom_node_detach_without_namespaces( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + axiom_node_t *parent = NULL; + + parent = om_node->parent; + if(!parent) + { + /* Node is already detached */ + om_node->builder = NULL; + return om_node; + } + + if(!om_node->prev_sibling) + { + parent->first_child = om_node->next_sibling; + } + else + { + axiom_node_t *prev_sib = NULL; + prev_sib = om_node->prev_sibling; + if(prev_sib) + { + prev_sib->next_sibling = om_node->next_sibling; + } + } + + if(om_node->next_sibling) + { + axiom_node_t *next_sibling = NULL; + next_sibling = om_node->next_sibling; + if(next_sibling) + { + next_sibling->prev_sibling = om_node->prev_sibling; + } + } + + if(parent->last_child && (parent->last_child == om_node)) + { + parent->last_child = om_node->prev_sibling; + } + + /* if the STAX builder's last node is what we are detaching, then we should adjust the + * last node if previous sibling is available, set that as the builder's last node. Else set the + * parent as the last node*/ + if(om_node->builder && (axiom_stax_builder_get_lastnode(om_node->builder, env) == om_node)) + { + axiom_node_t *lastnode = parent; + if(om_node->prev_sibling) + { + lastnode = om_node->prev_sibling; + } + axiom_stax_builder_set_lastnode(om_node->builder, env, lastnode); + } + + om_node->parent = NULL; + om_node->prev_sibling = NULL; + om_node->next_sibling = NULL; + om_node->builder = NULL; + return om_node; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_node_detach( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + axutil_hash_t *inscope_namespaces = NULL; + axiom_element_t *om_element = NULL; + + AXIS2_ENV_CHECK(env, NULL); + if(!om_node) + { + return NULL; + } + + /* If this is an element node, determine which namespaces are available to it + from its parent nodes. */ + if((om_node->node_type == AXIOM_ELEMENT) && (om_element = om_node->data_element)) + { + inscope_namespaces = axiom_element_gather_parent_namespaces(om_element, env, om_node); + } + + /* Detach this node from its parent. */ + om_node = axiom_node_detach_without_namespaces(om_node, env); + + /* If this is an element node, ensure that any namespaces available to it or its + children remain available after the detach. */ + if(om_node && inscope_namespaces) + { + axiom_element_redeclare_parent_namespaces(om_element, env, om_node, om_element, + inscope_namespaces); + } + + if(inscope_namespaces) + { + axutil_hash_free(inscope_namespaces, env); + } + + return om_node; +} + +/** + Internal function , only used in om and soap + not to be used by users + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_set_parent( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * parent) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + if(!om_node) + { + return AXIS2_FAILURE; + } + + AXIS2_PARAM_CHECK(env->error, parent, AXIS2_FAILURE); + + if(parent == om_node->parent) + { /* same parent already exist */ + return AXIS2_SUCCESS; + } + /* if a new parent is assigned in place of existing + one first the node should be detached + */ + if(om_node->parent) + { + om_node = axiom_node_detach_without_namespaces(om_node, env); + } + + om_node->parent = parent; + + return AXIS2_SUCCESS; +} + +/** + * This will insert a sibling just after the current information item + * @param node the node in consideration + * @param nodeto_insert the node that will be inserted + */ + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_insert_sibling_after( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * node_to_insert) +{ + axiom_node_t *next_sib = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + AXIS2_PARAM_CHECK(env->error, node_to_insert, AXIS2_FAILURE); + + if(!om_node->parent) + { + /* We shouldn't add a sibling because this node doesn't has a parent. + * This can be the root node of the tree*/ + return AXIS2_FAILURE; + } + + node_to_insert->parent = om_node->parent; + + node_to_insert->prev_sibling = om_node; + + next_sib = om_node->next_sibling; + + if(next_sib) + { + next_sib->prev_sibling = node_to_insert; + } + + node_to_insert->next_sibling = om_node->next_sibling; + + om_node->next_sibling = node_to_insert; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_insert_sibling_before( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * node_to_insert) +{ + axiom_node_t *prev_sibling = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, node_to_insert, AXIS2_FAILURE); + + if(!om_node->parent) + { + /* We shouldn't add a sibling because this node doesn't has a parent. + * This can be the root node of the tree*/ + return AXIS2_FAILURE; + } + + node_to_insert->parent = om_node->parent; + + node_to_insert->prev_sibling = om_node->prev_sibling; + + node_to_insert->next_sibling = om_node; + + prev_sibling = om_node->prev_sibling; + + if(!prev_sibling) + { + axiom_node_t *parent = om_node->parent; + parent->first_child = node_to_insert; + } + else + { + axiom_node_t *prev_sibling = om_node->prev_sibling; + if(prev_sibling) + { + prev_sibling->next_sibling = node_to_insert; + } + } + om_node->prev_sibling = node_to_insert; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_serialize( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_output_t * om_output) +{ + + int status = AXIS2_SUCCESS; + axiom_node_t *temp_node = NULL; + axiom_node_t *nodes[256]; + int count = 0; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(!om_node) + { + return AXIS2_SUCCESS; + } + + nodes[count++] = om_node; + + AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); + + do + { + + if(om_node->node_type == AXIOM_ELEMENT) + { + if(om_node->data_element) + { + status = axiom_element_serialize_start_part( + (axiom_element_t *)(om_node-> data_element), env, om_output, om_node); + } + if(status != AXIS2_SUCCESS) + { + return status; + } + } + else if(om_node->node_type == AXIOM_DATA_SOURCE) + { + if(om_node->data_element) + { + status = axiom_data_source_serialize( + (axiom_data_source_t *)(om_node->data_element), env, om_output); + } + if(status != AXIS2_SUCCESS) + { + return status; + } + } + else if(om_node->node_type == AXIOM_TEXT) + { + if(om_node->data_element) + { + status = axiom_text_serialize((axiom_text_t *)(om_node-> data_element), env, + om_output); + } + if(status != AXIS2_SUCCESS) + { + return status; + } + } + else if(om_node->node_type == AXIOM_COMMENT) + { + if(om_node->data_element) + { + status = axiom_comment_serialize((axiom_comment_t *)(om_node-> data_element), env, + om_output); + } + if(status != AXIS2_SUCCESS) + { + return status; + } + } + else if(om_node->node_type == AXIOM_DOCTYPE) + { + if(om_node->data_element) + { + status = axiom_doctype_serialize((axiom_doctype_t *)(om_node-> data_element), env, + om_output); + } + if(status != AXIS2_SUCCESS) + { + return status; + } + } + else if(om_node->node_type == AXIOM_PROCESSING_INSTRUCTION) + { + if(om_node->data_element) + { + status = axiom_processing_instruction_serialize( + (axiom_processing_instruction_t *)(om_node->data_element), env, om_output); + } + + if(status != AXIS2_SUCCESS) + { + return status; + } + } + + temp_node = axiom_node_get_first_child(om_node, env); + /* serialize children of this node */ + if(temp_node) + { + om_node = temp_node; + nodes[count++] = om_node; + } + else + { + if(om_node->node_type == AXIOM_ELEMENT) + { + if(om_node->data_element) + { + status = axiom_element_serialize_end_part( + (axiom_element_t *)(om_node-> data_element), env, om_output); + } + if(status != AXIS2_SUCCESS) + { + return status; + } + } + + temp_node = axiom_node_get_next_sibling(om_node, env); + if(temp_node) + { + om_node = temp_node; + nodes[count - 1] = om_node; + } + else + { + while(count > 1 && !temp_node) + { + count--; + om_node = nodes[count - 1]; + if(om_node->node_type == AXIOM_ELEMENT) + { + if(om_node->data_element) + { + status = axiom_element_serialize_end_part( + (axiom_element_t *)(om_node->data_element), env, om_output); + } + if(status != AXIS2_SUCCESS) + { + return status; + } + } + + temp_node = axiom_node_get_next_sibling(om_node, env); + } + + if(temp_node && count > 1) + { + om_node = temp_node; + nodes[count - 1] = om_node; + } + else + { + count--; + } + } + + } + } + while(count > 0); + + return status; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_serialize_sub_tree( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_output_t * om_output) +{ + + int status = AXIS2_SUCCESS; + axiom_node_t *temp_node = NULL; + axiom_node_t *nodes[256]; + int count = 0; + axutil_hash_t *namespaces = NULL; + axutil_hash_t *namespaces_from_parents = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(!om_node) + { + return AXIS2_SUCCESS; + } + + namespaces = axutil_hash_make(env); + if(!namespaces) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "hash for namespaces creation failed"); + return AXIS2_FAILURE; + } + + namespaces_from_parents = axutil_hash_make(env); + if(!namespaces_from_parents) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "hash for namespaces_from_parents creation failed"); + return AXIS2_FAILURE; + } + + nodes[count++] = om_node; + + AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); + + do + { + + if(om_node->node_type == AXIOM_ELEMENT) + { + if(om_node->data_element) + { + axutil_hash_t *temp_namespaces = NULL; + axutil_hash_t *temp_attributes = NULL; + axiom_namespace_t *namespace = NULL; + status = axiom_element_serialize_start_part( + (axiom_element_t *)(om_node-> data_element), env, om_output, om_node); + temp_namespaces = axiom_element_get_namespaces( + (axiom_element_t *)(om_node-> data_element), env); + if(temp_namespaces) + { + axutil_hash_t *new_hash = NULL; + new_hash = axutil_hash_overlay(temp_namespaces, env, namespaces); + if(namespaces) + axutil_hash_free(namespaces, env); + namespaces = new_hash; + } + namespace = axiom_element_get_namespace( + (axiom_element_t *)(om_node-> data_element), env, om_node); + if(namespace) + { + axiom_namespace_t *ns = NULL; + axis2_char_t *prefix = NULL; + prefix = axiom_namespace_get_prefix(namespace, env); + if(prefix) + { + ns = axutil_hash_get(namespaces, prefix, AXIS2_HASH_KEY_STRING); + if(!ns) + { + ns = axutil_hash_get(namespaces_from_parents, prefix, + AXIS2_HASH_KEY_STRING); + if(!ns) + { + axiom_namespace_serialize(namespace, env, om_output); + axutil_hash_set(namespaces_from_parents, prefix, + AXIS2_HASH_KEY_STRING, namespace); + } + } + } + } + + temp_attributes = axiom_element_get_all_attributes( + (axiom_element_t *)(om_node->data_element), env); + if(temp_attributes) + { + axutil_hash_index_t *hi; + void *val; + for(hi = axutil_hash_first(temp_attributes, env); hi; hi = axutil_hash_next( + env, hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + + if(val) + { + axiom_namespace_t *ns = NULL; + axis2_char_t *prefix = NULL; + + namespace + = axiom_attribute_get_namespace((axiom_attribute_t *)val, env); + + if(namespace) + { + prefix = axiom_namespace_get_prefix(namespace, env); + if(prefix) + { + ns = axutil_hash_get(namespaces, prefix, AXIS2_HASH_KEY_STRING); + if(!ns) + { + ns = axutil_hash_get(namespaces_from_parents, prefix, + AXIS2_HASH_KEY_STRING); + if(!ns) + { + axiom_namespace_serialize(namespace, env, om_output); + axutil_hash_set(namespaces_from_parents, prefix, + AXIS2_HASH_KEY_STRING, namespace); + } + } + } + } + } + else + { + status = AXIS2_FAILURE; + } + } + } + } + if(status != AXIS2_SUCCESS) + { + break; + } + } + else if(om_node->node_type == AXIOM_DATA_SOURCE) + { + if(om_node->data_element) + { + status = axiom_data_source_serialize( + (axiom_data_source_t *)(om_node->data_element), env, om_output); + } + if(status != AXIS2_SUCCESS) + { + break; + } + } + else if(om_node->node_type == AXIOM_TEXT) + { + if(om_node->data_element) + { + status = axiom_text_serialize((axiom_text_t *)(om_node-> data_element), env, + om_output); + } + if(status != AXIS2_SUCCESS) + { + break; + } + } + else if(om_node->node_type == AXIOM_COMMENT) + { + if(om_node->data_element) + { + status = axiom_comment_serialize((axiom_comment_t *)(om_node-> data_element), env, + om_output); + } + if(status != AXIS2_SUCCESS) + { + break; + } + } + else if(om_node->node_type == AXIOM_DOCTYPE) + { + if(om_node->data_element) + { + status = axiom_doctype_serialize((axiom_doctype_t *)(om_node-> data_element), env, + om_output); + } + if(status != AXIS2_SUCCESS) + { + break; + } + } + else if(om_node->node_type == AXIOM_PROCESSING_INSTRUCTION) + { + if(om_node->data_element) + { + status = axiom_processing_instruction_serialize( + (axiom_processing_instruction_t *)(om_node->data_element), env, om_output); + } + + if(status != AXIS2_SUCCESS) + { + break; + } + } + + temp_node = axiom_node_get_first_child(om_node, env); + /* serialize children of this node */ + if(temp_node) + { + om_node = temp_node; + nodes[count++] = om_node; + } + else + { + if(om_node->node_type == AXIOM_ELEMENT) + { + if(om_node->data_element) + { + + axutil_hash_t *temp_attributes = NULL; + axiom_namespace_t *namespace = NULL; + /* at the writing of end part all the namespaces declared + specially to that element should be cancelled */ + + /* first checking the element namespace */ + namespace = axiom_element_get_namespace( + (axiom_element_t *)(om_node-> data_element), env, om_node); + if(namespace) + { + axiom_namespace_t *ns = NULL; + axis2_char_t *prefix = NULL; + prefix = axiom_namespace_get_prefix(namespace, env); + if(prefix) + { + ns = axutil_hash_get(namespaces_from_parents, prefix, + AXIS2_HASH_KEY_STRING); + if(ns) + { + axutil_hash_set(namespaces_from_parents, prefix, + AXIS2_HASH_KEY_STRING, NULL); + } + } + } + + /* then checking the attribute namespaces */ + + temp_attributes = axiom_element_get_all_attributes( + (axiom_element_t *)(om_node->data_element), env); + if(temp_attributes) + { + axutil_hash_index_t *hi; + void *val; + for(hi = axutil_hash_first(temp_attributes, env); hi; hi + = axutil_hash_next(env, hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + + if(val) + { + axiom_namespace_t *ns = NULL; + axis2_char_t *prefix = NULL; + + namespace = axiom_attribute_get_namespace((axiom_attribute_t *)val, + env); + + if(namespace) + { + prefix = axiom_namespace_get_prefix(namespace, env); + if(prefix) + { + ns = axutil_hash_get(namespaces_from_parents, prefix, + AXIS2_HASH_KEY_STRING); + if(ns) + { + axutil_hash_set(namespaces_from_parents, prefix, + AXIS2_HASH_KEY_STRING, NULL); + } + } + } + } + } + } + + status = axiom_element_serialize_end_part( + (axiom_element_t *)(om_node-> data_element), env, om_output); + } + if(status != AXIS2_SUCCESS) + { + break; + } + } + /* We need to make make sure that om_node is not the root when we take the next sibling */ + if(count > 1) + { + temp_node = axiom_node_get_next_sibling(om_node, env); + } + if(temp_node) + { + om_node = temp_node; + nodes[count - 1] = om_node; + } + else + { + while(count > 1 && !temp_node) + { + count--; + om_node = nodes[count - 1]; + if(om_node->node_type == AXIOM_ELEMENT) + { + if(om_node->data_element) + { + axutil_hash_t *temp_attributes = NULL; + axiom_namespace_t *namespace = NULL; + + /* similar to the earlier time, whenever the ending is happened + * namespaces declared specially to that element should be cancelled */ + + /* first checking the element namespace */ + namespace = axiom_element_get_namespace( + (axiom_element_t *)(om_node-> data_element), env, om_node); + if(namespace) + { + axiom_namespace_t *ns = NULL; + axis2_char_t *prefix = NULL; + prefix = axiom_namespace_get_prefix(namespace, env); + if(prefix) + { + ns = axutil_hash_get(namespaces_from_parents, prefix, + AXIS2_HASH_KEY_STRING); + if(ns) + { + axutil_hash_set(namespaces_from_parents, prefix, + AXIS2_HASH_KEY_STRING, NULL); + } + } + } + + /* then checking the attribute namespaces */ + + temp_attributes = axiom_element_get_all_attributes( + (axiom_element_t *)(om_node->data_element), env); + if(temp_attributes) + { + axutil_hash_index_t *hi; + void *val; + for(hi = axutil_hash_first(temp_attributes, env); hi; hi + = axutil_hash_next(env, hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + + if(val) + { + axiom_namespace_t *ns = NULL; + axis2_char_t *prefix = NULL; + + namespace = axiom_attribute_get_namespace( + (axiom_attribute_t *)val, env); + + if(namespace) + { + prefix = axiom_namespace_get_prefix(namespace, env); + if(prefix) + { + ns = axutil_hash_get(namespaces_from_parents, + prefix, AXIS2_HASH_KEY_STRING); + if(ns) + { + axutil_hash_set(namespaces_from_parents, + prefix, AXIS2_HASH_KEY_STRING, NULL); + } + } + } + } + } + } + status = axiom_element_serialize_end_part( + (axiom_element_t *)(om_node->data_element), env, om_output); + } + if(status != AXIS2_SUCCESS) + { + break; + } + } + + temp_node = axiom_node_get_next_sibling(om_node, env); + } + + if(temp_node && count > 1) + { + om_node = temp_node; + nodes[count - 1] = om_node; + } + else + { + count--; + } + } + } + } + while(count > 0); + + axutil_hash_free(namespaces_from_parents, env); + axutil_hash_free(namespaces, env); + + return status; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_node_get_parent( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + return om_node->parent; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_node_get_first_child( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + int token = 0; + if(!om_node) + { + return NULL; + } + + /**********************************************************/ + while(!(om_node->first_child) && !(om_node->done) && om_node->builder) + { + token = axiom_stax_builder_next_with_token(om_node->builder, env); + if(token == -1) + { + return NULL; + } + } + + /**********************************************************/ + return om_node->first_child; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_node_get_first_element( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + int token = 0; + axiom_node_t *first_element; + if(!om_node) + { + return NULL; + } + + /**********************************************************/ + while(!(om_node->first_child) && !(om_node->done) && om_node->builder) + { + token = axiom_stax_builder_next_with_token(om_node->builder, env); + if(token == -1) + { + return NULL; + } + } + + /**********************************************************/ + first_element = om_node->first_child; + + while(first_element && (axiom_node_get_node_type(first_element, env) != AXIOM_ELEMENT)) + { + first_element = axiom_node_get_next_sibling(first_element, env); + } + + return first_element; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_node_get_last_child( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + return om_node->last_child; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_node_get_previous_sibling( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + return om_node->prev_sibling; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_node_get_next_sibling( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + int token = 0; + if(!om_node) + { + return NULL; + } + + while(!(om_node->next_sibling) && om_node->parent && om_node->builder + && !(axiom_node_is_complete(om_node->parent, env))) + { + token = axiom_stax_builder_next_with_token(om_node->builder, env); + if(token == -1) + { + return NULL; + } + } + + return om_node->next_sibling; +} + +AXIS2_EXTERN axiom_types_t AXIS2_CALL +axiom_node_get_node_type( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + return om_node->node_type; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_node_is_complete( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + return om_node->done; + +} + +AXIS2_EXTERN struct axiom_document *AXIS2_CALL +axiom_node_get_document( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + return om_node->om_doc; +} + +AXIS2_EXTERN void *AXIS2_CALL +axiom_node_get_data_element( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + return om_node->data_element; +} + +/** + internal function , not to be used by users + only sets the first_child link because this is needed by builder + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_set_first_child( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * first_child) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, first_child, AXIS2_FAILURE); + + /** set the parent */ + axiom_node_set_parent(first_child, env, om_node); + + om_node->first_child = first_child; + return AXIS2_SUCCESS; +} + +/** + internal function not to be used by users + only sets the previous sibling link as it is needed by builders + + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_set_previous_sibling( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * prev_sibling) +{ + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, prev_sibling, AXIS2_FAILURE); + + om_node->prev_sibling = prev_sibling; + return AXIS2_SUCCESS; +} + +/** + internal function, not to be used by users + only sets the next sibling link; + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_set_next_sibling( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_node_t * next_sibling) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, next_sibling, AXIS2_FAILURE); + om_node->next_sibling = next_sibling; + return AXIS2_SUCCESS; +} + +/** + internal function not to be used by users + sets the node type only used in soap and om + */ + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_set_node_type( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_types_t type) +{ + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); + om_node->node_type = type; + return AXIS2_SUCCESS; +} + +/** + internal function , not to be used by users + only used in om and soap + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_set_data_element( + axiom_node_t * om_node, + const axutil_env_t * env, + void *data_element) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, data_element, AXIS2_FAILURE); + om_node->data_element = data_element; + return AXIS2_SUCCESS; +} + +/** + internal function not to be used by users + only sets the build status + + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_set_complete( + axiom_node_t * om_node, + const axutil_env_t * env, + axis2_bool_t done) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); + om_node->done = done; + return AXIS2_SUCCESS; +} + +/** + internal function not to be used by users + only used by om builder + + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_set_document( + axiom_node_t * om_node, + const axutil_env_t * env, + struct axiom_document * om_doc) +{ + AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); + om_node->om_doc = om_doc; + return AXIS2_SUCCESS; +} + +/** + internal function only sets the builder reference , + should not be used by user + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_node_set_builder( + axiom_node_t * om_node, + const axutil_env_t * env, + axiom_stax_builder_t * builder) +{ + AXIS2_PARAM_CHECK(env->error, om_node, AXIS2_FAILURE); + om_node->builder = builder; + return AXIS2_SUCCESS; +} + +/** + * This is an internal function + */ +AXIS2_EXTERN axiom_stax_builder_t *AXIS2_CALL +axiom_node_get_builder( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + if(!om_node) + { + return NULL; + } + return om_node->builder; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_node_to_string( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + axiom_output_t *om_output = NULL; + axiom_xml_writer_t *xml_writer = NULL; + axis2_char_t *xml = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, om_node, NULL); + + xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0, + AXIS2_XML_PARSER_TYPE_BUFFER); + if(!xml_writer) + { + return NULL; + } + + om_output = axiom_output_create(env, xml_writer); + if(!om_output) + { + axiom_xml_writer_free(xml_writer, env); + return NULL; + } + status = axiom_node_serialize(om_node, env, om_output); + if(status == AXIS2_SUCCESS) + { + xml = axutil_strdup(env, (axis2_char_t *)axiom_xml_writer_get_xml(xml_writer, env)); + } + axiom_output_free(om_output, env); + return xml; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_node_sub_tree_to_string( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + axiom_output_t *om_output = NULL; + axiom_xml_writer_t *xml_writer = NULL; + axis2_char_t *xml = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, om_node, NULL); + + xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0, + AXIS2_XML_PARSER_TYPE_BUFFER); + if(!xml_writer) + { + return NULL; + } + + om_output = axiom_output_create(env, xml_writer); + if(!om_output) + { + axiom_xml_writer_free(xml_writer, env); + return NULL; + } + status = axiom_node_serialize_sub_tree(om_node, env, om_output); + if(status == AXIS2_SUCCESS) + { + xml = axutil_strdup(env, (axis2_char_t *)axiom_xml_writer_get_xml(xml_writer, env)); + } + axiom_output_free(om_output, env); + return xml; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_node_to_string_non_optimized( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + axiom_output_t *om_output = NULL; + axiom_xml_writer_t *xml_writer = NULL; + axis2_char_t *xml = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, om_node, NULL); + + xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0, + AXIS2_XML_PARSER_TYPE_BUFFER); + if(!xml_writer) + { + return NULL; + } + + om_output = axiom_output_create(env, xml_writer); + if(!om_output) + { + axiom_xml_writer_free(xml_writer, env); + return NULL; + } + /*This is where we set the output to be non-optimized*/ + axiom_output_set_do_optimize(om_output, env, AXIS2_FALSE); + status = axiom_node_serialize(om_node, env, om_output); + if(status == AXIS2_SUCCESS) + { + xml = axutil_strdup(env, (axis2_char_t *)axiom_xml_writer_get_xml(xml_writer, env)); + } + axiom_output_free(om_output, env); + return xml; +} + diff --git a/axiom/src/om/om_output.c b/axiom/src/om/om_output.c new file mode 100644 index 0000000..893f426 --- /dev/null +++ b/axiom/src/om/om_output.c @@ -0,0 +1,638 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define AXIS2_DEFAULT_CHAR_SET_ENCODING "UTF-8" + +/** also defined in axiom_soap.h */ + +/** max args for om_output_write function */ +#define MAX_ARGS 4 + +struct axiom_output +{ + + /** axiom_xml_writer. any xml writer which + implemet axiom_xml_writer.h interface */ + axiom_xml_writer_t *xml_writer; + + axis2_bool_t do_optimize; + + axis2_char_t *mime_boundary; + + axis2_char_t *root_content_id; + + int next_id; + + axis2_char_t *next_content_id; + + axis2_bool_t is_soap11; + + axis2_char_t *char_set_encoding; + + axis2_char_t *xml_version; + + axis2_bool_t ignore_xml_declaration; + + axutil_array_list_t *binary_node_list; + + axis2_char_t *mime_boundry; + + axis2_char_t *content_type; + + axutil_array_list_t *mime_parts; + +}; + +AXIS2_EXTERN axiom_output_t *AXIS2_CALL +axiom_output_create( + const axutil_env_t * env, + axiom_xml_writer_t * xml_writer) +{ + axiom_output_t *om_output = NULL; + AXIS2_ENV_CHECK(env, NULL); + + om_output = (axiom_output_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_output_t)); + + if(!om_output) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + om_output->xml_writer = xml_writer; + om_output->do_optimize = AXIS2_TRUE; + om_output->mime_boundary = NULL; + om_output->root_content_id = NULL; + om_output->next_content_id = NULL; + om_output->next_id = 0; + om_output->is_soap11 = AXIS2_TRUE; + om_output->char_set_encoding = AXIS2_DEFAULT_CHAR_SET_ENCODING; + om_output->xml_version = NULL; + om_output->ignore_xml_declaration = AXIS2_TRUE; + om_output->binary_node_list = NULL; + om_output->mime_boundry = NULL; + om_output->content_type = NULL; + om_output->mime_parts = NULL; + + return om_output; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_output_free( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + + if(om_output->xml_version) + { + AXIS2_FREE(env->allocator, om_output->xml_version); + } + if(om_output->mime_boundary) + { + AXIS2_FREE(env->allocator, om_output->mime_boundary); + } + if(om_output->next_content_id) + { + AXIS2_FREE(env->allocator, om_output->next_content_id); + } + if(om_output->root_content_id) + { + AXIS2_FREE(env->allocator, om_output->root_content_id); + } + + if(om_output->xml_writer) + { + axiom_xml_writer_free(om_output->xml_writer, env); + } + + if(om_output->binary_node_list) + { + axutil_array_list_free(om_output->binary_node_list, env); + } + + if(om_output->content_type) + { + AXIS2_FREE(env->allocator, om_output->content_type); + } + + AXIS2_FREE(env->allocator, om_output); + return; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_output_is_soap11( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return om_output->is_soap11; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_output_is_ignore_xml_declaration( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return om_output->ignore_xml_declaration; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_output_set_ignore_xml_declaration( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_bool_t ignore_xml_dec) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + om_output->ignore_xml_declaration = ignore_xml_dec; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_output_set_soap11( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_bool_t soap11) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + om_output->is_soap11 = soap11; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_output_set_xml_version( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_char_t * xml_version) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + AXIS2_PARAM_CHECK(env->error, xml_version, AXIS2_FAILURE); + + if(om_output->xml_version) + { + AXIS2_FREE(env->allocator, om_output->xml_version); + om_output->xml_version = NULL; + } + + om_output->xml_version = axutil_strdup(env, xml_version); + if(!om_output->xml_version) + { + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_output_get_xml_version( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + return om_output->xml_version; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_output_set_char_set_encoding( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_char_t * char_set_encoding) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + om_output->char_set_encoding = char_set_encoding; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_output_get_char_set_encoding( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + return om_output->char_set_encoding; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_output_set_do_optimize( + axiom_output_t * om_output, + const axutil_env_t * env, + axis2_bool_t optimize) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + om_output->do_optimize = optimize; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL +axiom_output_get_xml_writer( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + return om_output->xml_writer; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_output_is_optimized( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + return om_output->do_optimize; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axiom_output_get_content_type( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + const axis2_char_t *soap_content_type = NULL; + if(AXIS2_TRUE == om_output->do_optimize) + { + if(AXIS2_TRUE == om_output->is_soap11) + { + soap_content_type = AXIOM_SOAP11_CONTENT_TYPE; + } + else + { + soap_content_type = AXIOM_SOAP12_CONTENT_TYPE; + } + if(om_output->content_type) + { + AXIS2_FREE(env->allocator, om_output->content_type); + om_output->content_type = NULL; + } + + om_output->content_type = (axis2_char_t *)axiom_mime_part_get_content_type_for_mime(env, + om_output->mime_boundry, om_output->root_content_id, om_output->char_set_encoding, + soap_content_type); + return om_output->content_type; + } + else if(AXIS2_TRUE == om_output->is_soap11) + { + return AXIOM_SOAP11_CONTENT_TYPE; + } + return AXIOM_SOAP12_CONTENT_TYPE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_output_write_optimized( + axiom_output_t * om_output, + const axutil_env_t * env, + axiom_text_t * om_text) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + if(om_output->binary_node_list) + { + axutil_array_list_add(om_output->binary_node_list, env, om_text); + } + else + { + om_output->binary_node_list = axutil_array_list_create(env, 5); + if(!(om_output->binary_node_list)) + { + return AXIS2_FAILURE; + } + axutil_array_list_add(om_output->binary_node_list, env, om_text); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_output_get_next_content_id( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + axis2_char_t *uuid = NULL; + axis2_char_t *temp_str = NULL; + axis2_char_t *temp_str1 = NULL; + axis2_char_t id[256]; + om_output->next_id++; + + /** free existing id */ + if(om_output->next_content_id) + { + AXIS2_FREE(env->allocator, om_output->next_content_id); + om_output->next_content_id = NULL; + } + + uuid = axutil_uuid_gen(env); + if(!uuid) + { + return NULL; + } + + sprintf(id, "%d", om_output->next_id); + + temp_str = axutil_stracat(env, id, "."); + temp_str1 = axutil_stracat(env, temp_str, uuid); + om_output->next_content_id = axutil_stracat(env, temp_str1, "@apache.org"); + if(temp_str) + { + AXIS2_FREE(env->allocator, temp_str); + temp_str = NULL; + } + if(temp_str1) + { + AXIS2_FREE(env->allocator, temp_str1); + temp_str1 = NULL; + } + if(uuid) + { + AXIS2_FREE(env->allocator, uuid); + uuid = NULL; + } + return om_output->next_content_id; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_output_get_root_content_id( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + axis2_char_t *temp_str = NULL; + axis2_char_t *uuid = NULL; + + if(!om_output->root_content_id) + { + uuid = axutil_uuid_gen(env); + + temp_str = axutil_stracat(env, "0.", uuid); + + om_output->root_content_id = axutil_stracat(env, temp_str, "@apache.org"); + + if(temp_str) + { + AXIS2_FREE(env->allocator, temp_str); + temp_str = NULL; + } + if(uuid) + { + AXIS2_FREE(env->allocator, uuid); + uuid = NULL; + } + } + + return om_output->root_content_id; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_output_get_mime_boundry( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + axis2_char_t *uuid = NULL; + if(!om_output->mime_boundary) + { + uuid = axutil_uuid_gen(env); + + om_output->mime_boundary = axutil_stracat(env, "MIMEBoundary", uuid); + if(uuid) + { + AXIS2_FREE(env->allocator, uuid); + uuid = NULL; + } + } + return om_output->mime_boundary; +} + +/******************************************************************************/ + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_output_write( + axiom_output_t * om_output, + const axutil_env_t * env, + axiom_types_t type, + int no_of_args, + ...) +{ + int status = AXIS2_SUCCESS; + axis2_char_t *args_list[MAX_ARGS]; + int i = 0; + va_list ap; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + va_start(ap, no_of_args); + for(i = 0; i < no_of_args; i++) + { + args_list[i] = va_arg(ap, axis2_char_t *); + } + va_end(ap); + + if(type == AXIOM_ELEMENT) + { + if(no_of_args == 0) + { + status = axiom_xml_writer_write_end_element(om_output->xml_writer, env); + } + else if(no_of_args == 1) + { + status = axiom_xml_writer_write_start_element(om_output->xml_writer, env, args_list[0]); + } + else if(no_of_args == 2) + { + status = axiom_xml_writer_write_start_element_with_namespace( + om_output->xml_writer, env, args_list[0], args_list[1]); + } + else if(no_of_args == 3) + { + status = axiom_xml_writer_write_start_element_with_namespace_prefix( + om_output->xml_writer, env, args_list[0], args_list[1], args_list[2]); + } + else if(no_of_args == 4) + { + if(!args_list[0]) + { + status = AXIS2_FAILURE; + } + else if(!args_list[1]) + { + status = axiom_xml_writer_write_empty_element( + om_output->xml_writer, env,args_list[0]); + } + else if(!args_list[2]) + { + status = axiom_xml_writer_write_empty_element_with_namespace( + om_output->xml_writer, env, args_list[0], args_list[1]); + } + else + { + status = axiom_xml_writer_write_empty_element_with_namespace_prefix( + om_output->xml_writer, env, args_list[0], args_list[1], args_list[2]); + } + } + } + else if(type == AXIOM_DATA_SOURCE) + { + status = axiom_xml_writer_write_raw(om_output->xml_writer, env, args_list[0]); + } + else if(type == AXIOM_ATTRIBUTE) + { + if(no_of_args == 2) + { + status = axiom_xml_writer_write_attribute( + om_output->xml_writer, env, args_list[0], args_list[1]); + } + else if(no_of_args == 3) + { + status = axiom_xml_writer_write_attribute_with_namespace( + om_output-> xml_writer, env, args_list[0], args_list[1], args_list[2]); + } + else if(no_of_args == 4) + { + status = axiom_xml_writer_write_attribute_with_namespace_prefix( + om_output->xml_writer, env, args_list[0], args_list[1], args_list[2], args_list[3]); + } + } + else if(type == AXIOM_NAMESPACE) + { + /* If the namespace prefix is xml, it must be the pre-defined xml + namespace. Although the XML spec allows it to be declared + explicitly, this is superfluous and not accepted by all xml + parsers. */ + if((!args_list[0]) || (strcmp(args_list[0], "xml") != 0)) + { + status = axiom_xml_writer_write_namespace( + om_output->xml_writer, env, args_list[0], args_list[1]); + } + } + else if(type == AXIOM_TEXT) + { + status = axiom_xml_writer_write_characters(om_output->xml_writer, env, args_list[0]); + } + else if(type == AXIOM_COMMENT) + { + status = axiom_xml_writer_write_comment(om_output->xml_writer, env, args_list[0]); + } + else if(type == AXIOM_PROCESSING_INSTRUCTION) + { + if(no_of_args == 1) + { + status = axiom_xml_writer_write_processing_instruction( + om_output-> xml_writer, env, args_list[0]); + } + else if(no_of_args == 2) + { + status = axiom_xml_writer_write_processing_instruction_data( + om_output-> xml_writer, env, args_list[0], args_list[1]); + } + } + else if(type == AXIOM_DOCTYPE) + { + status = axiom_xml_writer_write_dtd(om_output->xml_writer, env, args_list[0]); + } + + if(status == AXIS2_SUCCESS) + { + return AXIS2_SUCCESS; + } + else + return AXIS2_FAILURE; +} + +axis2_status_t AXIS2_CALL +axiom_output_write_xml_version_encoding( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + if(!om_output->xml_version) + { + axiom_output_set_xml_version(om_output, env, "1.0"); + } + if(!om_output->char_set_encoding) + { + axiom_output_set_char_set_encoding(om_output, env, "UTF-8"); + } + return axiom_xml_writer_write_start_document_with_version_encoding(om_output-> xml_writer, env, + om_output-> xml_version, om_output-> char_set_encoding); + +} + +/* This method will be called from transport. After this method each and every + * message part needs to be send are stored in an arraylits. So the transport + * sender should correctly figure out how to send from the given information. + */ + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_output_flush( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + const axis2_char_t *soap_content_type = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + if(om_output->do_optimize) + { + axis2_char_t *root_content_id = NULL; + axis2_char_t *buffer = NULL; + + /* Extracting the soap part */ + + buffer = axiom_xml_writer_get_xml(om_output->xml_writer, env); + if(om_output->is_soap11) + { + soap_content_type = AXIOM_SOAP11_CONTENT_TYPE; + } + else + { + soap_content_type = AXIOM_SOAP12_CONTENT_TYPE; + } + + /* The created mime_boundary for this soap message */ + + om_output->mime_boundry = axiom_output_get_mime_boundry(om_output, env); + + /* This is also created for attachments*/ + root_content_id = axiom_output_get_root_content_id(om_output, env); + + /* different parts of the message is added according to their order + * to an arraylist */ + om_output->mime_parts = axiom_mime_part_create_part_list(env, buffer, + om_output->binary_node_list, om_output->mime_boundry, om_output->root_content_id, + om_output->char_set_encoding, soap_content_type); + + if(om_output->mime_parts) + { + return AXIS2_SUCCESS; + } + else + { + return AXIS2_FAILURE; + } + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axiom_output_get_mime_parts( + axiom_output_t * om_output, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return om_output->mime_parts; +} + diff --git a/axiom/src/om/om_processing_instruction.c b/axiom/src/om/om_processing_instruction.c new file mode 100644 index 0000000..5be688b --- /dev/null +++ b/axiom/src/om/om_processing_instruction.c @@ -0,0 +1,187 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "axiom_node_internal.h" + +struct axiom_processing_instruction +{ + + /** processing instruction target */ + axis2_char_t *target; + + /** processing instruction value */ + axis2_char_t *value; +}; + +AXIS2_EXTERN axiom_processing_instruction_t *AXIS2_CALL +axiom_processing_instruction_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * target, + const axis2_char_t * value, + axiom_node_t ** node) +{ + axiom_processing_instruction_t *processing_instruction = NULL; + AXIS2_ENV_CHECK(env, NULL); + + if(!node || !target || !value) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Node or target or value is NULL"); + return NULL; + } + + *node = axiom_node_create(env); + + if(!*node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + processing_instruction = (axiom_processing_instruction_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_processing_instruction_t)); + + if(!processing_instruction) + { + AXIS2_FREE(env->allocator, (*node)); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + processing_instruction->value = NULL; + + if(value) + { + processing_instruction->value = (axis2_char_t *)axutil_strdup(env, value); + if(!processing_instruction->value) + { + AXIS2_FREE(env->allocator, processing_instruction); + AXIS2_FREE(env->allocator, *node); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + } + + processing_instruction->target = NULL; + + if(target) + { + processing_instruction->target = (axis2_char_t *)axutil_strdup(env, target); + if(!processing_instruction->target) + { + AXIS2_FREE(env->allocator, processing_instruction->value); + AXIS2_FREE(env->allocator, processing_instruction); + AXIS2_FREE(env->allocator, *node); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + } + axiom_node_set_data_element(*node, env, processing_instruction); + axiom_node_set_node_type(*node, env, AXIOM_PROCESSING_INSTRUCTION); + if(parent) + { + axiom_node_add_child(parent, env, (*node)); + } + + return processing_instruction; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_processing_instruction_free( + axiom_processing_instruction_t * om_pi, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + + if(om_pi->value) + { + AXIS2_FREE(env->allocator, om_pi->value); + om_pi->value = NULL; + } + + if(om_pi->target) + { + AXIS2_FREE(env->allocator, om_pi->target); + om_pi->target = NULL; + } + + AXIS2_FREE(env->allocator, om_pi); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_processing_instruction_set_value( + axiom_processing_instruction_t * om_pi, + const axutil_env_t * env, + const axis2_char_t * value) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + om_pi->value = (axis2_char_t *)axutil_strdup(env, value); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_processing_instruction_set_target( + axiom_processing_instruction_t * om_pi, + const axutil_env_t * env, + const axis2_char_t * target) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, target, AXIS2_FAILURE); + om_pi->target = (axis2_char_t *)axutil_strdup(env, target); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_processing_instruction_get_value( + axiom_processing_instruction_t * om_pi, + const axutil_env_t * env) +{ + return om_pi->value; +} +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_processing_instruction_get_target( + axiom_processing_instruction_t * om_pi, + const axutil_env_t * env) +{ + return om_pi->target; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_processing_instruction_serialize( + axiom_processing_instruction_t * om_pi, + const axutil_env_t * env, + axiom_output_t * om_output) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); + + if(om_pi->target && om_pi->value) + { + return axiom_output_write(om_output, env, AXIOM_PROCESSING_INSTRUCTION, 2, om_pi->target, + om_pi->value); + } + else if(om_pi->target) + { + return axiom_output_write(om_output, env, AXIOM_PROCESSING_INSTRUCTION, 2, om_pi->target, + om_pi->value); + } + return AXIS2_FAILURE; +} diff --git a/axiom/src/om/om_stax_builder.c b/axiom/src/om/om_stax_builder.c new file mode 100644 index 0000000..399a711 --- /dev/null +++ b/axiom/src/om/om_stax_builder.c @@ -0,0 +1,1072 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "axiom_node_internal.h" +#include "axiom_stax_builder_internal.h" + +struct axiom_stax_builder +{ + + /** pull parser instance used by the om_builder */ + axiom_xml_reader_t *parser; + + /** last node the om_builder found */ + axiom_node_t *lastnode; + + axiom_node_t *root_node; + + /** document associated with the om_builder */ + axiom_document_t *document; + + /** done building the document? */ + axis2_bool_t done; + + /** parser was accessed? */ + axis2_bool_t parser_accessed; + + /** caching enabled? */ + axis2_bool_t cache; + + /** current event */ + int current_event; + /** Indicate the current element level. */ + int element_level; + axutil_hash_t *declared_namespaces; +}; + +AXIS2_EXTERN axiom_stax_builder_t *AXIS2_CALL +axiom_stax_builder_create( + const axutil_env_t * env, + axiom_xml_reader_t * parser) +{ + axiom_stax_builder_t *om_builder = NULL; + AXIS2_PARAM_CHECK(env->error, parser, NULL); + + om_builder = (axiom_stax_builder_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_stax_builder_t)); + if(!om_builder) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + om_builder->cache = AXIS2_TRUE; + om_builder->parser_accessed = AXIS2_FALSE; + om_builder->done = AXIS2_FALSE; + om_builder->lastnode = NULL; + om_builder->document = NULL; + om_builder->parser = parser; + om_builder->current_event = -1; + om_builder->root_node = NULL; + om_builder->element_level = 0; + om_builder->declared_namespaces = axutil_hash_make(env); + om_builder->document = axiom_document_create(env, NULL, om_builder); + if(!om_builder->document) + { + AXIS2_FREE(env->allocator, om_builder); + return NULL; + } + + return om_builder; +} + +static axis2_status_t +axiom_stax_builder_process_attributes( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env, + axiom_node_t * element_node) +{ + int i = 0; + int attribute_count; + axiom_element_t *om_ele = NULL; + + om_ele = (axiom_element_t *)axiom_node_get_data_element(element_node, env); + attribute_count = axiom_xml_reader_get_attribute_count(om_builder->parser, env); + for(i = 1; i <= attribute_count; ++i) + { + axiom_namespace_t *ns = NULL; + axis2_char_t *uri = NULL; + axis2_char_t *prefix = NULL; + axis2_char_t *attr_name = NULL; + axis2_char_t *attr_value = NULL; + + uri = axiom_xml_reader_get_attribute_namespace_by_number(om_builder-> parser, env, i); + prefix = axiom_xml_reader_get_attribute_prefix_by_number(om_builder->parser, env, i); + if(uri && (axutil_strcmp(uri, "") != 0)) + { + ns = axiom_element_find_namespace(om_ele, env, element_node, uri, prefix); + if(!ns) + { + /* if namespace is not defined yet, create it */ + ns = axiom_namespace_create(env, uri, prefix); + } + } + if(uri) + { + axiom_xml_reader_xml_free(om_builder->parser, env, uri); + } + if(prefix) + { + axiom_xml_reader_xml_free(om_builder->parser, env, prefix); + } + + attr_name = axiom_xml_reader_get_attribute_name_by_number(om_builder->parser, env, i); + attr_value = axiom_xml_reader_get_attribute_value_by_number(om_builder->parser, env, i); + + if(attr_name) + { + axutil_string_t *attr_name_str = NULL; + axutil_string_t *attr_value_str = NULL; + axiom_attribute_t *attribute = NULL; + +#ifdef AXIS2_LIBXML2_ENABLED + attr_name_str = axutil_string_create(env, attr_name); + attr_value_str = axutil_string_create(env, attr_value); + axiom_xml_reader_xml_free(om_builder->parser, env, attr_name); + axiom_xml_reader_xml_free(om_builder->parser, env, attr_value); +#else + attr_name_str = axutil_string_create_assume_ownership(env, &attr_name); + attr_value_str = axutil_string_create_assume_ownership(env, &attr_value); +#endif + + attribute = axiom_attribute_create_str(env, attr_name_str, attr_value_str, ns); + axutil_string_free(attr_name_str, env); + axutil_string_free(attr_value_str, env); + + if(!attribute) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create attribute"); + return AXIS2_FAILURE; + } + if(axiom_element_add_attribute(om_ele, env, attribute, element_node) != AXIS2_SUCCESS) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot add attribute to element"); + return AXIS2_FAILURE; + } + } + } + return AXIS2_SUCCESS; +} + +static axiom_node_t * +axiom_stax_builder_create_om_text( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + axis2_char_t *temp_value = NULL; + axutil_string_t *temp_value_str = NULL; + axiom_node_t *node = NULL; + axiom_node_t *parent = om_builder->lastnode; + + if(!parent) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_BUILDER_STATE_LAST_NODE_NULL, AXIS2_FAILURE); + return NULL; + } + + temp_value = axiom_xml_reader_get_value(om_builder->parser, env); + if(!temp_value) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_XML_READER_VALUE_NULL, AXIS2_FAILURE); + return NULL; + } + +#ifdef AXIS2_LIBXML2_ENABLED + temp_value_str = axutil_string_create(env, temp_value); + axiom_xml_reader_xml_free(om_builder->parser, env, temp_value); +#else + temp_value_str = axutil_string_create_assume_ownership(env, &temp_value); +#endif + + if(!temp_value_str) + { + /* axutil_string_create will have set an error number */ + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create OM Text value"); + return NULL; + } + + if(axiom_node_is_complete(parent, env)) + { + parent = axiom_node_get_parent(om_builder->lastnode, env); + } + + axiom_text_create_str(env, parent, temp_value_str, &node); + axutil_string_free(temp_value_str, env); + + if(node) + { + axiom_node_set_complete(node, env, AXIS2_TRUE); + om_builder->lastnode = node; + } + + return node; +} + +static axis2_status_t +axiom_stax_builder_process_namespaces( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env, + axiom_node_t * node, + int is_soap_element) +{ + axis2_status_t status = AXIS2_SUCCESS; + int namespace_count = 0; + axiom_namespace_t *om_ns = NULL; + axiom_element_t *om_ele = NULL; + + /* temp values */ + axis2_char_t *tmp_prefix = NULL; + axis2_char_t *tmp_ns_prefix = NULL; + axis2_char_t *tmp_ns_uri = NULL; + axutil_string_t *tmp_ns_prefix_str = NULL; + axutil_string_t *tmp_ns_uri_str = NULL; + + int i = 0; + om_ele = (axiom_element_t *)axiom_node_get_data_element(node, env); + + namespace_count = axiom_xml_reader_get_namespace_count(om_builder->parser, env); + for(i = 1; i <= namespace_count; ++i) + { + tmp_ns_prefix = axiom_xml_reader_get_namespace_prefix_by_number(om_builder->parser, env, i); + tmp_ns_uri = axiom_xml_reader_get_namespace_uri_by_number(om_builder->parser, env, i); + +#ifdef AXIS2_LIBXML2_ENABLED + tmp_ns_prefix_str = axutil_string_create(env, tmp_ns_prefix); + tmp_ns_uri_str = axutil_string_create(env, tmp_ns_uri); +#else + tmp_ns_prefix_str = axutil_string_create_assume_ownership(env, &tmp_ns_prefix); + tmp_ns_uri_str = axutil_string_create_assume_ownership(env, &tmp_ns_uri); +#endif + + if(!tmp_ns_prefix || axutil_strcmp(tmp_ns_prefix, "xmlns") == 0) + { + /* default namespace case. !temp_ns_prefix is for guththila */ + + if(tmp_ns_prefix_str) + { + axutil_string_free(tmp_ns_prefix_str, env); + } + + tmp_ns_prefix_str = axutil_string_create(env, ""); + om_ns = axiom_namespace_create_str(env, tmp_ns_uri_str, tmp_ns_prefix_str); + if(!om_ns) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create namespace"); + return AXIS2_FAILURE; + } + + status = axiom_element_declare_namespace(om_ele, env, node, om_ns); + if(!status) + { + axiom_namespace_free(om_ns, env); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error when declaring namespace"); + return AXIS2_FAILURE; + } + } + else + { + axis2_char_t *prefix = NULL; + om_ns = axiom_namespace_create_str(env, tmp_ns_uri_str, tmp_ns_prefix_str); + if(!om_ns) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create namespace"); + return AXIS2_FAILURE; + } + + status = axiom_element_declare_namespace_assume_param_ownership(om_ele, env, om_ns); + prefix = axiom_namespace_get_prefix(om_ns, env); + axutil_hash_set(om_builder->declared_namespaces, prefix, AXIS2_HASH_KEY_STRING, om_ns); + } + + axutil_string_free(tmp_ns_uri_str, env); + axutil_string_free(tmp_ns_prefix_str, env); +#ifdef AXIS2_LIBXML2_ENABLED + axiom_xml_reader_xml_free(om_builder->parser, env, tmp_ns_uri); + axiom_xml_reader_xml_free(om_builder->parser, env, tmp_ns_prefix); +#endif + } + + /* set own namespace */ + tmp_prefix = axiom_xml_reader_get_prefix(om_builder->parser, env); + if(tmp_prefix) + { + om_ns = axutil_hash_get(om_builder->declared_namespaces, tmp_prefix, AXIS2_HASH_KEY_STRING); + + if(om_ns) + { + axiom_element_set_namespace_assume_param_ownership(om_ele, env, om_ns); + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_INVALID_DOCUMENT_STATE_UNDEFINED_NAMESPACE, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error when setting namespace"); + return AXIS2_FAILURE; + } + + axiom_xml_reader_xml_free(om_builder->parser, env, tmp_prefix); + } + + return status; +} + +static axiom_node_t * +axiom_stax_builder_create_om_element( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env, + axis2_bool_t is_empty) +{ + axiom_node_t *element_node = NULL; + axiom_element_t *om_ele = NULL; + axis2_char_t *temp_localname = NULL; + axutil_string_t *temp_localname_str = NULL; + + temp_localname = axiom_xml_reader_get_name(om_builder->parser, env); + + if(!temp_localname) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_XML_READER_ELEMENT_NULL, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot find name of the element"); + return NULL; + } + +#ifdef AXIS2_LIBXML2_ENABLED + temp_localname_str = axutil_string_create(env, temp_localname); + axiom_xml_reader_xml_free(om_builder->parser, env, temp_localname); +#else + temp_localname_str = axutil_string_create_assume_ownership(env, &temp_localname); +#endif + + om_builder->element_level++; + + if(!om_builder->lastnode) + { + /* since last node is null, this should be the root node */ + om_ele = axiom_element_create_str(env, NULL, temp_localname_str, NULL, &element_node); + om_builder->root_node = element_node; + if(om_builder->document) + { + axiom_document_set_root_element(om_builder->document, env, element_node); + } + } + else if(axiom_node_is_complete(om_builder->lastnode, env)) + { + /* previous node building is finished. So, this node should be a sibling of previous node */ + axiom_node_t *parent = axiom_node_get_parent(om_builder->lastnode, env); + om_ele = axiom_element_create_str(env, parent, temp_localname_str, NULL, &element_node); + if(element_node) + { + axiom_node_set_next_sibling(om_builder->lastnode, env, element_node); + axiom_node_set_previous_sibling(element_node, env, om_builder->lastnode); + } + } + else + { + /* previous node building is not finished. This should be first child of previous node */ + om_ele = axiom_element_create_str( + env, om_builder->lastnode, temp_localname_str, NULL, &element_node); + if(element_node) + { + axiom_node_set_first_child(om_builder->lastnode, env, element_node); + axiom_node_set_parent(element_node, env, om_builder->lastnode); + } + } + + axutil_string_free(temp_localname_str, env); + + if((!om_ele) || (!element_node)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create axiom element"); + return NULL; + } + + axiom_node_set_builder(element_node, env, om_builder); + axiom_node_set_document(element_node, env, om_builder->document); + axiom_element_set_is_empty(om_ele, env, is_empty); + + /* order of processing name spaces first (before processing attributes) is important */ + axiom_stax_builder_process_namespaces(om_builder, env, element_node, 0); + axiom_stax_builder_process_attributes(om_builder, env, element_node); + + om_builder->lastnode = element_node; + return element_node; +} + +static axiom_node_t * +axiom_stax_builder_create_om_comment( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + axiom_node_t *comment_node = NULL; + axis2_char_t *comment_value = NULL; + + if(!om_builder->lastnode) + { + /* if the comment is at the root level, we will omit it */ + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Top level comment is ignored"); + return NULL; + } + + comment_value = axiom_xml_reader_get_value(om_builder->parser, env); + if(!comment_value) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_XML_READER_ELEMENT_NULL, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in reading comment"); + return NULL; + } + + if(axiom_node_is_complete(om_builder->lastnode, env)) + { + /* Last node is completed means, this node should be a sibling of last node */ + axiom_node_t *parent = axiom_node_get_parent(om_builder->lastnode, env); + axiom_comment_create(env, parent, comment_value, &comment_node); + axiom_node_set_next_sibling(om_builder->lastnode, env, comment_node); + axiom_node_set_previous_sibling(comment_node, env, om_builder->lastnode); + } + else + { + /* this node should be a child of last node */ + axiom_comment_create(env, om_builder->lastnode, comment_value, &comment_node); + axiom_node_set_first_child(om_builder->lastnode, env, comment_node); + axiom_node_set_parent(comment_node, env, om_builder->lastnode); + } + + axiom_xml_reader_xml_free(om_builder->parser,env,comment_value); + axiom_node_set_builder(comment_node, env, om_builder); + axiom_node_set_document(comment_node, env, om_builder->document); + om_builder->element_level++; + om_builder->lastnode = comment_node; + + return comment_node; +} + + +static axiom_node_t * +axiom_stax_builder_create_om_processing_instruction( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + axiom_node_t *pi_node = NULL; + axis2_char_t *target = NULL; + axis2_char_t *value = NULL; + + target = axiom_xml_reader_get_pi_target(om_builder->parser, env); + value = axiom_xml_reader_get_pi_data(om_builder->parser, env); + if(!target) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_XML_READER_ELEMENT_NULL, AXIS2_FAILURE); + return NULL; + } + if(!om_builder->lastnode) + { + /* do nothing */ + axiom_xml_reader_xml_free(om_builder->parser, env, target); + axiom_xml_reader_xml_free(om_builder->parser, env, value); + return NULL; + } + else if(axiom_node_is_complete(om_builder->lastnode, env) + || (axiom_node_get_node_type(om_builder->lastnode, env) == AXIOM_TEXT)) + { + axiom_processing_instruction_create(env, axiom_node_get_parent(om_builder-> lastnode, env), + target, value, &pi_node); + + axiom_node_set_next_sibling(om_builder->lastnode, env, pi_node); + axiom_node_set_previous_sibling(pi_node, env, om_builder->lastnode); + } + else + { + axiom_processing_instruction_create(env, om_builder->lastnode, target, value, &pi_node); + axiom_node_set_first_child(om_builder->lastnode, env, pi_node); + axiom_node_set_parent(pi_node, env, om_builder->lastnode); + } + + om_builder->element_level++; + + if(target) + { + axiom_xml_reader_xml_free(om_builder->parser, env, target); + } + if(value) + { + axiom_xml_reader_xml_free(om_builder->parser, env, value); + } + + om_builder->lastnode = pi_node; + return pi_node; +} + +static axis2_status_t +axiom_stax_builder_end_element( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + /* if last node is not set, that means end_element is called before start_element, + * which is an error */ + if(!om_builder->lastnode) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Invalid XML. End element is received before start element."); + return AXIS2_FAILURE; + } + + om_builder->element_level--; + if(axiom_node_is_complete(om_builder->lastnode, env)) + { + /* Last node completed means, this end element should be parent of the last node. */ + axiom_node_t *parent = NULL; + parent = axiom_node_get_parent(om_builder->lastnode, env); + if(parent) + { + axiom_node_set_complete(parent, env, AXIS2_TRUE); + om_builder->lastnode = parent; + } + } + else + { + axiom_node_set_complete((om_builder->lastnode), env, AXIS2_TRUE); + } + + /* if we finish building the root node, then we can set the complete status of om_builder */ + if(om_builder->root_node && axiom_node_is_complete(om_builder->root_node, env)) + { + om_builder->done = AXIS2_TRUE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_stax_builder_next( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + int token = 0; + axiom_node_t *node = NULL; + AXIS2_ENV_CHECK(env, NULL); + + if(!om_builder->parser) + { + return NULL; + } + do + { + if(om_builder->done) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_BUILDER_DONE_CANNOT_PULL, AXIS2_FAILURE); + return NULL; + } + + token = axiom_xml_reader_next(om_builder->parser, env); + if(token == -1) + { + return NULL; + } + + om_builder->current_event = token; + + if(!(om_builder->cache)) + { + return NULL; + } + + switch(token) + { + case AXIOM_XML_READER_START_DOCUMENT: + /*Do nothing */ + break; + + case AXIOM_XML_READER_START_ELEMENT: + node = axiom_stax_builder_create_om_element(om_builder, env, AXIS2_FALSE); + break; + + case AXIOM_XML_READER_EMPTY_ELEMENT: + +#ifdef AXIS2_LIBXML2_ENABLED + node = axiom_stax_builder_create_om_element(om_builder, env, AXIS2_FALSE); +#else + node = axiom_stax_builder_create_om_element(om_builder, env, AXIS2_TRUE); +#endif + + case AXIOM_XML_READER_END_ELEMENT: + axiom_stax_builder_end_element(om_builder, env); + break; + + case AXIOM_XML_READER_SPACE: + node = axiom_stax_builder_create_om_text(om_builder, env); + break; + + case AXIOM_XML_READER_CHARACTER: + node = axiom_stax_builder_create_om_text(om_builder, env); + break; + + case AXIOM_XML_READER_ENTITY_REFERENCE: + break; + + case AXIOM_XML_READER_COMMENT: + + node = axiom_stax_builder_create_om_comment(om_builder, env); + axiom_stax_builder_end_element(om_builder, env); + break; + + case AXIOM_XML_READER_PROCESSING_INSTRUCTION: + + node = axiom_stax_builder_create_om_processing_instruction(om_builder, env); + axiom_stax_builder_end_element(om_builder, env); + break; + + case AXIOM_XML_READER_CDATA: + break; + + case AXIOM_XML_READER_DOCUMENT_TYPE: + break; + + default: + break; + } + } + while(!node); + return node; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_stax_builder_free( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + if(!om_builder) + { + return; + } + if(om_builder->declared_namespaces) + { + axutil_hash_free(om_builder->declared_namespaces, env); + om_builder->declared_namespaces = NULL; + } + + if(om_builder->document) + { + axiom_document_free(om_builder->document, env); + om_builder->document = NULL; + } + else + { + if(om_builder->root_node) + { + axiom_node_free_tree(om_builder->root_node, env); + om_builder->root_node = NULL; + } + } + + if(om_builder->parser) + { + axiom_xml_reader_free(om_builder->parser, env); + om_builder->parser = NULL; + } + + AXIS2_FREE(env->allocator, om_builder); + + return; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_stax_builder_free_self( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + + axiom_node_t *temp_node = NULL; + axiom_node_t *nodes[256]; + axiom_node_t *om_node = NULL; + int count = 0; + + om_node = om_builder->root_node; + + nodes[count++] = om_node; + + if(om_node) + { + do + { + + axiom_node_set_builder(om_node, env, NULL); + axiom_node_set_document(om_node, env, NULL); + + temp_node = axiom_node_get_first_child(om_node, env); + /* serialize children of this node */ + if(temp_node) + { + om_node = temp_node; + nodes[count++] = om_node; + } + else + { + temp_node = axiom_node_get_next_sibling(om_node, env); + if(temp_node) + { + om_node = temp_node; + nodes[count - 1] = om_node; + } + else + { + while(count > 1 && !temp_node) + { + count--; + om_node = nodes[count - 1]; + temp_node = axiom_node_get_next_sibling(om_node, env); + } + if(temp_node && count > 1) + { + om_node = temp_node; + nodes[count - 1] = om_node; + } + else + { + count--; + } + } + } + } + while(count > 0); + } + if(om_builder->declared_namespaces) + { + axutil_hash_free(om_builder->declared_namespaces, env); + om_builder->declared_namespaces = NULL; + } + + if(om_builder->parser) + { + axiom_xml_reader_free(om_builder->parser, env); + om_builder->parser = NULL; + } + if(om_builder->document) + { + axiom_document_free_self(om_builder->document, env); + om_builder->document = NULL; + } + AXIS2_FREE(env->allocator, om_builder); + return; +} + +AXIS2_EXTERN axiom_document_t *AXIS2_CALL +axiom_stax_builder_get_document( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + return om_builder->document; +} + +/** + * moves the reader to next event and returns the token returned by the xml_reader , + * @param builder pointer to STAX builder struct to be used + * @param environment Environment. MUST NOT be NULL. + * @return next event axiom_xml_reader_event_types. Returns -1 on error + */ +AXIS2_EXTERN int AXIS2_CALL +axiom_stax_builder_next_with_token( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + int token = 0; + + if((!om_builder) || (!om_builder->parser)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid OM builder"); + return -1; + } + + if(om_builder->done) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_BUILDER_DONE_CANNOT_PULL, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "OM is fully built. Nothing more to build"); + return -1; + } + + token = axiom_xml_reader_next(om_builder->parser, env); + om_builder->current_event = token; + + if(token == -1) + { + om_builder->done = AXIS2_TRUE; + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error when reading xml"); + return -1; + } + + if(!om_builder->cache) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Caching disabled"); + return -1; + } + + switch(token) + { + case AXIOM_XML_READER_START_DOCUMENT: + { + /*Do nothing */ + break; + } + case AXIOM_XML_READER_START_ELEMENT: + { + if(!axiom_stax_builder_create_om_element(om_builder, env, AXIS2_FALSE)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating start element"); + return -1; + } + break; + } + case AXIOM_XML_READER_EMPTY_ELEMENT: + { + axis2_bool_t is_empty = AXIS2_TRUE; +#ifdef AXIS2_LIBXML2_ENABLED + is_empty = AXIS2_FALSE; +#endif + if(!axiom_stax_builder_create_om_element(om_builder, env, is_empty)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating empty element"); + return -1; + } + /* Let this to fall to AXIOM_XML_READER_END_ELEMENT case as well, since empty element + * = start element logic + end element logic */ + } + case AXIOM_XML_READER_END_ELEMENT: + { + if(axiom_stax_builder_end_element(om_builder, env) != AXIS2_SUCCESS) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in processing end element"); + return -1; + } + break; + } + case AXIOM_XML_READER_SPACE: + { + /* ignore white space before the root element */ + if(om_builder->lastnode) + { + if(!axiom_stax_builder_create_om_text(om_builder, env)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating axiom text"); + return -1; + } + } + break; + } + case AXIOM_XML_READER_CHARACTER: + { + if(!axiom_stax_builder_create_om_text(om_builder, env)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating axiom text"); + return -1; + } + break; + } + case AXIOM_XML_READER_ENTITY_REFERENCE: + { + break; + } + case AXIOM_XML_READER_COMMENT: + { + if(axiom_stax_builder_create_om_comment(om_builder, env)) + { + axiom_stax_builder_end_element(om_builder, env); + } + break; + } + case AXIOM_XML_READER_PROCESSING_INSTRUCTION: + { + if(axiom_stax_builder_create_om_processing_instruction(om_builder, env)) + { + axiom_stax_builder_end_element(om_builder, env); + } + break; + } + case AXIOM_XML_READER_CDATA: + case AXIOM_XML_READER_DOCUMENT_TYPE: + default: + break; + } + return token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_stax_builder_discard_current_element( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + axiom_node_t *element = NULL; + axiom_node_t *prev_node = NULL; + axiom_node_t *parent = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + element = om_builder->lastnode; + + if(axiom_node_is_complete(element, env) || !(om_builder->cache)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_BUILDER_STATE_CANNOT_DISCARD, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + om_builder->cache = AXIS2_FALSE; + do + { + while(axiom_xml_reader_next(om_builder->parser, env) != AXIOM_XML_READER_END_ELEMENT) + ; + } + while(!(axiom_node_is_complete(element, env))); + + /*All children of this element is pulled now */ + + prev_node = axiom_node_get_previous_sibling(element, env); + if(prev_node) + { + axiom_node_free_tree(axiom_node_get_next_sibling(prev_node, env), env); + axiom_node_set_next_sibling(prev_node, env, NULL); + } + else + { + parent = axiom_node_get_parent(element, env); + axiom_node_free_tree(axiom_node_get_first_child(parent, env), env); + axiom_node_set_first_child(parent, env, NULL); + om_builder->lastnode = parent; + } + om_builder->cache = AXIS2_TRUE; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL +axiom_stax_builder_get_parser( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + return om_builder->parser; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_stax_builder_set_cache( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env, + axis2_bool_t enable_cache) +{ + om_builder->cache = enable_cache; +} + +/** + internal function for soap om_builder only + */ +AXIS2_EXTERN int AXIS2_CALL +axiom_stax_builder_get_current_event( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + return om_builder->current_event; +} + +/** + internal function for soap om_builder only + */ +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_stax_builder_get_lastnode( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + return om_builder->lastnode; +} + +/** + internal function for soap om_builder only + */ +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_stax_builder_is_complete( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + return om_builder->done; +} + +/** + internal function for soap om_builder only + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_stax_builder_set_lastnode( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env, + axiom_node_t * om_node) +{ + om_builder->lastnode = om_node; + return AXIS2_SUCCESS; +} + +/** + internal function for soap om_builder only + */ +AXIS2_EXTERN int AXIS2_CALL +axiom_stax_builder_get_element_level( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + return om_builder->element_level; +} + +/** + internal function for soap om_builder only + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_stax_builder_set_element_level( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env, + int element_level) +{ + om_builder->element_level = element_level; + return AXIS2_SUCCESS; +} + +#if 0 +static axiom_node_t * +axiom_stax_builder_create_om_doctype( + axiom_stax_builder_t * om_builder, + const axutil_env_t * env) +{ + axiom_node_t *doctype_node = NULL; + axis2_char_t *doc_value = NULL; + + doc_value = axiom_xml_reader_get_dtd(om_builder->parser, env); + if(!doc_value) + { + return NULL; + } + if(!(om_builder->lastnode)) + { + axiom_doctype_create(env, NULL, doc_value, &doctype_node); + if(om_builder->document) + { + axiom_document_set_root_element(om_builder->document, env, doctype_node); + } + } + om_builder->lastnode = doctype_node; + axiom_xml_reader_xml_free(om_builder->parser, env, doc_value); + return doctype_node; +} +#endif diff --git a/axiom/src/om/om_text.c b/axiom/src/om/om_text.c new file mode 100644 index 0000000..453c395 --- /dev/null +++ b/axiom/src/om/om_text.c @@ -0,0 +1,637 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "axiom_node_internal.h" +#include +#include +#include +#include +#include + +static axis2_bool_t AXIS2_CALL axiom_text_get_is_binary( + axiom_text_t * om_text, + const axutil_env_t * env); + +static axis2_status_t AXIS2_CALL axiom_text_serialize_start_part( + axiom_text_t * om_text, + const axutil_env_t * env, + axiom_output_t * om_output); + +struct axiom_text +{ + + /** Text value */ + axutil_string_t *value; + + /** The following fields are for MTOM */ + axis2_char_t *mime_type; + axis2_bool_t optimize; + const axis2_char_t *localname; + axis2_bool_t is_binary; + axis2_bool_t is_swa; + axis2_char_t *content_id; + axiom_attribute_t *om_attribute; + axiom_namespace_t *ns; + axiom_data_handler_t *data_handler; +}; + +AXIS2_EXTERN axiom_text_t *AXIS2_CALL +axiom_text_create( + const axutil_env_t * env, + axiom_node_t * parent, + const axis2_char_t * value, + axiom_node_t ** node) +{ + axiom_text_t *om_text = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, node, NULL); + + *node = axiom_node_create(env); + + if(!(*node)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + om_text = (axiom_text_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_text_t)); + if(!om_text) + { + AXIS2_FREE(env->allocator, *node); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + om_text->mime_type = NULL; + om_text->optimize = AXIS2_FALSE; + om_text->localname = "Include"; + om_text->is_binary = AXIS2_FALSE; + om_text->is_swa = AXIS2_FALSE; + om_text->content_id = NULL; + om_text->om_attribute = NULL; + om_text->value = NULL; + om_text->ns = NULL; + om_text->data_handler = NULL; + om_text->mime_type = NULL; + + if(value) + { + om_text->value = axutil_string_create(env, value); + } + + axiom_node_set_data_element((*node), env, om_text); + axiom_node_set_node_type((*node), env, AXIOM_TEXT); + axiom_node_set_complete((*node), env, AXIS2_FALSE); + + if(parent && axiom_node_get_node_type(parent, env) == AXIOM_ELEMENT) + { + axiom_node_add_child(parent, env, (*node)); + } + + return om_text; +} + +AXIS2_EXTERN axiom_text_t *AXIS2_CALL +axiom_text_create_with_data_handler( + const axutil_env_t * env, + axiom_node_t * parent, + axiom_data_handler_t * data_handler, + axiom_node_t ** node) +{ + + axiom_text_t *om_text = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, data_handler, NULL); + + om_text = (axiom_text_t *)axiom_text_create(env, parent, NULL, node); + if(!om_text) + { + return NULL; + } + om_text->optimize = AXIS2_TRUE; + om_text->is_binary = AXIS2_TRUE; + om_text->data_handler = data_handler; + om_text->mime_type = axiom_data_handler_get_content_type(data_handler, env); + return om_text; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_text_free( + axiom_text_t * om_text, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + + if(om_text->value) + { + axutil_string_free(om_text->value, env); + } + + if(om_text->ns) + { + axiom_namespace_free(om_text->ns, env); + } + + if(om_text->content_id) + { + AXIS2_FREE(env->allocator, om_text->content_id); + } + + if(om_text->om_attribute) + { + axiom_attribute_free(om_text->om_attribute, env); + } + + if(om_text->data_handler) + { + axiom_data_handler_free(om_text->data_handler, env); + } + + AXIS2_FREE(env->allocator, om_text); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_text_serialize( + axiom_text_t * om_text, + const axutil_env_t * env, + axiom_output_t * om_output) +{ + int status = AXIS2_SUCCESS; + axis2_char_t *attribute_value = NULL; + const axis2_char_t *text = NULL; + axiom_xml_writer_t *om_output_xml_writer = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); + + if(!axiom_text_get_is_binary(om_text, env)) + { + if(om_text->value) + { + status = axiom_output_write(om_output, env, AXIOM_TEXT, 1, axutil_string_get_buffer( + om_text->value, env)); + } + } + else + { + om_output_xml_writer = axiom_output_get_xml_writer(om_output, env); + if(axiom_output_is_optimized(om_output, env) && om_text->optimize) + { + if(!(axiom_text_get_content_id(om_text, env))) + { + axis2_char_t *content_id = axiom_output_get_next_content_id(om_output, env); + if(content_id) + { + om_text->content_id = axutil_strdup(env, content_id); + } + } + + attribute_value = axutil_stracat(env, "cid:", om_text->content_id); + + /*send binary as MTOM optimised */ + if(om_text->om_attribute) + { + axiom_attribute_free(om_text->om_attribute, env); + om_text->om_attribute = NULL; + } + + om_text->om_attribute = axiom_attribute_create(env, "href", attribute_value, NULL); + + AXIS2_FREE(env->allocator, attribute_value); + attribute_value = NULL; + + if(!om_text->is_swa) /* This is a hack to get SwA working */ + { + axiom_text_serialize_start_part(om_text, env, om_output); + } + else + { + status = axiom_output_write(om_output, env, AXIOM_TEXT, 1, om_text->content_id); + } + + axiom_output_write_optimized(om_output, env, om_text); + + axiom_output_write(om_output, env, AXIOM_ELEMENT, 0); + } + else + { + text = axiom_text_get_text(om_text, env); + axiom_xml_writer_write_characters(om_output_xml_writer, env, (axis2_char_t *)text); + } + } + return status; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axiom_text_get_value( + axiom_text_t * om_text, + const axutil_env_t * env) +{ + if(om_text->value) + { + return axutil_string_get_buffer(om_text->value, env); + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_text_set_value( + axiom_text_t * om_text, + const axutil_env_t * env, + const axis2_char_t * value) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_text, AXIS2_FAILURE); + + if(om_text->value) + { + axutil_string_free(om_text->value, env); + om_text->value = NULL; + } + + om_text->value = axutil_string_create(env, value); + if(!om_text->value) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +/*Following has been implemented for the MTOM support*/ + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_text_get_mime_type( + axiom_text_t * om_text, + const axutil_env_t * env) +{ + return om_text->mime_type; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_text_set_mime_type( + axiom_text_t * om_text, + const axutil_env_t * env, + const axis2_char_t * mime_type) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_text, AXIS2_FAILURE); + if(om_text->mime_type) + { + AXIS2_FREE(env->allocator, om_text->mime_type); + } + om_text->mime_type = (axis2_char_t *)axutil_strdup(env, mime_type); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_text_get_optimize( + axiom_text_t * om_text, + const axutil_env_t * env) +{ + return om_text->optimize; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_text_set_optimize( + axiom_text_t * om_text, + const axutil_env_t * env, + axis2_bool_t optimize) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_text, AXIS2_FAILURE); + om_text->optimize = optimize; + return AXIS2_SUCCESS; +} + +static axis2_bool_t AXIS2_CALL +axiom_text_get_is_binary( + axiom_text_t * om_text, + const axutil_env_t * env) +{ + return om_text->is_binary; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_text_set_is_binary( + axiom_text_t * om_text, + const axutil_env_t * env, + const axis2_bool_t is_binary) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_text, AXIS2_FAILURE); + om_text->is_binary = is_binary; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axiom_text_get_localname( + axiom_text_t * om_text, + const axutil_env_t * env) +{ + return om_text->localname; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_text_get_content_id( + axiom_text_t * om_text, + const axutil_env_t * env) +{ + return om_text->content_id; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_text_set_content_id( + axiom_text_t * om_text, + const axutil_env_t * env, + const axis2_char_t * content_id) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_text, AXIS2_FAILURE); + if(om_text->content_id) + { + AXIS2_FREE(env->allocator, om_text->content_id); + } + om_text->content_id = (axis2_char_t *)axutil_strdup(env, content_id); + return AXIS2_SUCCESS; +} + +static axis2_status_t AXIS2_CALL +axiom_text_serialize_start_part( + axiom_text_t * om_text, + const axutil_env_t * env, + axiom_output_t * om_output) +{ + axis2_char_t *namespace_uri = NULL; + axis2_char_t *prefix = NULL; + const axis2_char_t *local_name = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + local_name = axiom_text_get_localname(om_text, env); + + om_text->ns = axiom_namespace_create(env, "http://www.w3.org/2004/08/xop/include", "xop"); + + if(om_text->ns) + { + namespace_uri = axiom_namespace_get_uri(om_text->ns, env); + if(namespace_uri) + { + prefix = axiom_namespace_get_prefix(om_text->ns, env); + + if(prefix) + { + axiom_output_write(om_output, env, AXIOM_ELEMENT, 3, local_name, namespace_uri, + prefix); + } + else + { + axiom_output_write(om_output, env, AXIOM_ELEMENT, 2, local_name, namespace_uri); + } + } + else + { + axiom_output_write(om_output, env, AXIOM_ELEMENT, 1, local_name); + } + } + else + { + axiom_output_write(om_output, env, AXIOM_TEXT, 1, local_name); + } + if(om_text->om_attribute) + { + axiom_attribute_serialize(om_text->om_attribute, env, om_output); + } + if(om_text->ns) + { + axiom_namespace_serialize(om_text->ns, env, om_output); + axiom_namespace_free(om_text->ns, env); + om_text->ns = NULL; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_text_serialize_attribute( + axiom_text_t * om_text, + const axutil_env_t * env, + axiom_output_t * om_output, + axiom_attribute_t * om_attribute) +{ + axiom_xml_writer_t *xml_writer = NULL; + axiom_namespace_t *om_namespace = NULL; + + axis2_char_t *namespace_uri = NULL; + axis2_char_t *prefix = NULL; + axis2_char_t *attribute_local_name = NULL; + axis2_char_t *attribute_value = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0, + AXIS2_XML_PARSER_TYPE_BUFFER); + om_namespace = axiom_namespace_create(env, "", ""); + + namespace_uri = axiom_namespace_get_uri(om_text->ns, env); + attribute_local_name = axiom_attribute_get_localname(om_attribute, env); + + if(om_namespace) + { + prefix = axiom_namespace_get_prefix(om_text->ns, env); + attribute_value = axiom_attribute_get_value(om_attribute, env); + if(prefix) + { + axiom_xml_writer_write_attribute(xml_writer, env, attribute_local_name, attribute_value); + } + else + { + axiom_xml_writer_write_attribute_with_namespace(xml_writer, env, attribute_local_name, + attribute_value, namespace_uri); + } + } + else + { + axiom_xml_writer_write_attribute(xml_writer, env, attribute_local_name, attribute_value); + } + axiom_namespace_free(om_namespace, env); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_text_serialize_namespace( + axiom_text_t * om_text, + const axutil_env_t * env, + const axiom_namespace_t * om_namespace, + axiom_output_t * om_output) +{ + axiom_xml_writer_t *xml_writer = NULL; + axis2_char_t *namespace_uri = NULL; + axis2_char_t *namespace_prefix = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0, + AXIS2_XML_PARSER_TYPE_BUFFER); + om_namespace = axiom_namespace_create(env, "", ""); + + if(om_namespace) + { + namespace_uri = axiom_namespace_get_uri(om_text->ns, env); + namespace_prefix = axiom_namespace_get_prefix(om_text->ns, env); + axiom_xml_writer_write_namespace(xml_writer, env, namespace_prefix, namespace_uri); + axiom_xml_writer_set_prefix(xml_writer, env, namespace_prefix, namespace_uri); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN const axis2_char_t *AXIS2_CALL +axiom_text_get_text( + axiom_text_t * om_text, + const axutil_env_t * env) +{ + if(om_text->value) + { + return axutil_string_get_buffer(om_text->value, env); + } + else + { + axis2_char_t *data_handler_stream = NULL; + size_t data_handler_stream_size = 0; + if(om_text->data_handler) + { + int encoded_len = 0; + axis2_char_t *encoded_str = NULL; + axiom_data_handler_read_from(om_text->data_handler, env, &data_handler_stream, + &data_handler_stream_size); + if(data_handler_stream) + { + encoded_len = axutil_base64_encode_len((int)data_handler_stream_size); + encoded_str = AXIS2_MALLOC(env->allocator, encoded_len + 2); + if(encoded_str) + { + encoded_len = axutil_base64_encode(encoded_str, data_handler_stream, + (int)data_handler_stream_size); + encoded_str[encoded_len] = '\0'; + return encoded_str; + } + } + } + } + return NULL; +} + +AXIS2_EXTERN axiom_data_handler_t *AXIS2_CALL +axiom_text_get_data_handler( + axiom_text_t * om_text, + const axutil_env_t * env) +{ + return om_text->data_handler; +} + +AXIS2_EXTERN axiom_text_t *AXIS2_CALL +axiom_text_create_str( + const axutil_env_t * env, + axiom_node_t * parent, + axutil_string_t * value, + axiom_node_t ** node) +{ + axiom_text_t *om_text = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, node, NULL); + + *node = axiom_node_create(env); + + if(!(*node)) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + om_text = (axiom_text_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_text_t)); + if(!om_text) + { + AXIS2_FREE(env->allocator, *node); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + om_text->mime_type = NULL; + om_text->optimize = AXIS2_FALSE; + om_text->localname = "Include"; + om_text->is_binary = AXIS2_FALSE; + om_text->content_id = NULL; + om_text->om_attribute = NULL; + om_text->value = NULL; + om_text->ns = NULL; + om_text->data_handler = NULL; + om_text->mime_type = NULL; + + if(value) + { + om_text->value = axutil_string_clone(value, env); + } + + axiom_node_set_data_element((*node), env, om_text); + axiom_node_set_node_type((*node), env, AXIOM_TEXT); + axiom_node_set_complete((*node), env, AXIS2_FALSE); + + if(parent && axiom_node_get_node_type(parent, env) == AXIOM_ELEMENT) + { + axiom_node_add_child(parent, env, (*node)); + } + + return om_text; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_text_set_value_str( + struct axiom_text * om_text, + const axutil_env_t * env, + axutil_string_t * value) +{ + if(om_text->value) + { + axutil_string_free(om_text->value, env); + om_text->value = NULL; + } + if(value) + { + om_text->value = axutil_string_clone(value, env); + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_string_t *AXIS2_CALL +axiom_text_get_value_str( + struct axiom_text * om_text, + const axutil_env_t * env) +{ + return om_text->value; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_text_set_is_swa( + axiom_text_t * om_text, + const axutil_env_t * env, + const axis2_bool_t is_swa) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_text, AXIS2_FAILURE); + om_text->is_swa = is_swa; + return AXIS2_SUCCESS; +} diff --git a/axiom/src/parser/Makefile.am b/axiom/src/parser/Makefile.am new file mode 100644 index 0000000..6c1d2ba --- /dev/null +++ b/axiom/src/parser/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = $(WRAPPER_DIR) + +DIST_SUBDIRS=guththila libxml2 diff --git a/axiom/src/parser/guththila/Makefile.am b/axiom/src/parser/guththila/Makefile.am new file mode 100644 index 0000000..0cc6be5 --- /dev/null +++ b/axiom/src/parser/guththila/Makefile.am @@ -0,0 +1,13 @@ +lib_LTLIBRARIES = libaxis2_parser.la + +libaxis2_parser_la_LIBADD = ../../../../guththila/src/libguththila.la \ + ../../../../util/src/libaxutil.la + +libaxis2_parser_la_SOURCES = ../xml_reader.c ../xml_writer.c guththila_xml_writer_wrapper.c \ + guththila_xml_reader_wrapper.c + +libaxis2_parser_la_LDFLAGS = -version-info $(VERSION_NO) + +INCLUDES = -I$(top_builddir)/include \ + -I ../../../../util/include \ + -I ../../../../guththila/include diff --git a/axiom/src/parser/guththila/guththila_xml_reader_wrapper.c b/axiom/src/parser/guththila/guththila_xml_reader_wrapper.c new file mode 100644 index 0000000..086ed12 --- /dev/null +++ b/axiom/src/parser/guththila/guththila_xml_reader_wrapper.c @@ -0,0 +1,613 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +/**************** function prototypes ******************************************/ + +int AXIS2_CALL guththila_xml_reader_wrapper_next( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +void AXIS2_CALL guththila_xml_reader_wrapper_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +int AXIS2_CALL guththila_xml_reader_wrapper_get_attribute_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_attribute_name_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_attribute_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_attribute_value_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_attribute_namespace_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + +axis2_char_t *AXIS2_CALL guththila_xml_reader_wrapper_get_value( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +int AXIS2_CALL guththila_xml_reader_wrapper_get_namespace_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_namespace_uri_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_namespace_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + +axis2_char_t *AXIS2_CALL guththila_xml_reader_wrapper_get_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL guththila_xml_reader_wrapper_get_name( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL guththila_xml_reader_wrapper_get_pi_target( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL guththila_xml_reader_wrapper_get_pi_data( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL guththila_xml_reader_wrapper_get_dtd( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +void AXIS2_CALL guththila_xml_reader_wrapper_xml_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + void *data); + +axis2_char_t *AXIS2_CALL guththila_xml_reader_wrapper_get_char_set_encoding( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL guththila_xml_reader_wrapper_get_namespace_uri( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_namespace_uri_by_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + axis2_char_t * prefix); + +void *AXIS2_CALL +guththila_xml_reader_wrapper_get_context( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_current_buffer( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +/*********** guththila_xml_reader_wrapper_impl_t wrapper struct *******************/ + +typedef struct guththila_xml_reader_wrapper_impl +{ + axiom_xml_reader_t parser; + guththila_t *guththila_parser; + guththila_reader_t *reader; + int event_map[10]; + void *context; + +} guththila_xml_reader_wrapper_impl_t; + +/********************************* Macro ***************************************/ + +#define AXIS2_INTF_TO_IMPL(p) ((guththila_xml_reader_wrapper_impl_t*)p) + +#define AXIS2_IMPL_TO_INTF(p) &(p->parser) + +/**********End macros -- event_map initializing function *********************/ + +static axis2_status_t +guththila_xml_reader_wrapper_init_map( + guththila_xml_reader_wrapper_impl_t * parser) +{ + if(parser) + { + parser->event_map[GUTHTHILA_START_DOCUMENT] = AXIOM_XML_READER_START_DOCUMENT; + parser->event_map[GUTHTHILA_START_ELEMENT] = AXIOM_XML_READER_START_ELEMENT; + parser->event_map[GUTHTHILA_END_ELEMENT] = AXIOM_XML_READER_END_ELEMENT; + parser->event_map[GUTHTHILA_SPACE] = AXIOM_XML_READER_SPACE; + parser->event_map[GUTHTHILA_EMPTY_ELEMENT] = AXIOM_XML_READER_EMPTY_ELEMENT; + parser->event_map[GUTHTHILA_CHARACTER] = AXIOM_XML_READER_CHARACTER; + parser->event_map[GUTHTHILA_ENTITY_REFERANCE] = AXIOM_XML_READER_ENTITY_REFERENCE; + parser->event_map[GUTHTHILA_COMMENT] = AXIOM_XML_READER_COMMENT; + return AXIS2_SUCCESS; + } + return AXIS2_FAILURE; +} + +static const axiom_xml_reader_ops_t axiom_xml_reader_ops_var = { guththila_xml_reader_wrapper_next, + guththila_xml_reader_wrapper_free, guththila_xml_reader_wrapper_get_attribute_count, + guththila_xml_reader_wrapper_get_attribute_name_by_number, + guththila_xml_reader_wrapper_get_attribute_prefix_by_number, + guththila_xml_reader_wrapper_get_attribute_value_by_number, + guththila_xml_reader_wrapper_get_attribute_namespace_by_number, + guththila_xml_reader_wrapper_get_value, guththila_xml_reader_wrapper_get_namespace_count, + guththila_xml_reader_wrapper_get_namespace_uri_by_number, + guththila_xml_reader_wrapper_get_namespace_prefix_by_number, + guththila_xml_reader_wrapper_get_prefix, guththila_xml_reader_wrapper_get_name, + guththila_xml_reader_wrapper_get_pi_target, guththila_xml_reader_wrapper_get_pi_data, + guththila_xml_reader_wrapper_get_dtd, guththila_xml_reader_wrapper_xml_free, + guththila_xml_reader_wrapper_get_char_set_encoding, + guththila_xml_reader_wrapper_get_namespace_uri, + guththila_xml_reader_wrapper_get_namespace_uri_by_prefix, + guththila_xml_reader_wrapper_get_context, + guththila_xml_reader_wrapper_get_current_buffer}; + +/********************************************************************************/ + +AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL +axiom_xml_reader_create_for_file( + const axutil_env_t * env, + char *filename, + const axis2_char_t * encoding) +{ + guththila_xml_reader_wrapper_impl_t *guththila_impl = NULL; + guththila_t *guththila = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + guththila_impl = AXIS2_MALLOC(env->allocator, sizeof(guththila_xml_reader_wrapper_impl_t)); + + if(!guththila_impl) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + guththila_impl->reader = guththila_reader_create_for_file(filename, env); + + if(!(guththila_impl->reader)) + { + AXIS2_FREE(env->allocator, guththila_impl); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + guththila = (guththila_t *)AXIS2_MALLOC(env->allocator, sizeof(guththila_t)); + guththila_init(guththila, guththila_impl->reader, env); + if(!guththila) + { + AXIS2_FREE(env->allocator, guththila_impl); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + guththila_impl->guththila_parser = guththila; + guththila_impl->context = NULL; + guththila_impl->parser.ops = NULL; + /* guththila_impl->parser.ops = + (axiom_xml_reader_ops_t *) AXIS2_MALLOC(env->allocator, + sizeof(axiom_xml_reader_ops_t)); + if (!(guththila_impl->parser.ops)) + { + guththila_free(guththila, env); + AXIS2_FREE(env->allocator, guththila_impl); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + */ + guththila_xml_reader_wrapper_init_map(guththila_impl); + + /************** ops *****/ + guththila_impl->parser.ops = &axiom_xml_reader_ops_var; + return &(guththila_impl->parser); +} + +/****** pull parser for io create function ***************************/ + +axiom_xml_reader_t *AXIS2_CALL +axiom_xml_reader_create_for_io( + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK read_input_callback, + AXIS2_CLOSE_INPUT_CALLBACK close_input_callback, + void *ctx, + const char *encoding) +{ + guththila_xml_reader_wrapper_impl_t *guththila_impl = NULL; + /*axutil_allocator_t *allocator = NULL; */ + guththila_t *guththila = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + guththila_impl = AXIS2_MALLOC(env->allocator, sizeof(guththila_xml_reader_wrapper_impl_t)); + + if(!guththila_impl) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + /*allocator = axutil_allocator_init(NULL); */ + + /*-------difference of two create function is here--------*/ + guththila_impl->reader = guththila_reader_create_for_io(read_input_callback, ctx, env); + + if(!(guththila_impl->reader)) + { + AXIS2_FREE(env->allocator, guththila_impl); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + guththila = (guththila_t *)AXIS2_MALLOC(env->allocator, sizeof(guththila_t)); + guththila_init(guththila, guththila_impl->reader, env); + if(!guththila) + { + AXIS2_FREE(env->allocator, guththila_impl); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + guththila_impl->guththila_parser = guththila; + guththila_impl->context = ctx; + guththila_impl->parser.ops = NULL; + /* guththila_impl->parser.ops = (axiom_xml_reader_ops_t *) + AXIS2_MALLOC(env->allocator, sizeof(axiom_xml_reader_ops_t)); + if (!(guththila_impl->parser.ops)) + { + guththila_free(guththila, env); + AXIS2_FREE(env->allocator, guththila_impl); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + }*/ + + guththila_xml_reader_wrapper_init_map(guththila_impl); + + /************** ops *****/ + guththila_impl->parser.ops = &axiom_xml_reader_ops_var; + return &(guththila_impl->parser); +} + +/* ####################################################################### */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_reader_init() +{ + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_reader_cleanup() +{ + return AXIS2_SUCCESS; +} + +/* ######################################################################## */ + +AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL +axiom_xml_reader_create_for_memory( + const axutil_env_t * env, + void *buffer, + int size, + const char *encoding, + int type) +{ + guththila_xml_reader_wrapper_impl_t *guththila_impl = NULL; + /*axutil_allocator_t *allocator = NULL; */ + guththila_t *guththila = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + guththila_impl = AXIS2_MALLOC(env->allocator, sizeof(guththila_xml_reader_wrapper_impl_t)); + + if(!guththila_impl) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + /*allocator = axutil_allocator_init(NULL); */ + + /*-------difference of two create function is here--------*/ + guththila_impl->reader = guththila_reader_create_for_memory(buffer, size, env); + + if(!(guththila_impl->reader)) + { + AXIS2_FREE(env->allocator, guththila_impl); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + guththila = (guththila_t *)AXIS2_MALLOC(env->allocator, sizeof(guththila_t)); + guththila_init(guththila, guththila_impl->reader, env); + if(!guththila) + { + AXIS2_FREE(env->allocator, guththila_impl); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + guththila_impl->guththila_parser = guththila; + guththila_impl->context = NULL; + guththila_impl->parser.ops = NULL; + /* guththila_impl->parser.ops = (axiom_xml_reader_ops_t *) + AXIS2_MALLOC(env->allocator, sizeof(axiom_xml_reader_ops_t)); + if (!(guththila_impl->parser.ops)) + { + guththila_free(guththila, env); + AXIS2_FREE(env->allocator, guththila_impl); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + */ + guththila_xml_reader_wrapper_init_map(guththila_impl); + + /************** ops *****/ + guththila_impl->parser.ops = &axiom_xml_reader_ops_var; + return &(guththila_impl->parser); +} + +int AXIS2_CALL +guththila_xml_reader_wrapper_next( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + int i = -1; + AXIS2_ENV_CHECK(env, -1); + i = guththila_next(AXIS2_INTF_TO_IMPL(parser)->guththila_parser, env); + return i == -1 ? -1 : AXIS2_INTF_TO_IMPL(parser)->event_map[i]; +} + +void AXIS2_CALL +guththila_xml_reader_wrapper_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + guththila_xml_reader_wrapper_impl_t *parser_impl = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + parser_impl = AXIS2_INTF_TO_IMPL(parser); + if(parser_impl->reader) + { + guththila_reader_free(parser_impl->reader, env); + } + + if(parser_impl->guththila_parser) + { + guththila_un_init(parser_impl->guththila_parser, env); + } + + AXIS2_FREE(env->allocator, parser_impl); +} + +int AXIS2_CALL +guththila_xml_reader_wrapper_get_attribute_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return guththila_get_attribute_count(AXIS2_INTF_TO_IMPL(parser)-> guththila_parser, env); +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_attribute_name_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + AXIS2_ENV_CHECK(env, NULL); + return guththila_get_attribute_name_by_number(AXIS2_INTF_TO_IMPL(parser)-> guththila_parser, i, + env); +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_attribute_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + AXIS2_ENV_CHECK(env, NULL); + return guththila_get_attribute_prefix_by_number(AXIS2_INTF_TO_IMPL(parser)-> guththila_parser, + i, env); +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_attribute_value_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + AXIS2_ENV_CHECK(env, NULL); + return guththila_get_attribute_value_by_number(AXIS2_INTF_TO_IMPL(parser)-> guththila_parser, + i, env); +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_attribute_namespace_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + AXIS2_ENV_CHECK(env, NULL); + return guththila_get_attribute_namespace_by_number( + AXIS2_INTF_TO_IMPL(parser)-> guththila_parser, i, env); +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_value( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + return guththila_get_value(AXIS2_INTF_TO_IMPL(parser)->guththila_parser, env); +} + +int AXIS2_CALL +guththila_xml_reader_wrapper_get_namespace_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return guththila_get_namespace_count(AXIS2_INTF_TO_IMPL(parser)-> guththila_parser, env); +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_namespace_uri_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + AXIS2_ENV_CHECK(env, NULL); + return guththila_get_namespace_uri_by_number(AXIS2_INTF_TO_IMPL(parser)-> guththila_parser, i, + env); +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_namespace_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + AXIS2_ENV_CHECK(env, NULL); + return guththila_get_namespace_prefix_by_number(AXIS2_INTF_TO_IMPL(parser)-> guththila_parser, + i, env); +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + return guththila_get_prefix(AXIS2_INTF_TO_IMPL(parser)->guththila_parser, env); +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_name( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + return guththila_get_name(AXIS2_INTF_TO_IMPL(parser)->guththila_parser, env); +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_pi_target( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + /* guththila_does not support pi's yet */ + return NULL; +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_pi_data( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + /* guththila_dose not support yet */ + return NULL; +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_dtd( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + printf("not implemented in guththila"); + return NULL; +} + +void AXIS2_CALL +guththila_xml_reader_wrapper_xml_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + void *data) +{ + if(data) + AXIS2_FREE(env->allocator, data); +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_char_set_encoding( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return guththila_get_encoding(AXIS2_INTF_TO_IMPL(parser)->guththila_parser, env); +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_namespace_uri( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + + return (axis2_char_t *)NULL; +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_namespace_uri_by_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + axis2_char_t * prefix) +{ + return (axis2_char_t *)NULL; +} + +void *AXIS2_CALL +guththila_xml_reader_wrapper_get_context( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + guththila_xml_reader_wrapper_impl_t* parser_impl = NULL; + parser_impl = AXIS2_INTF_TO_IMPL(parser); + return parser_impl->context; +} + +axis2_char_t *AXIS2_CALL +guththila_xml_reader_wrapper_get_current_buffer( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return guththila_get_current_buffer(AXIS2_INTF_TO_IMPL(parser)->guththila_parser, env); +} + diff --git a/axiom/src/parser/guththila/guththila_xml_writer_wrapper.c b/axiom/src/parser/guththila/guththila_xml_writer_wrapper.c new file mode 100644 index 0000000..31b4040 --- /dev/null +++ b/axiom/src/parser/guththila/guththila_xml_writer_wrapper.c @@ -0,0 +1,787 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +/************************ function prototypes ************************************/ +void AXIS2_CALL guththila_xml_writer_wrapper_free( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_end_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_start_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_start_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_empty_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_empty_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_empty_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_end_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_end_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_attribute( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_attribute_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_attribute_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * namespace_uri); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_default_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * namespace_uri); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_comment( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * value); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_processing_instruction( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_processing_instruction_data( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target, + axis2_char_t * data); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_cdata( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * data); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_dtd( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * dtd); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_entity_ref( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * name); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_start_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_start_document_with_version( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_start_document_with_version_encoding( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * encoding, + axis2_char_t * version); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_characters( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text); + +axis2_char_t *AXIS2_CALL guththila_xml_writer_wrapper_get_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_set_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * uri); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_set_default_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_encoded( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text, + int in_attr); + +void *AXIS2_CALL guththila_xml_writer_wrapper_get_xml( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +unsigned int AXIS2_CALL guththila_xml_writer_wrapper_get_xml_size( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +int AXIS2_CALL guththila_xml_writer_wrapper_get_type( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_raw( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * content); + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_flush( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +/***************************** end function pointers *****************************/ + +typedef struct guththila_xml_writer_wrapper_impl +{ + axiom_xml_writer_t writer; + guththila_xml_writer_t *wr; +} guththila_xml_writer_wrapper_impl_t; + +static const axiom_xml_writer_ops_t axiom_xml_writer_ops_var = { guththila_xml_writer_wrapper_free, + guththila_xml_writer_wrapper_write_start_element, + guththila_xml_writer_wrapper_end_start_element, + guththila_xml_writer_wrapper_write_start_element_with_namespace, + guththila_xml_writer_wrapper_write_start_element_with_namespace_prefix, + guththila_xml_writer_wrapper_write_empty_element, + guththila_xml_writer_wrapper_write_empty_element_with_namespace, + guththila_xml_writer_wrapper_write_empty_element_with_namespace_prefix, + guththila_xml_writer_wrapper_write_end_element, + guththila_xml_writer_wrapper_write_end_document, guththila_xml_writer_wrapper_write_attribute, + guththila_xml_writer_wrapper_write_attribute_with_namespace, + guththila_xml_writer_wrapper_write_attribute_with_namespace_prefix, + guththila_xml_writer_wrapper_write_namespace, + guththila_xml_writer_wrapper_write_default_namespace, + guththila_xml_writer_wrapper_write_comment, + guththila_xml_writer_wrapper_write_processing_instruction, + guththila_xml_writer_wrapper_write_processing_instruction_data, + guththila_xml_writer_wrapper_write_cdata, guththila_xml_writer_wrapper_write_dtd, + guththila_xml_writer_wrapper_write_entity_ref, + guththila_xml_writer_wrapper_write_start_document, + guththila_xml_writer_wrapper_write_start_document_with_version, + guththila_xml_writer_wrapper_write_start_document_with_version_encoding, + guththila_xml_writer_wrapper_write_characters, guththila_xml_writer_wrapper_get_prefix, + guththila_xml_writer_wrapper_set_prefix, guththila_xml_writer_wrapper_set_default_prefix, + guththila_xml_writer_wrapper_write_encoded, guththila_xml_writer_wrapper_get_xml, + guththila_xml_writer_wrapper_get_xml_size, guththila_xml_writer_wrapper_get_type, + guththila_xml_writer_wrapper_write_raw, guththila_xml_writer_wrapper_flush }; + +/****************************** Macros *******************************************/ + +#define AXIS2_INTF_TO_IMPL(p) ((guththila_xml_writer_wrapper_impl_t*)p) + +/******************************* End macro ***************************************/ + +AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL +axiom_xml_writer_create( + const axutil_env_t * env, + axis2_char_t * filename, + axis2_char_t * encoding, + int is_prefix_default, + int compression) +{ + guththila_xml_writer_wrapper_impl_t *writer_impl; + + AXIS2_ENV_CHECK(env, NULL); + + writer_impl = (guththila_xml_writer_wrapper_impl_t *)AXIS2_MALLOC(env->allocator, + sizeof(guththila_xml_writer_wrapper_impl_t)); + return &(writer_impl->writer); +} + +AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL +axiom_xml_writer_create_for_memory( + const axutil_env_t * env, + axis2_char_t * encoding, + int is_prefix_default, + int compression, + int type) +{ + guththila_xml_writer_wrapper_impl_t *writer_impl = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + writer_impl = (guththila_xml_writer_wrapper_impl_t *)AXIS2_MALLOC(env->allocator, + sizeof(guththila_xml_writer_wrapper_impl_t)); + + if(!writer_impl) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + /* creating guththila parser */ + /* guththila xml stream writer for memory */ + + writer_impl->wr = guththila_create_xml_stream_writer_for_memory(env); + + if(!(writer_impl->wr)) + { + AXIS2_FREE(env->allocator, writer_impl->wr); + AXIS2_FREE(env->allocator, writer_impl); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + writer_impl->writer.ops = NULL; + /* ops */ + writer_impl->writer.ops = &axiom_xml_writer_ops_var; + return &(writer_impl->writer); + +} + +void AXIS2_CALL +guththila_xml_writer_wrapper_free( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + if(AXIS2_INTF_TO_IMPL(writer)->wr) + { + guththila_xml_writer_free(AXIS2_INTF_TO_IMPL(writer)->wr, env); + } + + if(writer) + { + AXIS2_FREE(env->allocator, AXIS2_INTF_TO_IMPL(writer)); + } + +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname) +{ + int status = AXIS2_SUCCESS; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + guththila_write_start_element(AXIS2_INTF_TO_IMPL(writer)->wr, localname, env); + return status; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_start_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri) +{ + int status = AXIS2_SUCCESS; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + guththila_write_start_element_with_namespace(AXIS2_INTF_TO_IMPL(writer)->wr, namespace_uri, + localname, env); + return status; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_start_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, prefix, AXIS2_FAILURE); + guththila_write_start_element_with_prefix_and_namespace(AXIS2_INTF_TO_IMPL + (writer)->wr, prefix, namespace_uri, localname, env); + return AXIS2_SUCCESS; + +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_empty_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + guththila_write_empty_element(AXIS2_INTF_TO_IMPL(writer)->wr, localname, env); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_empty_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + guththila_write_empty_element_with_namespace(AXIS2_INTF_TO_IMPL(writer)->wr, namespace_uri, + localname, env); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_empty_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, prefix, AXIS2_FAILURE); + + guththila_write_empty_element_with_prefix_and_namespace(AXIS2_INTF_TO_IMPL + (writer)->wr, prefix, namespace_uri, localname, env); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_end_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + guththila_write_end_element(AXIS2_INTF_TO_IMPL(writer)->wr, env); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_end_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + guththila_write_end_document(AXIS2_INTF_TO_IMPL(writer)->wr, env); + return AXIS2_SUCCESS; + +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_attribute( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value) +{ + if(!value) + value = ""; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + guththila_write_attribute(AXIS2_INTF_TO_IMPL(writer)->wr, localname, value, env); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_attribute_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri) +{ + if(!value) + value = ""; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + + guththila_write_attribute_with_namespace(AXIS2_INTF_TO_IMPL(writer)->wr, namespace_uri, + localname, value, env); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_attribute_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri, + axis2_char_t * prefix) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, prefix, AXIS2_FAILURE); + guththila_write_attribute_with_prefix_and_namespace(AXIS2_INTF_TO_IMPL + (writer)->wr, prefix, namespace_uri, localname, value, env); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * namespace_uri) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + /* when default namespace comes is passed, prefix is null */ + if(prefix) + guththila_write_namespace(AXIS2_INTF_TO_IMPL(writer)->wr, prefix, namespace_uri, env); + else + guththila_write_default_namespace(AXIS2_INTF_TO_IMPL(writer)->wr, namespace_uri, env); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_default_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * namespace_uri) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + guththila_write_default_namespace(AXIS2_INTF_TO_IMPL(writer)->wr, namespace_uri, env); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_comment( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * value) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + guththila_write_comment(AXIS2_INTF_TO_IMPL(writer)->wr, value, env); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_processing_instruction( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, target, AXIS2_FAILURE); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_processing_instruction_data( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target, + axis2_char_t * data) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, target, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, data, AXIS2_FAILURE); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_cdata( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * data) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, data, AXIS2_FAILURE); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_dtd( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * dtd) +{ + /* AXIS2_ENV_CHECK( env, AXIS2_FAILURE); */ + /* AXIS2_PARAM_CHECK(env->error, dtd, AXIS2_FAILURE); */ + /* return guththila_write_dtd( */ + /* (axutil_env_t *)env, */ + /* AXIS2_INTF_TO_IMPL(writer)->parser, */ + /* dtd); */ + return 0; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_entity_ref( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * name) +{ + /* AXIS2_ENV_CHECK( env, AXIS2_FAILURE); */ + /* AXIS2_PARAM_CHECK(env->error, name, AXIS2_FAILURE); */ + /* return guththila_write_entity_ref( */ + /* (axutil_env_t *)env, */ + /* AXIS2_INTF_TO_IMPL(writer)->parser, */ + /* name); */ + return 0; + +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_start_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + guththila_write_start_document(AXIS2_INTF_TO_IMPL(writer)->wr, env, NULL, NULL); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_start_document_with_version( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, version, AXIS2_FAILURE); + guththila_write_start_document(AXIS2_INTF_TO_IMPL(writer)->wr, env, NULL, version); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_start_document_with_version_encoding( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * encoding, + axis2_char_t * version) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, encoding, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, version, AXIS2_FAILURE); + guththila_write_start_document(AXIS2_INTF_TO_IMPL(writer)->wr, env, encoding, version); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_characters( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, text, AXIS2_FAILURE); + guththila_write_characters(AXIS2_INTF_TO_IMPL(writer)->wr, text, env); + return AXIS2_SUCCESS; +} + +axis2_char_t *AXIS2_CALL +guththila_xml_writer_wrapper_get_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri) +{ + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, uri, NULL); + return guththila_get_prefix_for_namespace(AXIS2_INTF_TO_IMPL(writer)->wr, uri, env); +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_set_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * uri) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, prefix, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, uri, AXIS2_FAILURE); + guththila_write_namespace(AXIS2_INTF_TO_IMPL(writer)->wr, prefix, uri, env); + return AXIS2_SUCCESS; + +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_set_default_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, uri, AXIS2_FAILURE); + guththila_write_default_namespace(AXIS2_INTF_TO_IMPL(writer)->wr, uri, env); + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_encoded( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text, + int in_attr) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, text, AXIS2_FAILURE); + return AXIS2_SUCCESS; +} + +void *AXIS2_CALL +guththila_xml_writer_wrapper_get_xml( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + char *buffer = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + buffer = guththila_get_memory_buffer(AXIS2_INTF_TO_IMPL(writer)->wr, env); + return (void *)buffer; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_write_raw( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * content) +{ + if(!content) + { + return AXIS2_FAILURE; + } + else + { + guththila_write_to_buffer(AXIS2_INTF_TO_IMPL(writer)->wr, (char *)content, (int)strlen( + content), env); + return AXIS2_SUCCESS; + } +} + +unsigned int AXIS2_CALL +guththila_xml_writer_wrapper_get_xml_size( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + return guththila_get_memory_buffer_size(AXIS2_INTF_TO_IMPL(writer)->wr, env); +} + +int AXIS2_CALL +guththila_xml_writer_wrapper_get_type( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + return 0; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_flush( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +guththila_xml_writer_wrapper_end_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + /* nothing to do , + it is automatically taken care by the libxml2 writer */ + return AXIS2_SUCCESS; +} diff --git a/axiom/src/parser/libxml2/Makefile.am b/axiom/src/parser/libxml2/Makefile.am new file mode 100644 index 0000000..a5b4c75 --- /dev/null +++ b/axiom/src/parser/libxml2/Makefile.am @@ -0,0 +1,17 @@ +lib_LTLIBRARIES = libaxis2_parser.la + + +libaxis2_parser_la_SOURCES = ../xml_reader.c ../xml_writer.c \ + libxml2_reader_wrapper.c libxml2_writer_wrapper.c + +libaxis2_parser_la_LIBADD = @LIBXML2_LIBS@ \ + ../../../../util/src/libaxutil.la + +libaxis2_parser_la_LDFLAGS = -version-info $(VERSION_NO) +libaxis2_libxml2_la_LDFLAGS = -version-info $(VERSION_NO) + + +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/src/parser \ + -I ../../../../util/include \ + @LIBXML2_CFLAGS@ diff --git a/axiom/src/parser/libxml2/libxml2_reader_wrapper.c b/axiom/src/parser/libxml2/libxml2_reader_wrapper.c new file mode 100644 index 0000000..2510d49 --- /dev/null +++ b/axiom/src/parser/libxml2/libxml2_reader_wrapper.c @@ -0,0 +1,949 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include + + +int AXIS2_CALL axis2_libxml2_reader_wrapper_next( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +void AXIS2_CALL axis2_libxml2_reader_wrapper_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +int AXIS2_CALL axis2_libxml2_reader_wrapper_get_attribute_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_attribute_name_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_attribute_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_attribute_value_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_attribute_namespace_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + +axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_value( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +int AXIS2_CALL axis2_libxml2_reader_wrapper_get_namespace_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_namespace_uri_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_namespace_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i); + +axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_name( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_pi_target( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_pi_data( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_dtd( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +void AXIS2_CALL axis2_libxml2_reader_wrapper_xml_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + void *data); + +axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_char_set_encoding( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL axis2_libxml2_reader_wrapper_get_namespace_uri( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_namespace_uri_by_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + axis2_char_t * prefix); + +axis2_status_t +axis2_libxml2_reader_wrapper_fill_maps( + axiom_xml_reader_t * parser, + const axutil_env_t * env); + +void +axis2_libxml2_reader_wrapper_error_handler( + void *arg, + const char *msg, + int severities, + void *locator_ptr); + +static int +axis2_libxml2_reader_wrapper_read_input_callback( + void *ctx, + char *buffer, + int size); + +static int +axis2_libxml2_reader_wrapper_close_input_callback( + void *ctx); + +typedef struct axis2_libxml2_reader_wrapper_impl_t +{ + axiom_xml_reader_t parser; + + xmlTextReaderPtr reader; + + int current_event; + int current_attribute_count; + int current_namespace_count; + int event_map[18]; + + void *ctx; + /* assuming that max ns and attribute will be 20 */ + + int *namespace_map; + int *attribute_map; + + AXIS2_READ_INPUT_CALLBACK read_input_callback; + + AXIS2_CLOSE_INPUT_CALLBACK close_input_callback; + +} axis2_libxml2_reader_wrapper_impl_t; + +#define AXIS2_INTF_TO_IMPL(p) ((axis2_libxml2_reader_wrapper_impl_t*)p) +#define AXIS2_IMPL_TO_INTF(p) &(p->parser) + +static const axiom_xml_reader_ops_t axiom_xml_reader_ops_var = { axis2_libxml2_reader_wrapper_next, + axis2_libxml2_reader_wrapper_free, axis2_libxml2_reader_wrapper_get_attribute_count, + axis2_libxml2_reader_wrapper_get_attribute_name_by_number, + axis2_libxml2_reader_wrapper_get_attribute_prefix_by_number, + axis2_libxml2_reader_wrapper_get_attribute_value_by_number, + axis2_libxml2_reader_wrapper_get_attribute_namespace_by_number, + axis2_libxml2_reader_wrapper_get_value, axis2_libxml2_reader_wrapper_get_namespace_count, + axis2_libxml2_reader_wrapper_get_namespace_uri_by_number, + axis2_libxml2_reader_wrapper_get_namespace_prefix_by_number, + axis2_libxml2_reader_wrapper_get_prefix, axis2_libxml2_reader_wrapper_get_name, + axis2_libxml2_reader_wrapper_get_pi_target, axis2_libxml2_reader_wrapper_get_pi_data, + axis2_libxml2_reader_wrapper_get_dtd, axis2_libxml2_reader_wrapper_xml_free, + axis2_libxml2_reader_wrapper_get_char_set_encoding, + axis2_libxml2_reader_wrapper_get_namespace_uri, + axis2_libxml2_reader_wrapper_get_namespace_uri_by_prefix }; + +static axis2_status_t +axis2_libxml2_reader_wrapper_init_map( + axis2_libxml2_reader_wrapper_impl_t * parser) +{ + int i = 0; + if(parser) + { + for(i = 0; i < 18; i++) + { + parser->event_map[i] = -1; + } + + parser->event_map[XML_READER_TYPE_ELEMENT] = AXIOM_XML_READER_START_ELEMENT; + parser->event_map[XML_READER_TYPE_DOCUMENT] = AXIOM_XML_READER_START_DOCUMENT; + parser->event_map[XML_READER_TYPE_TEXT] = AXIOM_XML_READER_CHARACTER; + parser->event_map[XML_READER_TYPE_CDATA] = AXIOM_XML_READER_CHARACTER; + parser->event_map[XML_READER_TYPE_SIGNIFICANT_WHITESPACE] = AXIOM_XML_READER_SPACE; + parser->event_map[XML_READER_TYPE_WHITESPACE] = AXIOM_XML_READER_SPACE; + parser->event_map[XML_READER_TYPE_END_ELEMENT] = AXIOM_XML_READER_END_ELEMENT; + parser->event_map[XML_READER_TYPE_ENTITY_REFERENCE] = AXIOM_XML_READER_ENTITY_REFERENCE; + parser->event_map[XML_READER_TYPE_END_ENTITY] = AXIOM_XML_READER_SPACE; + parser->event_map[XML_READER_TYPE_ENTITY] = AXIOM_XML_READER_SPACE; + parser->event_map[XML_READER_TYPE_PROCESSING_INSTRUCTION] + = AXIOM_XML_READER_PROCESSING_INSTRUCTION; + parser->event_map[XML_READER_TYPE_COMMENT] = AXIOM_XML_READER_COMMENT; + parser->event_map[XML_READER_TYPE_DOCUMENT_TYPE] = AXIOM_XML_READER_DOCUMENT_TYPE; + return AXIS2_SUCCESS; + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_reader_init() +{ + xmlInitParser(); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_reader_cleanup() +{ + xmlCleanupParser(); + return AXIS2_SUCCESS; +} + +static axis2_libxml2_reader_wrapper_impl_t* +libxml2_reader_wrapper_create( + const axutil_env_t *env) +{ + axis2_libxml2_reader_wrapper_impl_t *wrapper_impl = NULL; + wrapper_impl = (axis2_libxml2_reader_wrapper_impl_t *)AXIS2_MALLOC(env->allocator, + sizeof(axis2_libxml2_reader_wrapper_impl_t)); + + if(!wrapper_impl) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create libxml2 reader wrapper"); + return NULL; + } + memset(wrapper_impl, 0, sizeof(axis2_libxml2_reader_wrapper_impl_t)); + wrapper_impl->attribute_map = NULL; + wrapper_impl->namespace_map = NULL; + wrapper_impl->close_input_callback = NULL; + wrapper_impl->read_input_callback = NULL; + wrapper_impl->ctx = NULL; + wrapper_impl->current_namespace_count = 0; + wrapper_impl->current_attribute_count = 0; + wrapper_impl->current_event = -1; + return wrapper_impl; +} + +AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL +axiom_xml_reader_create_for_file( + const axutil_env_t * env, + char *filename, + const axis2_char_t * encoding) +{ + + axis2_libxml2_reader_wrapper_impl_t *wrapper_impl = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, filename, NULL); + + wrapper_impl = libxml2_reader_wrapper_create(env); + if(!wrapper_impl) + { + return NULL; + } + + wrapper_impl->reader = xmlReaderForFile(filename, encoding, XML_PARSE_RECOVER); + if(!(wrapper_impl->reader)) + { + AXIS2_FREE(env->allocator, wrapper_impl); + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_CREATING_XML_STREAM_READER, AXIS2_FAILURE); + return NULL; + } + + xmlTextReaderSetErrorHandler(wrapper_impl->reader, + (xmlTextReaderErrorFunc)axis2_libxml2_reader_wrapper_error_handler, (void *)env); + wrapper_impl->current_event = -1; + wrapper_impl->ctx = NULL; + axis2_libxml2_reader_wrapper_init_map(wrapper_impl); + + wrapper_impl->parser.ops = &axiom_xml_reader_ops_var; + return &(wrapper_impl->parser); +} + +AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL +axiom_xml_reader_create_for_io( + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK read_input_callback, + AXIS2_CLOSE_INPUT_CALLBACK close_input_callback, + void *ctx, + const axis2_char_t * encoding) +{ + axis2_libxml2_reader_wrapper_impl_t *wrapper_impl = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + if(!read_input_callback) + { + return NULL; + } + + wrapper_impl = libxml2_reader_wrapper_create(env); + if(!wrapper_impl) + { + return NULL; + } + wrapper_impl->close_input_callback = NULL; + wrapper_impl->read_input_callback = NULL; + wrapper_impl->read_input_callback = read_input_callback; + wrapper_impl->close_input_callback = close_input_callback; + wrapper_impl->ctx = ctx; + if(wrapper_impl->close_input_callback) + { + wrapper_impl->reader = xmlReaderForIO(axis2_libxml2_reader_wrapper_read_input_callback, + axis2_libxml2_reader_wrapper_close_input_callback, wrapper_impl, NULL, encoding, + XML_PARSE_RECOVER); + } + else + { + wrapper_impl->reader = xmlReaderForIO(axis2_libxml2_reader_wrapper_read_input_callback, + NULL, wrapper_impl, NULL, encoding, XML_PARSE_RECOVER); + } + if(!(wrapper_impl->reader)) + { + AXIS2_FREE(env->allocator, wrapper_impl); + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_CREATING_XML_STREAM_READER, AXIS2_FAILURE); + return NULL; + } + + xmlTextReaderSetErrorHandler(wrapper_impl->reader, + (xmlTextReaderErrorFunc)axis2_libxml2_reader_wrapper_error_handler, (void *)env); + + wrapper_impl->current_event = -1; + + axis2_libxml2_reader_wrapper_init_map(wrapper_impl); + + wrapper_impl->parser.ops = &axiom_xml_reader_ops_var; + return &(wrapper_impl->parser); +} + +AXIS2_EXTERN axiom_xml_reader_t *AXIS2_CALL +axiom_xml_reader_create_for_memory( + const axutil_env_t * env, + void *container, + int size, + const axis2_char_t * encoding, + int type) +{ + axis2_libxml2_reader_wrapper_impl_t *wrapper_impl = NULL; + + AXIS2_PARAM_CHECK(env->error, container, NULL); + + wrapper_impl = libxml2_reader_wrapper_create(env); + if(!wrapper_impl) + { + return NULL; + } + wrapper_impl->close_input_callback = NULL; + wrapper_impl->read_input_callback = NULL; + wrapper_impl->ctx = NULL; + + if(AXIS2_XML_PARSER_TYPE_BUFFER == type) + { + wrapper_impl->reader = xmlReaderForMemory((axis2_char_t *)container, size, NULL, encoding, + XML_PARSE_RECOVER); + } + else if(AXIS2_XML_PARSER_TYPE_DOC == type) + { + wrapper_impl->reader = xmlReaderWalker((xmlDocPtr)container); + } + else + { + AXIS2_FREE(env->allocator, wrapper_impl); + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_XML_PARSER_INVALID_MEM_TYPE, AXIS2_FAILURE); + return NULL; + } + + if(!(wrapper_impl->reader)) + { + AXIS2_FREE(env->allocator, wrapper_impl); + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_CREATING_XML_STREAM_READER, AXIS2_FAILURE); + return NULL; + } + + if(AXIS2_XML_PARSER_TYPE_BUFFER == type) + { + xmlTextReaderSetErrorHandler(wrapper_impl->reader, + (xmlTextReaderErrorFunc)axis2_libxml2_reader_wrapper_error_handler, (void *)env); + } + + wrapper_impl->current_event = -1; + + axis2_libxml2_reader_wrapper_init_map(wrapper_impl); + + wrapper_impl->parser.ops = &axiom_xml_reader_ops_var; + return &(wrapper_impl->parser); +} + +int AXIS2_CALL +axis2_libxml2_reader_wrapper_next( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + int ret_val = 0; + int node = 2; + int empty_check = 0; + axis2_libxml2_reader_wrapper_impl_t *parser_impl; + AXIS2_ENV_CHECK(env, -1); + parser_impl = AXIS2_INTF_TO_IMPL(parser); + ret_val = xmlTextReaderRead(parser_impl->reader); + if(ret_val == 0) + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "xml stream is over "); + } + if(ret_val == -1) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, " error occurred in reading xml stream "); + return -1; + } + + if(ret_val == 1) + { + node = xmlTextReaderNodeType(parser_impl->reader); + parser_impl->current_event = parser_impl->event_map[node]; + parser_impl->current_attribute_count = 0; + parser_impl->current_namespace_count = 0; + + if(node == XML_READER_TYPE_ELEMENT) + { + empty_check = xmlTextReaderIsEmptyElement(parser_impl->reader); + axis2_libxml2_reader_wrapper_fill_maps(parser, env); + } + if(empty_check == 1) + { + parser_impl->current_event = AXIOM_XML_READER_EMPTY_ELEMENT; + return AXIOM_XML_READER_EMPTY_ELEMENT; + } + return parser_impl->event_map[node]; + } + else + { + return -1; + } +} + +/** + * If your application crashes here, it may be due to an earlier call to + * xmlCleanupParser() function. In client API, op_client create function has a call + * to axiom_xml_reader_init and op_client_free function has a call to axiom_xml_reader_cleanup + * function. You can avoid the call to axiom_xml_reader_cleanup using + * axis2_options_set_xml_parser_reset function in client API. + * refer to jira issue: https://issues.apache.org/jira/browse/AXIS2C-884 + */ +void AXIS2_CALL +axis2_libxml2_reader_wrapper_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + parser_impl = AXIS2_INTF_TO_IMPL(parser); + if(parser_impl->ctx) + { + AXIS2_FREE(env->allocator, parser_impl->ctx); + } + + if(parser_impl->reader) + { + xmlTextReaderClose(parser_impl->reader); + xmlFreeTextReader(parser_impl->reader); + } + if(parser_impl->namespace_map) + { + AXIS2_FREE(env->allocator, parser_impl->namespace_map); + parser_impl->namespace_map = NULL; + } + if(parser_impl->attribute_map) + { + AXIS2_FREE(env->allocator, parser_impl->attribute_map); + parser_impl->attribute_map = NULL; + } + AXIS2_FREE(env->allocator, AXIS2_INTF_TO_IMPL(parser)); + return; +} + +int AXIS2_CALL +axis2_libxml2_reader_wrapper_get_attribute_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + parser_impl = AXIS2_INTF_TO_IMPL(parser); + if(parser_impl->current_event == AXIOM_XML_READER_START_ELEMENT || parser_impl->current_event + == AXIOM_XML_READER_EMPTY_ELEMENT) + { + return parser_impl->current_attribute_count; + } + else + { + return 0; + } +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_attribute_name_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl; + AXIS2_ENV_CHECK(env, NULL); + parser_impl = AXIS2_INTF_TO_IMPL(parser); + + if(parser_impl->current_attribute_count > 0 && parser_impl->current_attribute_count >= i) + { + int ret = + xmlTextReaderMoveToAttributeNo(parser_impl->reader, parser_impl->attribute_map[i]); + if(ret == 1) + { + return (axis2_char_t *)xmlTextReaderLocalName(parser_impl->reader); + } + else + { + return NULL; + } + } + return NULL; +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_attribute_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + AXIS2_ENV_CHECK(env, NULL); + parser_impl = AXIS2_INTF_TO_IMPL(parser); + + if(parser_impl->current_attribute_count > 0 && parser_impl->current_attribute_count >= i) + { + int ret = + xmlTextReaderMoveToAttributeNo(parser_impl->reader, parser_impl->attribute_map[i]); + if(ret == 1) + { + return (axis2_char_t *)xmlTextReaderPrefix(parser_impl->reader); + } + else + { + return NULL; + } + } + return NULL; +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_attribute_value_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + + axis2_libxml2_reader_wrapper_impl_t *parser_impl; + AXIS2_ENV_CHECK(env, NULL); + parser_impl = AXIS2_INTF_TO_IMPL(parser); + + if(parser_impl->current_attribute_count > 0 && parser_impl->current_attribute_count >= i) + { + int ret = + xmlTextReaderMoveToAttributeNo(parser_impl->reader, parser_impl->attribute_map[i]); + if(ret == 1) + { + return (axis2_char_t *)xmlTextReaderValue(parser_impl->reader); + } + else + { + return NULL; + } + } + return NULL; +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_attribute_namespace_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl; + AXIS2_ENV_CHECK(env, NULL); + parser_impl = AXIS2_INTF_TO_IMPL(parser); + + if(parser_impl->current_attribute_count > 0 && parser_impl->current_attribute_count >= i) + { + int ret = + xmlTextReaderMoveToAttributeNo(parser_impl->reader, parser_impl->attribute_map[i]); + + if(ret == 1) + { + return (axis2_char_t *)xmlTextReaderNamespaceUri(parser_impl-> reader); + } + else + { + return NULL; + } + } + return NULL; +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_value( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + + AXIS2_ENV_CHECK(env, NULL); + parser_impl = AXIS2_INTF_TO_IMPL(parser); + return (axis2_char_t *)xmlTextReaderValue(parser_impl->reader); + +} + +int AXIS2_CALL +axis2_libxml2_reader_wrapper_get_namespace_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + parser_impl = AXIS2_INTF_TO_IMPL(parser); + if(parser_impl->current_event == AXIOM_XML_READER_START_ELEMENT || parser_impl->current_event + == AXIOM_XML_READER_EMPTY_ELEMENT) + { + return parser_impl->current_namespace_count; + } + else + { + return 0; + } +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_namespace_uri_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + AXIS2_ENV_CHECK(env, NULL); + parser_impl = AXIS2_INTF_TO_IMPL(parser); + + if(parser_impl->current_namespace_count > 0 && parser_impl->current_namespace_count >= i) + { + + int ret = + xmlTextReaderMoveToAttributeNo(parser_impl->reader, parser_impl->namespace_map[i]); + if(ret == 1) + { + return (axis2_char_t *)xmlTextReaderValue(parser_impl->reader); + } + else + return NULL; + } + return NULL; +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_namespace_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + AXIS2_ENV_CHECK(env, NULL); + parser_impl = AXIS2_INTF_TO_IMPL(parser); + + if(parser_impl->current_namespace_count > 0 && parser_impl->current_namespace_count >= i) + { + int ret = + xmlTextReaderMoveToAttributeNo(parser_impl->reader, parser_impl->namespace_map[i]); + + if(ret == 1) + { + return (axis2_char_t *)xmlTextReaderLocalName(parser_impl->reader); + } + else + { + return NULL; + } + } + return NULL; +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + parser_impl = AXIS2_INTF_TO_IMPL(parser); + xmlTextReaderMoveToElement(parser_impl->reader); + return (axis2_char_t *)xmlTextReaderPrefix(parser_impl->reader); +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_name( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + parser_impl = AXIS2_INTF_TO_IMPL(parser); + xmlTextReaderMoveToElement(parser_impl->reader); + return (axis2_char_t *)xmlTextReaderLocalName(parser_impl->reader); +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_pi_target( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + parser_impl = AXIS2_INTF_TO_IMPL(parser); + if(parser_impl->current_event == AXIOM_XML_READER_PROCESSING_INSTRUCTION) + { + return (axis2_char_t *)xmlTextReaderLocalName(parser_impl->reader); + } + else + { + return NULL; + } +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_dtd( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + parser_impl = AXIS2_INTF_TO_IMPL(parser); + if(parser_impl->current_event == AXIOM_XML_READER_DOCUMENT_TYPE) + { + return (axis2_char_t *)xmlTextReaderLocalName(parser_impl->reader); + } + else + { + return NULL; + } +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_pi_data( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + parser_impl = AXIS2_INTF_TO_IMPL(parser); + if(parser_impl->current_event == AXIOM_XML_READER_PROCESSING_INSTRUCTION) + { + return (axis2_char_t *)xmlTextReaderValue(parser_impl->reader); + } + else + { + return NULL; + } +} + +void AXIS2_CALL +axis2_libxml2_reader_wrapper_xml_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + void *data) +{ + AXIS2_ENV_CHECK(env, void); + if(data) + xmlFree(data); + return; +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_char_set_encoding( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + axis2_libxml2_reader_wrapper_impl_t *reader_impl = NULL; + reader_impl = AXIS2_INTF_TO_IMPL(parser); + return (axis2_char_t *)xmlTextReaderConstEncoding(reader_impl->reader); +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_namespace_uri( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + parser_impl = AXIS2_INTF_TO_IMPL(parser); + return (axis2_char_t *)xmlTextReaderNamespaceUri(parser_impl->reader); +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_reader_wrapper_get_namespace_uri_by_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + axis2_char_t * prefix) +{ + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + parser_impl = AXIS2_INTF_TO_IMPL(parser); + if(!prefix || axutil_strcmp(prefix, "") == 0) + { + return NULL; + } + return (axis2_char_t *)xmlTextReaderLookupNamespace(parser_impl->reader, + (const xmlChar *)prefix); +} + +axis2_status_t +axis2_libxml2_reader_wrapper_fill_maps( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + int libxml2_attribute_count = 0; + int attr_count = 0; + int ns_count = 0; + int i = 0; + char *q_name = NULL; + axis2_libxml2_reader_wrapper_impl_t *parser_impl = NULL; + int map_size = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + parser_impl = AXIS2_INTF_TO_IMPL(parser); + + libxml2_attribute_count = xmlTextReaderAttributeCount(parser_impl->reader); + if(libxml2_attribute_count == 0) + { + parser_impl->current_attribute_count = 0; + parser_impl->current_namespace_count = 0; + return AXIS2_SUCCESS; + } + map_size = libxml2_attribute_count + 1; + if(parser_impl->namespace_map) + { + AXIS2_FREE(env->allocator, parser_impl->namespace_map); + parser_impl->namespace_map = NULL; + } + if(parser_impl->attribute_map) + { + AXIS2_FREE(env->allocator, parser_impl->attribute_map); + parser_impl->attribute_map = NULL; + } + parser_impl->attribute_map = AXIS2_MALLOC(env->allocator, sizeof(int) * map_size); + memset(parser_impl->attribute_map, 0, map_size * sizeof(int)); + + parser_impl->namespace_map = AXIS2_MALLOC(env->allocator, sizeof(int) * map_size); + memset(parser_impl->namespace_map, 0, map_size * sizeof(int)); + + for(i = 0; i < map_size; i++) + { + parser_impl->namespace_map[i] = -1; + parser_impl->attribute_map[i] = -1; + } + + for(i = 0; i < libxml2_attribute_count; i++) + { + xmlTextReaderMoveToAttributeNo(parser_impl->reader, i); + q_name = (char *)xmlTextReaderName(parser_impl->reader); + if(q_name) + { + if((strcmp(q_name, "xmlns") == 0) || (strncmp(q_name, "xmlns:", 6) == 0)) + { + /* found a namespace */ + ns_count++; + parser_impl->namespace_map[ns_count] = i; + } + else + { + /* found an attribute */ + attr_count++; + parser_impl->attribute_map[attr_count] = i; + } + + xmlFree(q_name); + q_name = NULL; + } + + parser_impl->current_attribute_count = attr_count; + parser_impl->current_namespace_count = ns_count; + } + return AXIS2_SUCCESS; +} + +static int +axis2_libxml2_reader_wrapper_read_input_callback( + void *ctx, + char *buffer, + int size) +{ + return ((axis2_libxml2_reader_wrapper_impl_t *)ctx)-> read_input_callback(buffer, size, + ((axis2_libxml2_reader_wrapper_impl_t *)ctx)->ctx); +} + +void +axis2_libxml2_reader_wrapper_error_handler( + void *arg, + const char *msg, + int severities, + void *locator_ptr) +{ + const axutil_env_t *env = NULL; + env = (const axutil_env_t *)arg; + + switch(severities) + { + case XML_PARSER_SEVERITY_VALIDITY_WARNING: + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "%s VALIDITY WARNTING", msg); + } + break; + case XML_PARSER_SEVERITY_VALIDITY_ERROR: + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "%s -- VALIDITY ERROR", msg); + } + break; + case XML_PARSER_SEVERITY_WARNING: + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "%s -- VALIDITY ERROR", msg); + } + break; + case XML_PARSER_SEVERITY_ERROR: + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "%s -- SEVERITY_ERROR", msg); + } + break; + default: + break; + } +} + +static int +axis2_libxml2_reader_wrapper_close_input_callback( + void *ctx) +{ + return ((axis2_libxml2_reader_wrapper_impl_t *)ctx)-> close_input_callback( + ((axis2_libxml2_reader_wrapper_impl_t *)ctx)-> ctx); +} diff --git a/axiom/src/parser/libxml2/libxml2_writer_wrapper.c b/axiom/src/parser/libxml2/libxml2_writer_wrapper.c new file mode 100644 index 0000000..4c889d4 --- /dev/null +++ b/axiom/src/parser/libxml2/libxml2_writer_wrapper.c @@ -0,0 +1,1571 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*******************************************************************************/ + +#define ENCODING "ISO-8859-1" + +#define AXIS2_XMLNS_NAMESPACE_URI "http://www.w3.org/XML/1998/namespace" +#define AXIS2_XMLNS_PREFIX "xml" + +typedef struct uri_prefix_element +{ + axis2_char_t *prefix; + + axis2_char_t *uri; + + axis2_char_t *real_prefix; + + axis2_char_t *key; + +} uri_prefix_element_t; + +typedef struct axis2_libxml2_writer_wrapper_impl +{ + axiom_xml_writer_t writer; + + xmlTextWriterPtr xml_writer; + + xmlBufferPtr buffer; + + xmlDocPtr doc; + + int writer_type; + + axis2_char_t *encoding; + + int is_prefix_defaulting; + + int compression; + + axutil_stack_t *stack; + + axis2_bool_t in_empty_element; + + axis2_bool_t in_start_element; + + axutil_hash_t *uri_prefix_map; + + uri_prefix_element_t *default_lang_namespace; + +} axis2_libxml2_writer_wrapper_impl_t; + +#define AXIS2_INTF_TO_IMPL(p) ((axis2_libxml2_writer_wrapper_impl_t*)p) + +void AXIS2_CALL axis2_libxml2_writer_wrapper_free( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_end_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_start_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_start_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_empty_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_empty_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_empty_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_end_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_end_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_attribute( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_attribute_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_attribute_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri, + axis2_char_t * prefix); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * namespace_uri); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_default_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * namespace_uri); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_comment( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * value); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_processing_instruction( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_processing_instruction_data( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target, + axis2_char_t * data); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_cdata( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * data); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_dtd( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * dtd); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_entity_ref( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * name); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_start_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_start_document_with_version( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_start_document_with_version_encoding( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * encoding, + axis2_char_t * version); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_characters( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text); + +axis2_char_t *AXIS2_CALL axis2_libxml2_writer_wrapper_get_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_set_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * uri); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_set_default_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_encoded( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text, + int in_attr); + +void *AXIS2_CALL axis2_libxml2_writer_wrapper_get_xml( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +unsigned int AXIS2_CALL axis2_libxml2_writer_wrapper_get_xml_size( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_flush( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +int AXIS2_CALL axis2_libxml2_writer_wrapper_get_type( + axiom_xml_writer_t * writer, + const axutil_env_t * env); + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_raw( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * content); + +static axis2_status_t +axis2_libxml2_writer_wrapper_push( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + const axis2_char_t * uri, + const axis2_char_t * prefix); + +static axis2_bool_t +axis2_libxml2_writer_wrapper_is_namespace_declared( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * key); + +static void +uri_prefix_element_free( + uri_prefix_element_t * up_element, + const axutil_env_t * env); + +static uri_prefix_element_t * +uri_prefix_element_create( + const axutil_env_t * env, + const axis2_char_t * uri, + const axis2_char_t * prefix, + const axis2_char_t * real_prefix, + const axis2_char_t * key); + +static void +create_key_from_uri_prefix( + const axutil_env_t * env, + const axis2_char_t * uri, + const axis2_char_t * prefix, + axis2_char_t * array); + +static axis2_char_t * +axis2_libxml2_writer_wrapper_find_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri); + +static uri_prefix_element_t * +axis2_libxml2_writer_wrapper_find_prefix_in_context( + axutil_array_list_t * context, + const axutil_env_t * env, + axis2_char_t * uri); + +static const axiom_xml_writer_ops_t axiom_xml_writer_ops_var = { axis2_libxml2_writer_wrapper_free, + axis2_libxml2_writer_wrapper_write_start_element, + axis2_libxml2_writer_wrapper_end_start_element, + axis2_libxml2_writer_wrapper_write_start_element_with_namespace, + axis2_libxml2_writer_wrapper_write_start_element_with_namespace_prefix, + axis2_libxml2_writer_wrapper_write_empty_element, + axis2_libxml2_writer_wrapper_write_empty_element_with_namespace, + axis2_libxml2_writer_wrapper_write_empty_element_with_namespace_prefix, + axis2_libxml2_writer_wrapper_write_end_element, + axis2_libxml2_writer_wrapper_write_end_document, axis2_libxml2_writer_wrapper_write_attribute, + axis2_libxml2_writer_wrapper_write_attribute_with_namespace, + axis2_libxml2_writer_wrapper_write_attribute_with_namespace_prefix, + axis2_libxml2_writer_wrapper_write_namespace, + axis2_libxml2_writer_wrapper_write_default_namespace, + axis2_libxml2_writer_wrapper_write_comment, + axis2_libxml2_writer_wrapper_write_processing_instruction, + axis2_libxml2_writer_wrapper_write_processing_instruction_data, + axis2_libxml2_writer_wrapper_write_cdata, axis2_libxml2_writer_wrapper_write_dtd, + axis2_libxml2_writer_wrapper_write_entity_ref, + axis2_libxml2_writer_wrapper_write_start_document, + axis2_libxml2_writer_wrapper_write_start_document_with_version, + axis2_libxml2_writer_wrapper_write_start_document_with_version_encoding, + axis2_libxml2_writer_wrapper_write_characters, axis2_libxml2_writer_wrapper_get_prefix, + axis2_libxml2_writer_wrapper_set_prefix, axis2_libxml2_writer_wrapper_set_default_prefix, + axis2_libxml2_writer_wrapper_write_encoded, axis2_libxml2_writer_wrapper_get_xml, + axis2_libxml2_writer_wrapper_get_xml_size, axis2_libxml2_writer_wrapper_get_type, + axis2_libxml2_writer_wrapper_write_raw, axis2_libxml2_writer_wrapper_flush }; + +AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL +axiom_xml_writer_create( + const axutil_env_t * env, + axis2_char_t * filename, + axis2_char_t * encoding, + int is_prefix_default, + int compression) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + AXIS2_ENV_CHECK(env, NULL); + writer_impl = (axis2_libxml2_writer_wrapper_impl_t *)AXIS2_MALLOC(env->allocator, + sizeof(axis2_libxml2_writer_wrapper_impl_t)); + if(!writer_impl) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create an XML writer wrapper"); + return NULL; + } + writer_impl->xml_writer = xmlNewTextWriterFilename(filename, compression); + + if(!(writer_impl->xml_writer)) + { + AXIS2_FREE(env->allocator, writer_impl); + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_CREATING_XML_STREAM_WRITER, AXIS2_FAILURE); + return NULL; + } + writer_impl->buffer = NULL; + writer_impl->encoding = NULL; + writer_impl->compression = 0; + writer_impl->in_empty_element = AXIS2_FALSE; + writer_impl->in_start_element = AXIS2_FALSE; + writer_impl->stack = NULL; + writer_impl->uri_prefix_map = NULL; + writer_impl->default_lang_namespace = NULL; + + writer_impl->writer_type = AXIS2_XML_PARSER_TYPE_FILE; + writer_impl->compression = compression; + + if(encoding) + { + writer_impl->encoding = axutil_strdup(env, encoding); + } + else + { + writer_impl->encoding = axutil_strdup(env, ENCODING); + } + + writer_impl->uri_prefix_map = axutil_hash_make(env); + if(!(writer_impl->uri_prefix_map)) + { + axis2_libxml2_writer_wrapper_free(&(writer_impl->writer), env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create URI prefix hash map"); + return NULL; + } + writer_impl->writer.ops = &axiom_xml_writer_ops_var; + return &(writer_impl->writer); +} + +AXIS2_EXTERN axiom_xml_writer_t *AXIS2_CALL +axiom_xml_writer_create_for_memory( + const axutil_env_t * env, + axis2_char_t * encoding, + int is_prefix_default, + int compression, + int type) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + AXIS2_ENV_CHECK(env, NULL); + writer_impl = (axis2_libxml2_writer_wrapper_impl_t *)AXIS2_MALLOC(env->allocator, + sizeof(axis2_libxml2_writer_wrapper_impl_t)); + if(!writer_impl) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create writer wrapper"); + return NULL; + } + + writer_impl->encoding = NULL; + writer_impl->buffer = NULL; + writer_impl->doc = NULL; + writer_impl->in_empty_element = AXIS2_FALSE; + writer_impl->in_start_element = AXIS2_FALSE; + writer_impl->stack = NULL; + writer_impl->uri_prefix_map = NULL; + writer_impl->default_lang_namespace = NULL; + writer_impl->compression = compression; + + if(AXIS2_XML_PARSER_TYPE_BUFFER == type) + { + writer_impl->writer_type = AXIS2_XML_PARSER_TYPE_BUFFER; + writer_impl->buffer = xmlBufferCreate(); + if(!(writer_impl->buffer)) + { + axis2_libxml2_writer_wrapper_free(&(writer_impl->writer), env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "No memory. Cannot create a buffer for writer wrapper"); + return NULL; + } + + writer_impl->xml_writer = xmlNewTextWriterMemory(writer_impl->buffer, 0); + } + else if(AXIS2_XML_PARSER_TYPE_DOC == type) + { + writer_impl->writer_type = AXIS2_XML_PARSER_TYPE_DOC; + writer_impl->xml_writer = xmlNewTextWriterDoc(&writer_impl->doc, 0); + } + else + { + axis2_libxml2_writer_wrapper_free(&(writer_impl->writer), env); + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_XML_PARSER_INVALID_MEM_TYPE, AXIS2_FAILURE); + return NULL; + } + + if(!(writer_impl->xml_writer)) + { + axis2_libxml2_writer_wrapper_free(&(writer_impl->writer), env); + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_CREATING_XML_STREAM_WRITER, AXIS2_FAILURE); + return NULL; + } + + if(encoding) + { + writer_impl->encoding = axutil_strdup(env, encoding); + } + else + { + writer_impl->encoding = axutil_strdup(env, ENCODING); + } + + writer_impl->uri_prefix_map = axutil_hash_make(env); + if(!(writer_impl->uri_prefix_map)) + { + axis2_libxml2_writer_wrapper_free(&(writer_impl->writer), env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create URI prefix hash map"); + return NULL; + } + writer_impl->stack = axutil_stack_create(env); + if(!(writer_impl->stack)) + { + axis2_libxml2_writer_wrapper_free(&(writer_impl->writer), env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "No memory. Cannot create the stack for writer wrapper"); + return NULL; + } + + writer_impl->writer.ops = &axiom_xml_writer_ops_var; + + return &(writer_impl->writer); +} + +void AXIS2_CALL +axis2_libxml2_writer_wrapper_free( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + if(writer_impl->xml_writer) + { + xmlFreeTextWriter(writer_impl->xml_writer); + writer_impl->xml_writer = NULL; + } + if(writer_impl->buffer) + { + xmlBufferFree(writer_impl->buffer); + writer_impl->buffer = NULL; + } + if(writer_impl->encoding) + { + AXIS2_FREE(env->allocator, writer_impl->encoding); + writer_impl->encoding = NULL; + } + if(writer_impl->uri_prefix_map) + { + axutil_hash_free(writer_impl->uri_prefix_map, env); + writer_impl->uri_prefix_map = NULL; + } + if(writer_impl->stack) + { + axutil_stack_free(writer_impl->stack, env); + writer_impl->stack = NULL; + } + if(writer_impl->default_lang_namespace) + { + uri_prefix_element_free(writer_impl->default_lang_namespace, env); + writer_impl->default_lang_namespace = NULL; + } + + AXIS2_FREE(env->allocator, writer_impl); + writer_impl = NULL; + return; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname) +{ + int status = 0; + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + writer_impl->in_start_element = AXIS2_TRUE; + + status = xmlTextWriterStartElement(writer_impl->xml_writer, (xmlChar *)localname); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_START_ELEMENT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_end_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + /* nothing to do , + it is automatically taken care by the libxml2 writer */ + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_start_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + status = xmlTextWriterStartElementNS(writer_impl->xml_writer, + NULL, BAD_CAST localname, NULL); + + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_START_ELEMENT_WITH_NAMESPACE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_start_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, prefix, AXIS2_FAILURE); + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + writer_impl->in_start_element = AXIS2_TRUE; + + status = xmlTextWriterStartElementNS(writer_impl->xml_writer, + BAD_CAST prefix, + BAD_CAST localname, BAD_CAST NULL); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_START_ELEMENT_WITH_NAMESPACE_PREFIX, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_empty_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname) +{ + int status = 0; + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + status = xmlTextWriterStartElement(writer_impl->xml_writer, (xmlChar *)localname); + + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_EMPTY_ELEMENT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + status = xmlTextWriterEndElement(writer_impl->xml_writer); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_EMPTY_ELEMENT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_empty_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + status = xmlTextWriterStartElementNS(writer_impl->xml_writer, + NULL, BAD_CAST localname, + BAD_CAST namespace_uri); + + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_EMPTY_ELEMENT_WITH_NAMESPACE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + status = xmlTextWriterEndElement(writer_impl->xml_writer); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_EMPTY_ELEMENT_WITH_NAMESPACE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_empty_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, prefix, AXIS2_FAILURE); + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + status = xmlTextWriterStartElementNS(writer_impl->xml_writer, + BAD_CAST prefix, + BAD_CAST localname, BAD_CAST NULL); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_START_ELEMENT_WITH_NAMESPACE_PREFIX, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + status = xmlTextWriterEndElement(writer_impl->xml_writer); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_EMPTY_ELEMENT_WITH_NAMESPACE_PREFIX, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_end_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + writer_impl->in_start_element = AXIS2_FALSE; + /* write an empty element in case the element is empty, + status = xmlTextWriterFullEndElement(writer_impl->xml_writer); + Above call write it like . + Call below will write it like */ + status = xmlTextWriterEndElement(writer_impl->xml_writer); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_END_ELEMENT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_end_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + status = xmlTextWriterEndDocument(writer_impl->xml_writer); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_END_DOCUMENT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_attribute( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + if(!value) + { + value = ""; + } + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + status = xmlTextWriterWriteAttribute(writer_impl->xml_writer, + BAD_CAST localname, BAD_CAST value); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_ATTRIBUTE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_attribute_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + + if(!value) + { + value = ""; + } + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + status = xmlTextWriterWriteAttributeNS(writer_impl->xml_writer, + NULL, BAD_CAST localname, + BAD_CAST NULL, BAD_CAST value); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_ATTRIBUTE_WITH_NAMESPACE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_attribute_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri, + axis2_char_t * prefix) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, localname, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, prefix, AXIS2_FAILURE); + + if(!value) + { + value = ""; + } + writer_impl = AXIS2_INTF_TO_IMPL(writer); + status = xmlTextWriterWriteAttributeNS(writer_impl->xml_writer, + BAD_CAST prefix, BAD_CAST localname, + BAD_CAST NULL, BAD_CAST value); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_ATTRIBUTE_WITH_NAMESPACE_PREFIX, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +/** need to work on this */ +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * namespace_uri) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + char *xmlnsprefix = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE); + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + if(prefix && (axutil_strcmp(prefix, "") != 0)) + { + xmlnsprefix = (axis2_char_t *)AXIS2_MALLOC(env->allocator, (sizeof(char) * (axutil_strlen( + prefix) + 7))); + sprintf(xmlnsprefix, "xmlns:%s", prefix); + } + else + { + xmlnsprefix = axutil_strdup(env, "xmlns"); + } + + status = xmlTextWriterWriteAttribute(writer_impl->xml_writer, + BAD_CAST xmlnsprefix, + BAD_CAST namespace_uri); + AXIS2_FREE(env->allocator, xmlnsprefix); + xmlnsprefix = NULL; + + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_ATTRIBUTE_WITH_NAMESPACE_PREFIX, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + AXIS2_FREE(env->allocator, xmlnsprefix); + xmlnsprefix = NULL; + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_default_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * namespace_uri) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + axis2_char_t *xmlns = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, namespace_uri, AXIS2_FAILURE) + xmlns = AXIS2_MALLOC(env->allocator, + sizeof(axis2_char_t) * (strlen("xmlns") + 1)); + sprintf(xmlns, "xmlns"); + status = xmlTextWriterWriteAttribute(writer_impl->xml_writer, + (const xmlChar *) xmlns, + BAD_CAST namespace_uri); + + if(xmlns) + { + AXIS2_FREE(env->allocator, xmlns); + xmlns = NULL; + } + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_DEFAULT_NAMESPACE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_comment( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * value) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + status = xmlTextWriterWriteComment(writer_impl->xml_writer, BAD_CAST value); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_COMMENT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_processing_instruction( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, target, AXIS2_FAILURE); + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + status = xmlTextWriterStartPI(writer_impl->xml_writer, BAD_CAST target); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_PROCESSING_INSTRUCTION, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_processing_instruction_data( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target, + axis2_char_t * data) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, target, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, data, AXIS2_FAILURE); + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + status = xmlTextWriterWritePI(writer_impl->xml_writer, + BAD_CAST target, BAD_CAST data); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_PROCESSING_INSTRUCTION, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_cdata( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * data) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, data, AXIS2_FAILURE); + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + status = xmlTextWriterWriteCDATA(writer_impl->xml_writer, BAD_CAST data); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_CDATA, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_dtd( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * dtd) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, dtd, AXIS2_FAILURE); + + status = xmlTextWriterStartDTD(writer_impl->xml_writer, + BAD_CAST dtd, NULL, NULL); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_DTD, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_entity_ref( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * name) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, name, AXIS2_FAILURE); + return AXIS2_FAILURE; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_start_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + axis2_libxml2_writer_wrapper_impl_t *wrapper_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + wrapper_impl = AXIS2_INTF_TO_IMPL(writer); + status = xmlTextWriterStartDocument(wrapper_impl->xml_writer, NULL, NULL, NULL); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_START_DOCUMENT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_start_document_with_version( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version) +{ + axis2_libxml2_writer_wrapper_impl_t *wrapper_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, version, AXIS2_FAILURE); + + wrapper_impl = AXIS2_INTF_TO_IMPL(writer); + status = xmlTextWriterStartDocument(wrapper_impl->xml_writer, version, NULL, NULL); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_START_DOCUMENT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_start_document_with_version_encoding( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * encoding, + axis2_char_t * version) +{ + axis2_libxml2_writer_wrapper_impl_t *wrapper_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + wrapper_impl = AXIS2_INTF_TO_IMPL(writer); + status = xmlTextWriterStartDocument(wrapper_impl->xml_writer, version, encoding, NULL); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_START_DOCUMENT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_characters( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, text, AXIS2_FAILURE); + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + status = xmlTextWriterWriteString(writer_impl->xml_writer, BAD_CAST text); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_START_DOCUMENT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +axis2_char_t *AXIS2_CALL +axis2_libxml2_writer_wrapper_get_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + AXIS2_PARAM_CHECK(env->error, uri, NULL); + writer_impl = AXIS2_INTF_TO_IMPL(writer); + if(!uri || axutil_strcmp(uri, "") == 0) + { + return NULL; + } + return axis2_libxml2_writer_wrapper_find_prefix(writer, env, uri); +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_set_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * uri) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + + axis2_bool_t is_declared = AXIS2_FALSE; + axis2_char_t key[1024]; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, prefix, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, uri, AXIS2_FAILURE); + writer_impl = AXIS2_INTF_TO_IMPL(writer); + if(axutil_strcmp(uri, "") == 0) + { + return AXIS2_FAILURE; + } + + create_key_from_uri_prefix(env, uri, prefix, key); + + is_declared = axis2_libxml2_writer_wrapper_is_namespace_declared(writer, env, key); + if(!is_declared) + { + return axis2_libxml2_writer_wrapper_push(writer, env, uri, prefix); + } + return AXIS2_FAILURE; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_set_default_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri) +{ + axis2_bool_t is_declared = AXIS2_FALSE; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, uri, AXIS2_FAILURE); + if(axutil_strcmp(uri, "") == 0) + { + return AXIS2_FAILURE; + } + is_declared = axis2_libxml2_writer_wrapper_is_namespace_declared(writer, env, uri); + if(!is_declared) + { + return axis2_libxml2_writer_wrapper_push(writer, env, uri, NULL); + } + return AXIS2_FAILURE; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_encoded( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text, + int in_attr) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, text, AXIS2_FAILURE); + writer_impl = AXIS2_INTF_TO_IMPL(writer); + return AXIS2_FAILURE; +} + +void *AXIS2_CALL +axis2_libxml2_writer_wrapper_get_xml( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + writer_impl = AXIS2_INTF_TO_IMPL(writer); + if(writer_impl->writer_type == AXIS2_XML_PARSER_TYPE_BUFFER) + { + int output_bytes = 0; + output_bytes = xmlTextWriterFlush(writer_impl->xml_writer); + return writer_impl->buffer->content; + } + else if(writer_impl->writer_type == AXIS2_XML_PARSER_TYPE_DOC) + { + return (void *)writer_impl->doc; + } + else if(writer_impl->writer_type == AXIS2_XML_PARSER_TYPE_FILE) + { + return NULL; + } + + return NULL; +} + +unsigned int AXIS2_CALL +axis2_libxml2_writer_wrapper_get_xml_size( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + if(writer_impl->writer_type == AXIS2_XML_PARSER_TYPE_BUFFER) + { + return writer_impl->buffer->use; + } + else + { + return 0; + } +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_flush( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + writer_impl = AXIS2_INTF_TO_IMPL(writer); + if(writer_impl->xml_writer) + { + int ret = 0; + ret = xmlTextWriterFlush(writer_impl->xml_writer); + if(ret > -1) + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +int AXIS2_CALL +axis2_libxml2_writer_wrapper_get_type( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + return writer_impl->writer_type; +} + +static axis2_status_t +axis2_libxml2_writer_wrapper_push( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + const axis2_char_t * uri, + const axis2_char_t * prefix) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + axutil_array_list_t *current_list = NULL; + axis2_char_t key[1024]; + const axis2_char_t *temp_prefix = NULL; + writer_impl = AXIS2_INTF_TO_IMPL(writer); + if(!prefix || axutil_strcmp(prefix, "") == 0) + { + temp_prefix = "default"; + } + else + { + temp_prefix = prefix; + } + + if(writer_impl->stack) + { + current_list = (axutil_array_list_t *)axutil_stack_get(writer_impl->stack, env); + + if(current_list) + { + uri_prefix_element_t *ele = NULL; + create_key_from_uri_prefix(env, uri, prefix, key); + + ele = uri_prefix_element_create(env, uri, temp_prefix, prefix, key); + if(ele) + { + axutil_array_list_add(current_list, env, ele); + axutil_hash_set(writer_impl->uri_prefix_map, ele->key, AXIS2_HASH_KEY_STRING, + ele->prefix); + } + } + } + return AXIS2_SUCCESS; +} + +static axis2_bool_t +axis2_libxml2_writer_wrapper_is_namespace_declared( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * key) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + writer_impl = AXIS2_INTF_TO_IMPL(writer); + if(writer_impl->uri_prefix_map && NULL != key) + { + void *ret = NULL; + ret = axutil_hash_get(writer_impl->uri_prefix_map, key, AXIS2_HASH_KEY_STRING); + if(ret) + { + return AXIS2_TRUE; + } + } + return AXIS2_FALSE; +} + +static void +uri_prefix_element_free( + uri_prefix_element_t * up_element, + const axutil_env_t * env) +{ + if(up_element) + { + if(up_element->uri) + { + AXIS2_FREE(env->allocator, up_element->uri); + up_element->uri = NULL; + } + if(up_element->prefix) + { + AXIS2_FREE(env->allocator, up_element->prefix); + up_element->prefix = NULL; + } + if(up_element->key) + { + AXIS2_FREE(env->allocator, up_element->key); + up_element->key = NULL; + } + if(up_element->real_prefix) + { + AXIS2_FREE(env->allocator, up_element->real_prefix); + up_element->real_prefix = NULL; + } + AXIS2_FREE(env->allocator, up_element); + up_element = NULL; + } + return; +} + +static uri_prefix_element_t * +uri_prefix_element_create( + const axutil_env_t * env, + const axis2_char_t * uri, + const axis2_char_t * prefix, + const axis2_char_t * real_prefix, + const axis2_char_t * key) +{ + uri_prefix_element_t *up_element = NULL; + up_element = (uri_prefix_element_t *)AXIS2_MALLOC(env->allocator, sizeof(uri_prefix_element_t)); + + if(!uri) + { + return NULL; + } + + if(!up_element) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create URI prefix element %s", + uri); + return NULL; + } + up_element->key = NULL; + up_element->prefix = NULL; + up_element->uri = NULL; + up_element->real_prefix = NULL; + + up_element->uri = axutil_strdup(env, uri); + if(!up_element->uri) + { + uri_prefix_element_free(up_element, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + up_element->prefix = axutil_strdup(env, prefix); + if(prefix && !up_element->prefix) + { + uri_prefix_element_free(up_element, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + up_element->key = axutil_strdup(env, key); + if(key && !up_element->key) + { + uri_prefix_element_free(up_element, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + up_element->real_prefix = axutil_strdup(env, real_prefix); + + return up_element; +} + +static void +create_key_from_uri_prefix( + const axutil_env_t * env, + const axis2_char_t * uri, + const axis2_char_t * prefix, + axis2_char_t * array) +{ + if(!prefix) + { + prefix = ""; + } + sprintf(array, "%s%s%s", uri, "|", prefix); +} + +static axis2_char_t * +axis2_libxml2_writer_wrapper_find_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int size = 0; + int i = 0; + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + + if(!writer_impl->stack) + { + return NULL; + } + size = axutil_stack_size(writer_impl->stack, env); + if(size <= 0) + { + return NULL; + } + + for(i = size - 1; i < 0; i--) + { + axutil_array_list_t *context = NULL; + void *value = NULL; + value = axutil_stack_get_at(writer_impl->stack, env, i); + if(value) + { + uri_prefix_element_t *up_ele = NULL; + context = (axutil_array_list_t *)value; + up_ele = axis2_libxml2_writer_wrapper_find_prefix_in_context(context, env, uri); + if(up_ele) + { + return up_ele->real_prefix; + } + } + } + return NULL; +} + +static uri_prefix_element_t * +axis2_libxml2_writer_wrapper_find_prefix_in_context( + axutil_array_list_t * context, + const axutil_env_t * env, + axis2_char_t * uri) +{ + int size = 0; + int i = 0; + if(!context) + { + return NULL; + } + size = axutil_array_list_size(context, env); + for(i = 0; i < size; i++) + { + uri_prefix_element_t *ele = NULL; + void *value = NULL; + value = axutil_array_list_get(context, env, i); + if(value) + { + ele = (uri_prefix_element_t *)value; + if(ele->uri && axutil_strcmp(uri, ele->uri)) + { + return ele; + } + } + } + return NULL; +} + +axis2_status_t AXIS2_CALL +axis2_libxml2_writer_wrapper_write_raw( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * content) +{ + axis2_libxml2_writer_wrapper_impl_t *writer_impl = NULL; + int status = 0; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, content, AXIS2_FAILURE); + + writer_impl = AXIS2_INTF_TO_IMPL(writer); + status = xmlTextWriterWriteRaw(writer_impl->xml_writer, BAD_CAST content); + if(status < 0) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_WRITING_DATA_SOURCE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} diff --git a/axiom/src/parser/xml_reader.c b/axiom/src/parser/xml_reader.c new file mode 100644 index 0000000..47e2334 --- /dev/null +++ b/axiom/src/parser/xml_reader.c @@ -0,0 +1,203 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +AXIS2_EXTERN int AXIS2_CALL +axiom_xml_reader_next( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->next(parser, env); +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_xml_reader_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + (parser)->ops->free(parser, env); +} + +AXIS2_EXTERN int AXIS2_CALL +axiom_xml_reader_get_attribute_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->get_attribute_count(parser, env); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_attribute_name_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + return (parser)->ops->get_attribute_name_by_number(parser, env, i); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_attribute_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + return (parser)->ops->get_attribute_prefix_by_number(parser, env, i); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_attribute_value_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + return (parser)->ops->get_attribute_value_by_number(parser, env, i); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_attribute_namespace_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + return (parser)->ops->get_attribute_namespace_by_number(parser, env, i); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_value( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->get_value(parser, env); +} + +AXIS2_EXTERN int AXIS2_CALL +axiom_xml_reader_get_namespace_count( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->get_namespace_count(parser, env); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_namespace_uri_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + return (parser)->ops->get_namespace_uri_by_number(parser, env, i); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_namespace_prefix_by_number( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + int i) +{ + return (parser)->ops->get_namespace_prefix_by_number(parser, env, i); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->get_prefix(parser, env); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_name( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->get_name(parser, env); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_pi_target( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->get_pi_target(parser, env); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_pi_data( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->get_pi_data(parser, env); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_dtd( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->get_dtd(parser, env); +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_xml_reader_xml_free( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + void *data) +{ + (parser)->ops->xml_free(parser, env, data); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_char_set_encoding( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->get_char_set_encoding(parser, env); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_namespace_uri( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->get_namespace_uri(parser, env); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_namespace_uri_by_prefix( + axiom_xml_reader_t * parser, + const axutil_env_t * env, + axis2_char_t * prefix) +{ + return (parser)->ops->get_namespace_uri_by_prefix(parser, env, prefix); +} + +AXIS2_EXTERN void *AXIS2_CALL +axiom_xml_reader_get_context( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->get_context(parser, env); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_reader_get_current_buffer( + axiom_xml_reader_t * parser, + const axutil_env_t * env) +{ + return (parser)->ops->get_current_buffer(parser, env); +} + diff --git a/axiom/src/parser/xml_writer.c b/axiom/src/parser/xml_writer.c new file mode 100644 index 0000000..cefaeae --- /dev/null +++ b/axiom/src/parser/xml_writer.c @@ -0,0 +1,337 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +AXIS2_EXTERN void AXIS2_CALL +axiom_xml_writer_free( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + (writer)->ops->free(writer, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname) +{ + return (writer)->ops->write_start_element(writer, env, localname); + +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_end_start_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + return (writer)->ops->end_start_element(writer, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_start_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri) +{ + return (writer)->ops->write_start_element_with_namespace(writer, env, localname, namespace_uri); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_start_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix) +{ + return (writer)->ops->write_start_element_with_namespace_prefix(writer, env, localname, + namespace_uri, prefix); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_empty_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname) +{ + return (writer)->ops->write_empty_element(writer, env, localname); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_empty_element_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri) +{ + return (writer)->ops->write_empty_element_with_namespace(writer, env, localname, namespace_uri); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_empty_element_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * namespace_uri, + axis2_char_t * prefix) +{ + return (writer)->ops->write_empty_element_with_namespace_prefix(writer, env, localname, + namespace_uri, prefix); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_end_element( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + return (writer)->ops->write_end_element(writer, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_end_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + return (writer)->ops->write_end_document(writer, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_attribute( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value) +{ + return (writer)->ops->write_attribute(writer, env, localname, value); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_attribute_with_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri) +{ + return (writer)->ops->write_attribute_with_namespace(writer, env, localname, value, + namespace_uri); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_attribute_with_namespace_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * localname, + axis2_char_t * value, + axis2_char_t * namespace_uri, + axis2_char_t * prefix) +{ + return (writer)->ops->write_attribute_with_namespace_prefix(writer, env, localname, value, + namespace_uri, prefix); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * namespace_uri) +{ + return (writer)->ops->write_namespace(writer, env, prefix, namespace_uri); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_default_namespace( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * namespace_uri) +{ + return (writer)->ops->write_default_namespace(writer, env, namespace_uri); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_comment( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * value) +{ + return (writer)->ops->write_comment(writer, env, value); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_processing_instruction( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target) +{ + return (writer)->ops->write_processing_instruction(writer, env, target); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_processing_instruction_data( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * target, + axis2_char_t * data) +{ + return (writer)->ops->write_processing_instruction_data(writer, env, target, data); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_cdata( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * data) +{ + return (writer)->ops->write_cdata(writer, env, data); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_dtd( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * dtd) +{ + return (writer)->ops->write_cdata(writer, env, dtd); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_entity_ref( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * name) +{ + return (writer)->ops->write_entity_ref(writer, env, name); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_start_document( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + return (writer)->ops->write_start_document(writer, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_start_document_with_version( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version) +{ + return (writer)->ops->write_start_document_with_version(writer, env, version); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_start_document_with_version_encoding( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * version, + axis2_char_t * encoding) +{ + return (writer)->ops->write_start_document_with_version_encoding(writer, env, encoding, version); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_characters( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text) +{ + return (writer)->ops->write_characters(writer, env, text); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_xml_writer_get_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri) +{ + return (writer)->ops->get_prefix(writer, env, uri); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_set_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * prefix, + axis2_char_t * uri) +{ + return (writer)->ops->set_prefix(writer, env, prefix, uri); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_set_default_prefix( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * uri) +{ + return (writer)->ops->set_default_prefix(writer, env, uri); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_encoded( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * text, + int in_attr) +{ + return (writer)->ops->write_encoded(writer, env, text, in_attr); +} + +AXIS2_EXTERN void *AXIS2_CALL +axiom_xml_writer_get_xml( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + return (writer)->ops->get_xml(writer, env); +} + +AXIS2_EXTERN unsigned int AXIS2_CALL +axiom_xml_writer_get_xml_size( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + return (writer)->ops->get_xml_size(writer, env); +} + +AXIS2_EXTERN int AXIS2_CALL +axiom_xml_writer_get_type( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + return (writer)->ops->get_type(writer, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_write_raw( + axiom_xml_writer_t * writer, + const axutil_env_t * env, + axis2_char_t * content) +{ + return (writer)->ops->write_raw(writer, env, content); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_xml_writer_flush( + axiom_xml_writer_t * writer, + const axutil_env_t * env) +{ + return (writer)->ops->flush(writer, env); +} diff --git a/axiom/src/soap/Makefile.am b/axiom/src/soap/Makefile.am new file mode 100644 index 0000000..5b53ba8 --- /dev/null +++ b/axiom/src/soap/Makefile.am @@ -0,0 +1,33 @@ +noinst_LTLIBRARIES = libaxis2_soap.la +libaxis2_soap_la_SOURCES = soap_fault.c \ + soap_fault_code.c \ + soap_fault_detail.c \ + soap_fault_node.c \ + soap_fault_reason.c \ + soap_fault_role.c \ + soap_fault_sub_code.c \ + soap_fault_text.c \ + soap_fault_value.c \ + soap_header_block.c \ + soap_header.c \ + soap_body.c \ + soap_envelope.c \ + soap_builder.c \ + soap11_builder_helper.c \ + soap12_builder_helper.c + +libaxis2_soap_la_LIBADD = +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/src/parser \ + -I$(top_builddir)/src/om \ + -I ../../../util/include + +EXTRA_DIST = axiom_soap11_builder_helper.h \ + _axiom_soap_fault_code.h _axiom_soap_fault_reason.h \ + _axiom_soap_fault_value.h axiom_soap12_builder_helper.h \ + _axiom_soap_fault_detail.h _axiom_soap_fault_role.h \ + _axiom_soap_header_block.h _axiom_soap_body.h \ + _axiom_soap_fault.h _axiom_soap_fault_sub_code.h \ + _axiom_soap_header.h _axiom_soap_envelope.h \ + _axiom_soap_fault_node.h _axiom_soap_fault_text.h + diff --git a/axiom/src/soap/_axiom_soap_body.h b/axiom/src/soap/_axiom_soap_body.h new file mode 100644 index 0000000..bb25b84 --- /dev/null +++ b/axiom/src/soap/_axiom_soap_body.h @@ -0,0 +1,69 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_BODY_H +#define _AXIOM_SOAP_BODY_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_body Soap Body + * @ingroup axiom_soap + * @{ + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_body_set_base_node( + axiom_soap_body_t * body, + const axutil_env_t * env, + axiom_node_t * om_node); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_body_set_builder( + axiom_soap_body_t * body, + const axutil_env_t * env, + struct axiom_soap_builder *builder); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_body_set_fault( + axiom_soap_body_t * body, + const axutil_env_t * env, + struct axiom_soap_fault *soap_fault); + + AXIS2_EXTERN axiom_soap_body_t *AXIS2_CALL + axiom_soap_body_create( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_BODY_H */ diff --git a/axiom/src/soap/_axiom_soap_envelope.h b/axiom/src/soap/_axiom_soap_envelope.h new file mode 100644 index 0000000..1c446cc --- /dev/null +++ b/axiom/src/soap/_axiom_soap_envelope.h @@ -0,0 +1,84 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_ENVELOPE_H +#define _AXIOM_SOAP_ENVELOPE_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_envelope Soap Envelope + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_envelope_set_base_node( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env, + axiom_node_t * om_node); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_envelope_set_body( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env, + struct axiom_soap_body *body); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_envelope_set_header( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env, + struct axiom_soap_header *header); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_envelope_set_builder( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env, + struct axiom_soap_builder *soap_builder); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_envelope_set_soap_version_internal( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env, + int soap_version); + + AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL + + axiom_soap_envelope_create_null( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_ENVELOPE_H */ diff --git a/axiom/src/soap/_axiom_soap_fault.h b/axiom/src/soap/_axiom_soap_fault.h new file mode 100644 index 0000000..2f0c410 --- /dev/null +++ b/axiom/src/soap/_axiom_soap_fault.h @@ -0,0 +1,105 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_FAULT_H +#define _AXIOM_SOAP_FAULT_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_fault Soap fault + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_set_code( + axiom_soap_fault_t * fault, + const axutil_env_t * env, + struct axiom_soap_fault_code *code); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_set_reason( + axiom_soap_fault_t * fault, + const axutil_env_t * env, + struct axiom_soap_fault_reason *reason); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_set_node( + axiom_soap_fault_t * fault, + const axutil_env_t * env, + struct axiom_soap_fault_node *node); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_set_role( + axiom_soap_fault_t * fault, + const axutil_env_t * env, + struct axiom_soap_fault_role *role); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_set_detail( + axiom_soap_fault_t * fault, + const axutil_env_t * env, + struct axiom_soap_fault_detail *detail); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_set_base_node( + axiom_soap_fault_t * fault, + const axutil_env_t * env, + axiom_node_t * node); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_set_builder( + axiom_soap_fault_t * fault, + const axutil_env_t * env, + struct axiom_soap_builder *builder); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_set_soap_version( + axiom_soap_fault_t * fault, + const axutil_env_t * env, + int soap_version); + + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_fault_get_soap_version( + axiom_soap_fault_t * fault, + const axutil_env_t * env); + + AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL + axiom_soap_fault_create( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_FAULT_H */ diff --git a/axiom/src/soap/_axiom_soap_fault_code.h b/axiom/src/soap/_axiom_soap_fault_code.h new file mode 100644 index 0000000..3905a18 --- /dev/null +++ b/axiom/src/soap/_axiom_soap_fault_code.h @@ -0,0 +1,91 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_FAULT_CODE_H +#define _AXIOM_SOAP_FAULT_CODE_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_fault_code Soap fault code + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_code_set_value( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env, + struct axiom_soap_fault_value *fault_val); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_code_set_sub_code( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env, + struct axiom_soap_fault_sub_code *fault_subcode); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_code_set_base_node( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env, + axiom_node_t * node); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_fault_code_set_builder( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env, + struct axiom_soap_builder *soap_builder); + + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_fault_code_get_soap_version( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_code_set_soap_version( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env, + int soap_version); + + AXIS2_EXTERN axiom_soap_fault_code_t *AXIS2_CALL + + axiom_soap_fault_code_create( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_FAULT_CODE_H */ diff --git a/axiom/src/soap/_axiom_soap_fault_detail.h b/axiom/src/soap/_axiom_soap_fault_detail.h new file mode 100644 index 0000000..69369ca --- /dev/null +++ b/axiom/src/soap/_axiom_soap_fault_detail.h @@ -0,0 +1,60 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_FAULT_DETAIL_H +#define _AXIOM_SOAP_FAULT_DETAIL_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_fault_detail soap fault detail + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_detail_set_base_node( + axiom_soap_fault_detail_t * fault_detail, + const axutil_env_t * env, + axiom_node_t * node); + + AXIS2_EXTERN axiom_soap_fault_detail_t *AXIS2_CALL + + axiom_soap_fault_detail_create( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_FAULT_DETAIL_H */ diff --git a/axiom/src/soap/_axiom_soap_fault_node.h b/axiom/src/soap/_axiom_soap_fault_node.h new file mode 100644 index 0000000..94ddad7 --- /dev/null +++ b/axiom/src/soap/_axiom_soap_fault_node.h @@ -0,0 +1,60 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_FAULT_NODE_H +#define _AXIOM_SOAP_FAULT_NODE_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_fault_node Soap fault_node + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_node_set_base_node( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env, + axiom_node_t * node); + + AXIS2_EXTERN axiom_soap_fault_node_t *AXIS2_CALL + + axiom_soap_fault_node_create( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_FAULT_NODE_H */ diff --git a/axiom/src/soap/_axiom_soap_fault_reason.h b/axiom/src/soap/_axiom_soap_fault_reason.h new file mode 100644 index 0000000..2307a31 --- /dev/null +++ b/axiom/src/soap/_axiom_soap_fault_reason.h @@ -0,0 +1,87 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_FAULT_REASON_H +#define _AXIOM_SOAP_FAULT_REASON_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_fault_reason Soap Reason + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_reason_set_builder( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + struct axiom_soap_builder *builder); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_reason_set_base_node( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + axiom_node_t * node); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_reason_set_soap_fault_text( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + struct axiom_soap_fault_text *soap_text); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_reason_set_soap_version( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + int soap_version); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_reason_get_soap_version( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env); + + AXIS2_EXTERN axiom_soap_fault_reason_t *AXIS2_CALL + + axiom_soap_fault_reason_create( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_FAULT_REASON_H */ diff --git a/axiom/src/soap/_axiom_soap_fault_role.h b/axiom/src/soap/_axiom_soap_fault_role.h new file mode 100644 index 0000000..9c4ec4b --- /dev/null +++ b/axiom/src/soap/_axiom_soap_fault_role.h @@ -0,0 +1,60 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_FAULT_ROLE_H +#define _AXIOM_SOAP_FAULT_ROLE_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_fault_role Soap_fault_role + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_role_set_base_node( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env, + axiom_node_t * node); + + AXIS2_EXTERN axiom_soap_fault_role_t *AXIS2_CALL + + axiom_soap_fault_role_create( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_FAULT_ROLE_H */ diff --git a/axiom/src/soap/_axiom_soap_fault_sub_code.h b/axiom/src/soap/_axiom_soap_fault_sub_code.h new file mode 100644 index 0000000..878d4e6 --- /dev/null +++ b/axiom/src/soap/_axiom_soap_fault_sub_code.h @@ -0,0 +1,93 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_FAULT_CODE_SUB_CODE_H +#define _AXIOM_SOAP_FAULT_CODE_SUB_CODE_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_fault_sub_code Soap_fault_code + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_sub_code_set_sub_code( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env, + axiom_soap_fault_sub_code_t * sub_code); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_sub_code_set_value( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env, + struct axiom_soap_fault_value *fault_sub_code_val); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_sub_code_set_base_node( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env, + axiom_node_t * node); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_sub_code_set_builder( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env, + struct axiom_soap_builder *builder); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_sub_code_set_soap_version( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env, + int soap_version); + + AXIS2_EXTERN int AXIS2_CALL + axiom_soap_fault_sub_code_get_soap_version( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env); + + AXIS2_EXTERN axiom_soap_fault_sub_code_t *AXIS2_CALL + + axiom_soap_fault_sub_code_create( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_FAULT_CODE_SUB_CODE_H */ diff --git a/axiom/src/soap/_axiom_soap_fault_text.h b/axiom/src/soap/_axiom_soap_fault_text.h new file mode 100644 index 0000000..dfc8772 --- /dev/null +++ b/axiom/src/soap/_axiom_soap_fault_text.h @@ -0,0 +1,60 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_FAULT_TEXT_H +#define _AXIOM_SOAP_FAULT_TEXT_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_fault_text soap fault text + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_text_set_base_node( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env, + axiom_node_t * node); + + AXIS2_EXTERN axiom_soap_fault_text_t *AXIS2_CALL + + axiom_soap_fault_text_create( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_FAULT_TEXT_H */ diff --git a/axiom/src/soap/_axiom_soap_fault_value.h b/axiom/src/soap/_axiom_soap_fault_value.h new file mode 100644 index 0000000..a524f7f --- /dev/null +++ b/axiom/src/soap/_axiom_soap_fault_value.h @@ -0,0 +1,60 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_FAULT_VALUE_H +#define _AXIOM_SOAP_FAULT_VALUE_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_fault_value Soap Fault Value + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_fault_value_set_base_node( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env, + axiom_node_t * node); + + AXIS2_EXTERN axiom_soap_fault_value_t *AXIS2_CALL + + axiom_soap_fault_value_create( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_FAULT_VALUE_H */ diff --git a/axiom/src/soap/_axiom_soap_header.h b/axiom/src/soap/_axiom_soap_header.h new file mode 100644 index 0000000..7571aa6 --- /dev/null +++ b/axiom/src/soap/_axiom_soap_header.h @@ -0,0 +1,77 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_HEADER_H +#define _AXIOM_SOAP_HEADER_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_header Soap header + * @ingroup axiom_soap + * @{ + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_set_base_node( + axiom_soap_header_t * header, + const axutil_env_t * env, + axiom_node_t * node); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_header_set_soap_version( + axiom_soap_header_t * header, + const axutil_env_t * env, + int soap_version); + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_header_set_header_block( + axiom_soap_header_t * header, + const axutil_env_t * env, + struct axiom_soap_header_block *header_block); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axiom_soap_header_set_builder( + axiom_soap_header_t * header, + const axutil_env_t * env, + struct axiom_soap_builder *builder); + + AXIS2_EXTERN axiom_soap_header_t *AXIS2_CALL + axiom_soap_header_create( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_HEADER_H */ diff --git a/axiom/src/soap/_axiom_soap_header_block.h b/axiom/src/soap/_axiom_soap_header_block.h new file mode 100644 index 0000000..65cb3ab --- /dev/null +++ b/axiom/src/soap/_axiom_soap_header_block.h @@ -0,0 +1,66 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _AXIOM_SOAP_HEADER_BLOCK_H +#define _AXIOM_SOAP_HEADER_BLOCK_H + +/** @defgroup axiom_soap AXIOM (Axis Object Model) + * @ingroup axis2 + * @{ + */ + +/** @} */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_soap_header_block Soap header block + * @ingroup axiom_soap + * @{ + */ + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_header_block_set_soap_version( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + int soap_version); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap_header_block_set_base_node( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + axiom_node_t * node); + + AXIS2_EXTERN axiom_soap_header_block_t *AXIS2_CALL + + axiom_soap_header_block_create( + const axutil_env_t * env); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /** _AXIOM_SOAP_HEADER_BLOCK_H */ diff --git a/axiom/src/soap/axiom_soap11_builder_helper.h b/axiom/src/soap/axiom_soap11_builder_helper.h new file mode 100644 index 0000000..13e914a --- /dev/null +++ b/axiom/src/soap/axiom_soap11_builder_helper.h @@ -0,0 +1,71 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP11_BUILDER_HELPER_H +#define AXIOM_SOAP11_BUILDER_HELPER_H + +/** + * @file axiom_soap_11_builder_helper.h + * @brief axiom_soap11_builder_helper + */ +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap11_builder_helper + axiom_soap11_builder_helper_t; + + /** + * @defgroup axiom_soap11_builder_helper + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap11_builder_helper_create + * @param env Environment. MUST NOT be NULL + */ + AXIS2_EXTERN axiom_soap11_builder_helper_t *AXIS2_CALL + + axiom_soap11_builder_helper_create( + const axutil_env_t * env, + axiom_soap_builder_t * soap_builder, + axiom_stax_builder_t * om_builder); + + AXIS2_EXTERN void AXIS2_CALL + axiom_soap11_builder_helper_free( + axiom_soap11_builder_helper_t * builder_helper, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap11_builder_helper_handle_event( + axiom_soap11_builder_helper_t * builder_helper, + const axutil_env_t * env, + axiom_node_t * om_element_node, + int element_level); + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /* AXIOM_SOAP11_BUILDER_HELPER_H */ diff --git a/axiom/src/soap/axiom_soap12_builder_helper.h b/axiom/src/soap/axiom_soap12_builder_helper.h new file mode 100644 index 0000000..e901627 --- /dev/null +++ b/axiom/src/soap/axiom_soap12_builder_helper.h @@ -0,0 +1,71 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_SOAP12_BUILDER_HELPER_H +#define AXIOM_SOAP12_BUILDER_HELPER_H + +#include + +/** + * @file axiom_soap_12_builder_helper.h + * @brief axiom_soap12_builder_helper + */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axiom_soap12_builder_helper + axiom_soap12_builder_helper_t; + + /** + * @defgroup axiom_soap12_builder_helper + * @ingroup axiom_soap + * @{ + */ + + /** + * creates a soap12_builder_helper_create + * @param env Environment. MUST NOT be NULL + */ + AXIS2_EXTERN axiom_soap12_builder_helper_t *AXIS2_CALL + + axiom_soap12_builder_helper_create( + const axutil_env_t * env, + axiom_soap_builder_t * soap_builder); + + AXIS2_EXTERN void AXIS2_CALL + axiom_soap12_builder_helper_free( + axiom_soap12_builder_helper_t * builder_helper, + const axutil_env_t * env); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + + axiom_soap12_builder_helper_handle_event( + axiom_soap12_builder_helper_t * builder_helper, + const axutil_env_t * env, + axiom_node_t * om_element_node, + int element_level); + + /** @} */ +#ifdef __cplusplus +} +#endif + +#endif /*AXIOM_SOAP11_BUILDER_HELPER_H */ diff --git a/axiom/src/soap/soap11_builder_helper.c b/axiom/src/soap/soap11_builder_helper.c new file mode 100644 index 0000000..ab2e4d8 --- /dev/null +++ b/axiom/src/soap/soap11_builder_helper.c @@ -0,0 +1,340 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axiom_soap11_builder_helper.h" +#include +#include +#include +#include "_axiom_soap_fault_code.h" +#include "_axiom_soap_fault_value.h" +#include "_axiom_soap_fault_reason.h" +#include "_axiom_soap_fault.h" +#include "_axiom_soap_body.h" +#include "_axiom_soap_fault_detail.h" +#include +#include "_axiom_soap_fault_role.h" +#include +#include + +static axis2_status_t +axiom_soap11_builder_helper_process_text( + axiom_soap11_builder_helper_t * builder_helper, + const axutil_env_t * env); + +struct axiom_soap11_builder_helper +{ + axiom_soap_builder_t *soap_builder; + + axis2_bool_t fault_code_present; + + axis2_bool_t fault_string_present; + + axiom_stax_builder_t *om_builder; + + axiom_node_t *last_processed_node; + +}; + +AXIS2_EXTERN axiom_soap11_builder_helper_t *AXIS2_CALL +axiom_soap11_builder_helper_create( + const axutil_env_t * env, + axiom_soap_builder_t * soap_builder, + axiom_stax_builder_t * om_builder) +{ + axiom_soap11_builder_helper_t *builder_helper = NULL; + + AXIS2_PARAM_CHECK(env->error, soap_builder, NULL); + AXIS2_PARAM_CHECK(env->error, om_builder, NULL); + + builder_helper = (axiom_soap11_builder_helper_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap11_builder_helper_t)); + + if(!builder_helper) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create SOAP 1.1 builder helper"); + return NULL; + } + + builder_helper->fault_code_present = AXIS2_FALSE; + builder_helper->fault_string_present = AXIS2_FALSE; + builder_helper->last_processed_node = NULL; + builder_helper->soap_builder = soap_builder; + builder_helper->om_builder = om_builder; + + return builder_helper; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap11_builder_helper_free( + axiom_soap11_builder_helper_t * builder_helper, + const axutil_env_t * env) +{ + + AXIS2_FREE(env->allocator, builder_helper); + builder_helper = NULL; + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap11_builder_helper_handle_event( + axiom_soap11_builder_helper_t * builder_helper, + const axutil_env_t * env, + axiom_node_t * om_element_node, + int element_level) +{ + axiom_element_t *om_ele = NULL; + axis2_char_t *ele_localname = NULL; + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_soap_body_t *soap_body = NULL; + axiom_soap_fault_t *soap_fault = NULL; + + AXIS2_PARAM_CHECK(env->error, om_element_node, AXIS2_FAILURE); + + om_ele = (axiom_element_t *)axiom_node_get_data_element(om_element_node, env); + + ele_localname = axiom_element_get_localname(om_ele, env); + if(!ele_localname) + { + return AXIS2_FAILURE; + } + + soap_envelope = axiom_soap_builder_get_soap_envelope(builder_helper->soap_builder, env); + + if(!soap_envelope) + { + return AXIS2_FAILURE; + } + + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + if(!soap_body) + { + return AXIS2_FAILURE; + } + + soap_fault = axiom_soap_body_get_fault(soap_body, env); + if(!soap_fault) + { + return AXIS2_FAILURE; + } + + if(element_level == 4) + { + axiom_soap_fault_code_t *fault_code = NULL; + axiom_soap_fault_value_t *fault_value = NULL; + axiom_node_t *fault_value_node = NULL; + axiom_element_t *fault_value_ele = NULL; + + if(axutil_strcmp(ele_localname, AXIOM_SOAP11_SOAP_FAULT_CODE_LOCAL_NAME) == 0) + { + axis2_status_t status = AXIS2_SUCCESS; + + if(builder_helper->fault_string_present) + { + axiom_soap_builder_set_bool_processing_mandatory_fault_elements( + builder_helper->soap_builder, env, AXIS2_FALSE); + } + + fault_code = axiom_soap_fault_code_create(env); + if(!fault_code) + { + return AXIS2_FAILURE; + } + axiom_soap_fault_code_set_base_node(fault_code, env, om_element_node); + + axiom_soap_fault_set_code(soap_fault, env, fault_code); + + axiom_soap_fault_code_set_builder(fault_code, env, builder_helper->soap_builder); + + axiom_element_set_localname(om_ele, env, AXIOM_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME); + + fault_value = axiom_soap_fault_value_create_with_code(env, fault_code); + if(!fault_value) + { + return AXIS2_FAILURE; + } + fault_value_node = axiom_soap_fault_value_get_base_node(fault_value, env); + if(!fault_value_node) + { + return AXIS2_FAILURE; + } + fault_value_ele = (axiom_element_t *)axiom_node_get_data_element(fault_value_node, env); + + axiom_stax_builder_set_lastnode(builder_helper->om_builder, env, fault_value_node); + + status = axiom_soap11_builder_helper_process_text(builder_helper, env); + if(status == AXIS2_FAILURE) + { + return AXIS2_FAILURE; + } + axiom_stax_builder_set_lastnode(builder_helper->om_builder, env, om_element_node); + axiom_node_set_complete(om_element_node, env, AXIS2_TRUE); + + axiom_stax_builder_set_element_level(builder_helper->om_builder, env, (element_level + - 1)); + builder_helper->fault_code_present = AXIS2_TRUE; + } + else if(axutil_strcmp(AXIOM_SOAP11_SOAP_FAULT_STRING_LOCAL_NAME, ele_localname) == 0) + { + + axiom_soap_fault_reason_t *fault_reason = NULL; + axiom_soap_fault_text_t *fault_text = NULL; + axiom_node_t *fault_text_node = NULL; + int status = AXIS2_SUCCESS; + if(builder_helper->fault_code_present) + { + axiom_soap_builder_set_bool_processing_mandatory_fault_elements( + builder_helper->soap_builder, env, AXIS2_FALSE); + } + + axiom_element_set_localname(om_ele, env, AXIOM_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME); + + fault_reason = axiom_soap_fault_reason_create(env); + if(!fault_reason) + { + return AXIS2_FAILURE; + } + axiom_soap_fault_reason_set_base_node(fault_reason, env, om_element_node); + + axiom_soap_fault_set_reason(soap_fault, env, fault_reason); + + fault_text = axiom_soap_fault_text_create_with_parent(env, fault_reason); + if(!fault_text) + { + return AXIS2_FAILURE; + } + fault_text_node = axiom_soap_fault_text_get_base_node(fault_text, env); + if(!fault_text_node) + { + return AXIS2_FAILURE; + } + axiom_stax_builder_set_lastnode(builder_helper->om_builder, env, fault_text_node); + + status = axiom_soap11_builder_helper_process_text(builder_helper, env); + if(status == AXIS2_FAILURE) + { + return AXIS2_FAILURE; + } + axiom_stax_builder_set_lastnode(builder_helper->om_builder, env, om_element_node); + + axiom_node_set_complete(om_element_node, env, AXIS2_TRUE); + + axiom_stax_builder_set_element_level(builder_helper->om_builder, env, (element_level + - 1)); + + builder_helper->fault_string_present = AXIS2_TRUE; + + } + else if(axutil_strcmp(AXIOM_SOAP11_SOAP_FAULT_ACTOR_LOCAL_NAME, ele_localname) == 0) + { + axiom_soap_fault_role_t *fault_role = NULL; + fault_role = axiom_soap_fault_role_create(env); + if(!fault_role) + { + return AXIS2_FAILURE; + } + axiom_element_set_localname(om_ele, env, AXIOM_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME); + + axiom_soap_fault_role_set_base_node(fault_role, env, om_element_node); + + axiom_soap_fault_set_role(soap_fault, env, fault_role); + /* + Role element may not have a namespace associated, hence commented, else it segfaults here - Samisa + status = axiom_soap_builder_process_namespace_data( + builder_helper->soap_builder, env, om_element_node, AXIS2_TRUE); + if(status == AXIS2_FAILURE) + return AXIS2_FAILURE; */ + } + else if(axutil_strcmp(AXIOM_SOAP11_SOAP_FAULT_DETAIL_LOCAL_NAME, ele_localname) == 0) + { + axiom_soap_fault_detail_t *fault_detail = NULL; + fault_detail = axiom_soap_fault_detail_create(env); + if(!fault_detail) + { + return AXIS2_FAILURE; + } + axiom_element_set_localname(om_ele, env, AXIOM_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME); + + axiom_soap_fault_detail_set_base_node(fault_detail, env, om_element_node); + + axiom_soap_fault_set_detail(soap_fault, env, fault_detail); + } + else + { + return AXIS2_SUCCESS; + } + } + else if(element_level == 5) + { + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_element = NULL; + axis2_char_t *parent_localname = NULL; + + parent_node = axiom_node_get_parent(om_element_node, env); + if(!parent_node) + { + return AXIS2_FAILURE; + } + parent_element = (axiom_element_t *)axiom_node_get_data_element(om_element_node, env); + parent_localname = axiom_element_get_localname(parent_element, env); + + if(!parent_localname) + { + return AXIS2_FAILURE; + } + if(axutil_strcmp(parent_localname, AXIOM_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME) == 0) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SOAP11_FAULT_ACTOR_SHOULD_NOT_HAVE_CHILD_ELEMENTS, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "SOAP 1.1 Actor should not have child elements"); + return AXIS2_FAILURE; + } + } + return AXIS2_SUCCESS; +} + +static axis2_status_t +axiom_soap11_builder_helper_process_text( + axiom_soap11_builder_helper_t * builder_helper, + const axutil_env_t * env) +{ + int token = 0; + + token = axiom_stax_builder_next_with_token(builder_helper->om_builder, env); + + if(token == -1) + { + return AXIS2_FAILURE; + } + while(token != AXIOM_XML_READER_END_ELEMENT) + { + if(token != AXIOM_XML_READER_CHARACTER) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_ONLY_CHARACTERS_ARE_ALLOWED_HERE, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Unidentified character in SOAP 1.1 builder helper processing"); + return AXIS2_FAILURE; + + } + token = axiom_stax_builder_next_with_token(builder_helper->om_builder, env); + if(token == -1) + { + return AXIS2_FAILURE; + } + } + return AXIS2_SUCCESS; +} diff --git a/axiom/src/soap/soap12_builder_helper.c b/axiom/src/soap/soap12_builder_helper.c new file mode 100644 index 0000000..179d26d --- /dev/null +++ b/axiom/src/soap/soap12_builder_helper.c @@ -0,0 +1,718 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "axiom_soap12_builder_helper.h" +#include +#include "_axiom_soap_body.h" +#include "_axiom_soap_fault.h" +#include "_axiom_soap_envelope.h" +#include "_axiom_soap_fault_code.h" +#include "_axiom_soap_fault_sub_code.h" +#include "_axiom_soap_fault_node.h" +#include "_axiom_soap_fault_detail.h" +#include "_axiom_soap_fault_reason.h" +#include "_axiom_soap_fault_role.h" +#include "_axiom_soap_fault_value.h" +#include "_axiom_soap_fault_text.h" + +struct axiom_soap12_builder_helper +{ + axiom_soap_builder_t *soap_builder; + + axis2_bool_t code_present; + + axis2_bool_t reason_present; + + axis2_bool_t node_present; + + axis2_bool_t role_present; + + axis2_bool_t detail_present; + + axis2_bool_t subcode_value_present; + + axis2_bool_t value_present; + + axis2_bool_t sub_code_present; + + axis2_bool_t sub_sub_code_present; + + axis2_bool_t code_processing; + + axis2_bool_t sub_code_processing; + + axis2_bool_t reason_processing; + + axutil_array_list_t *detail_element_names; +}; + +AXIS2_EXTERN axiom_soap12_builder_helper_t *AXIS2_CALL +axiom_soap12_builder_helper_create( + const axutil_env_t * env, + axiom_soap_builder_t * soap_builder) +{ + axiom_soap12_builder_helper_t *builder_helper = NULL; + AXIS2_ENV_CHECK(env, NULL); + AXIS2_PARAM_CHECK(env->error, soap_builder, NULL); + + builder_helper = (axiom_soap12_builder_helper_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap12_builder_helper_t)); + if(!builder_helper) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create SOAP 1.1 builder helper"); + return NULL; + } + + builder_helper->code_present = AXIS2_FALSE; + builder_helper->detail_present = AXIS2_FALSE; + builder_helper->reason_present = AXIS2_FALSE; + builder_helper->role_present = AXIS2_FALSE; + builder_helper->sub_code_present = AXIS2_FALSE; + builder_helper->reason_processing = AXIS2_FALSE; + builder_helper->code_processing = AXIS2_FALSE; + builder_helper->sub_code_processing = AXIS2_FALSE; + builder_helper->detail_element_names = NULL; + builder_helper->node_present = AXIS2_FALSE; + builder_helper->soap_builder = soap_builder; + builder_helper->sub_sub_code_present = AXIS2_FALSE; + builder_helper->value_present = AXIS2_FALSE; + builder_helper->subcode_value_present = AXIS2_FALSE; + + return builder_helper; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap12_builder_helper_free( + axiom_soap12_builder_helper_t * builder_helper, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, void); + + if(builder_helper->detail_element_names) + { + axutil_array_list_free(builder_helper->detail_element_names, env); + builder_helper->detail_element_names = NULL; + } + + AXIS2_FREE(env->allocator, builder_helper); + builder_helper = NULL; + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap12_builder_helper_handle_event( + axiom_soap12_builder_helper_t * builder_helper, + const axutil_env_t * env, + axiom_node_t * om_ele_node, + int element_level) +{ + axis2_char_t *ele_localname = NULL; + axiom_element_t *om_ele = NULL; + + axiom_soap_body_t *soap_body = NULL; + axiom_soap_fault_t *soap_fault = NULL; + axiom_soap_envelope_t *soap_envelope = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_ele_node, AXIS2_FAILURE); + + om_ele = (axiom_element_t *)axiom_node_get_data_element(om_ele_node, env); + if(!om_ele) + { + return AXIS2_FAILURE; + } + + ele_localname = axiom_element_get_localname(om_ele, env); + if(!ele_localname) + { + return AXIS2_FAILURE; + } + + soap_envelope = axiom_soap_builder_get_soap_envelope(builder_helper->soap_builder, env); + if(!soap_envelope) + { + return AXIS2_FAILURE; + } + + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + if(!soap_body) + { + return AXIS2_FAILURE; + } + + soap_fault = axiom_soap_body_get_fault(soap_body, env); + if(!soap_fault) + { + return AXIS2_FAILURE; + } + + if(element_level == 4) + { + if(axutil_strcmp(AXIOM_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME, ele_localname) == 0) + { + if(builder_helper->code_present) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_CODE_ELEMENTS_ENCOUNTERED, + AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Multiple fault code elements encountered in SOAP fault"); + return AXIS2_FAILURE; + } + else + { + axiom_soap_fault_code_t *soap_fault_code = NULL; + soap_fault_code = axiom_soap_fault_code_create(env); + if(!soap_fault_code) + { + return AXIS2_FAILURE; + } + axiom_soap_fault_code_set_base_node(soap_fault_code, env, om_ele_node); + + axiom_soap_fault_code_set_builder(soap_fault_code, env, + builder_helper->soap_builder); + + axiom_soap_fault_set_code(soap_fault, env, soap_fault_code); + + builder_helper->code_present = AXIS2_TRUE; + builder_helper->code_processing = AXIS2_TRUE; + } + } + else if(axutil_strcmp(AXIOM_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME, ele_localname) == 0) + { + if(!(builder_helper->code_processing) && !(builder_helper->sub_code_processing)) + { + if(builder_helper->code_present) + { + if(builder_helper->reason_present) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_MULTIPLE_REASON_ELEMENTS_ENCOUNTERED, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Multiple fault reason elements encountered in SOAP fault"); + + return AXIS2_FAILURE; + } + else + { + axiom_soap_fault_reason_t *fault_reason = NULL; + fault_reason = axiom_soap_fault_reason_create(env); + if(!fault_reason) + { + return AXIS2_FAILURE; + } + + axiom_soap_fault_reason_set_base_node(fault_reason, env, om_ele_node); + + axiom_soap_fault_set_reason(soap_fault, env, fault_reason); + + axiom_soap_fault_reason_set_builder(fault_reason, env, + builder_helper-> soap_builder); + + builder_helper->reason_present = AXIS2_TRUE; + builder_helper->reason_processing = AXIS2_TRUE; + } + } + else + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + else + { + if(builder_helper->code_processing) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_FAULT_CODE_DOES_NOT_HAVE_A_VALUE, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + else + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_FAULT_CODE_DOES_NOT_HAVE_A_VALUE, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + } + else if(axutil_strcmp(ele_localname, AXIOM_SOAP12_SOAP_FAULT_NODE_LOCAL_NAME) == 0) + { + if(!(builder_helper->reason_processing)) + { + if(builder_helper->reason_present && !(builder_helper->role_present) + && !(builder_helper->detail_present)) + { + if(builder_helper->node_present) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_NODE_ELEMENTS_ENCOUNTERED, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + else + { + axiom_soap_fault_node_t *soap_fault_node = NULL; + soap_fault_node = axiom_soap_fault_node_create(env); + if(!soap_fault_node) + { + return AXIS2_FAILURE; + } + + axiom_soap_fault_node_set_base_node(soap_fault_node, env, om_ele_node); + + axiom_soap_fault_set_node(soap_fault, env, soap_fault_node); + + builder_helper->node_present = AXIS2_TRUE; + } + } + else + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED, + AXIS2_FALSE); + + return AXIS2_FAILURE; + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SOAP_FAULT_REASON_ELEMENT_SHOULD_HAVE_A_TEXT, AXIS2_FALSE); + return AXIS2_FAILURE; + } + + } + else if(axutil_strcmp(ele_localname, AXIOM_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME) == 0) + { + if(!(builder_helper->reason_processing)) + { + if(builder_helper->reason_present && !(builder_helper->detail_present)) + { + if(builder_helper->role_present) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_ROLE_ELEMENTS_ENCOUNTERED, + AXIS2_FAILURE); + + return AXIS2_FAILURE; + } + else + { + axiom_soap_fault_role_t *soap_fault_role = NULL; + soap_fault_role = axiom_soap_fault_role_create(env); + if(!soap_fault_role) + return AXIS2_FAILURE; + + axiom_soap_fault_role_set_base_node(soap_fault_role, env, om_ele_node); + + axiom_soap_fault_set_role(soap_fault, env, soap_fault_role); + builder_helper->role_present = AXIS2_TRUE; + } + } + else + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + else + { + + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_FAULT_ROLE_ELEMENT_SHOULD_HAVE_A_TEXT, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + else if(axutil_strcmp(ele_localname, AXIOM_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME) == 0) + { + if(!(builder_helper->reason_processing)) + { + if(builder_helper->reason_present) + { + if(builder_helper->detail_present) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_MULTIPLE_DETAIL_ELEMENTS_ENCOUNTERED, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + else + { + + axiom_soap_fault_detail_t *soap_fault_detail = NULL; + soap_fault_detail = axiom_soap_fault_detail_create(env); + if(!soap_fault_detail) + return AXIS2_FAILURE; + + axiom_soap_fault_detail_set_base_node(soap_fault_detail, env, om_ele_node); + + axiom_soap_fault_set_detail(soap_fault, env, soap_fault_detail); + builder_helper->detail_present = AXIS2_TRUE; + } + } + else + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED, + AXIS2_FAILURE); + + return AXIS2_FAILURE; + + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SOAP_FAULT_REASON_ELEMENT_SHOULD_HAVE_A_TEXT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + } + else + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_UNSUPPORTED_ELEMENT_IN_SOAP_FAULT_ELEMENT, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + else if(element_level == 5) + { + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + axis2_char_t *parent_localname = NULL; + parent_node = axiom_node_get_parent(om_ele_node, env); + if(!parent_node) + { + return AXIS2_FAILURE; + } + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(!parent_ele) + { + return AXIS2_FAILURE; + } + parent_localname = axiom_element_get_localname(parent_ele, env); + if(!parent_localname) + { + return AXIS2_FAILURE; + } + + if(axutil_strcmp(parent_localname, AXIOM_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME) == 0) + { + if(axutil_strcmp(ele_localname, AXIOM_SOAP12_SOAP_FAULT_VALUE_LOCAL_NAME) == 0) + { + if(!(builder_helper->value_present)) + { + axiom_soap_fault_value_t *soap_fault_value = NULL; + axiom_soap_fault_code_t *parent_fcode = NULL; + + soap_fault_value = axiom_soap_fault_value_create(env); + if(!soap_fault_value) + { + return AXIS2_FAILURE; + } + axiom_soap_fault_value_set_base_node(soap_fault_value, env, om_ele_node); + + parent_fcode = axiom_soap_fault_get_code(soap_fault, env); + if(!parent_fcode) + { + return AXIS2_FAILURE; + } + axiom_soap_fault_code_set_value(parent_fcode, env, soap_fault_value); + + builder_helper->value_present = AXIS2_TRUE; + builder_helper->code_processing = AXIS2_FALSE; + + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_MULTIPLE_VALUE_ENCOUNTERED_IN_CODE_ELEMENT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + else if(axutil_strcmp(ele_localname, AXIOM_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME) == 0) + { + if(!(builder_helper->sub_code_present)) + { + if(builder_helper->value_present) + { + + axiom_soap_fault_sub_code_t *fault_subcode = NULL; + axiom_soap_fault_code_t *fault_code = NULL; + + fault_subcode = axiom_soap_fault_sub_code_create(env); + if(!fault_subcode) + { + return AXIS2_FAILURE; + } + axiom_soap_fault_sub_code_set_base_node(fault_subcode, env, om_ele_node); + + fault_code = axiom_soap_fault_get_code(soap_fault, env); + if(!fault_code) + { + return AXIS2_FAILURE; + } + axiom_soap_fault_code_set_sub_code(fault_code, env, fault_subcode); + + axiom_soap_fault_sub_code_set_builder(fault_subcode, env, + builder_helper-> soap_builder); + + builder_helper->sub_code_present = AXIS2_TRUE; + builder_helper->sub_code_processing = AXIS2_TRUE; + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SOAP_FAULT_VALUE_SHOULD_BE_PRESENT_BEFORE_SUB_CODE, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + else + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_SUB_CODE_VALUES_ENCOUNTERED, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_THIS_LOCALNAME_NOT_SUPPORTED_INSIDE_THE_CODE_ELEMENT, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + } + else if(axutil_strcmp(parent_localname, AXIOM_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME) == 0) + { + if(axutil_strcmp(ele_localname, AXIOM_SOAP12_SOAP_FAULT_TEXT_LOCAL_NAME) == 0) + { + axiom_soap_fault_text_t *soap_fault_text = NULL; + axiom_soap_fault_reason_t *fault_reason = NULL; + + soap_fault_text = axiom_soap_fault_text_create(env); + if(!soap_fault_text) + { + return AXIS2_FAILURE; + } + axiom_soap_fault_text_set_base_node(soap_fault_text, env, om_ele_node); + + fault_reason = axiom_soap_fault_get_reason(soap_fault, env); + if(!fault_reason) + { + return AXIS2_FAILURE; + } + + axiom_soap_fault_reason_add_soap_fault_text(fault_reason, env, soap_fault_text); + builder_helper->reason_processing = AXIS2_FALSE; + + axiom_soap_builder_set_bool_processing_mandatory_fault_elements( + builder_helper->soap_builder, env, AXIS2_FALSE); + + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_THIS_LOCALNAME_IS_NOT_SUPPORTED_INSIDE_THE_REASON_ELEMENT, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + } + else if(axutil_strcmp(parent_localname, AXIOM_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME) == 0) + { + axiom_soap_builder_set_processing_detail_elements(builder_helper-> soap_builder, env, + AXIS2_TRUE); + + if(!(builder_helper->detail_element_names)) + { + builder_helper->detail_element_names = axutil_array_list_create(env, 20); + } + + axutil_array_list_add(builder_helper->detail_element_names, env, ele_localname); + + } + else + { + + return AXIS2_FAILURE; + } + + } + else if(element_level > 5) + { + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + axis2_char_t *parent_localname = NULL; + + parent_node = axiom_node_get_parent(om_ele_node, env); + if(!parent_node) + { + return AXIS2_FAILURE; + } + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(!parent_ele) + { + return AXIS2_FAILURE; + } + + parent_localname = axiom_element_get_localname(parent_ele, env); + if(!parent_localname) + { + return AXIS2_FAILURE; + } + if(axutil_strcmp(parent_localname, AXIOM_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME) == 0) + { + if(axutil_strcmp(ele_localname, AXIOM_SOAP12_SOAP_FAULT_VALUE_LOCAL_NAME) == 0) + { + if(builder_helper->subcode_value_present) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_SUB_CODE_VALUES_ENCOUNTERED, + AXIS2_FAILURE); + return AXIS2_FAILURE; + } + else + { + + axiom_soap_fault_sub_code_t *sub_code = NULL; + axiom_soap_fault_code_t *code = NULL; + axiom_soap_fault_value_t *value = NULL; + code = axiom_soap_fault_get_code(soap_fault, env); + + if(!code) + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, + "fault code null when it should not be null"); + return AXIS2_FAILURE; + } + + sub_code = axiom_soap_fault_code_get_sub_code(code, env); + if(!sub_code) + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, + "fault subcode null when it should not be null"); + return AXIS2_FAILURE; + } + value = axiom_soap_fault_value_create(env); + if(!value) + { + return AXIS2_FAILURE; + } + + axiom_soap_fault_value_set_base_node(value, env, om_ele_node); + + axiom_soap_fault_sub_code_set_value(sub_code, env, value); + + builder_helper->subcode_value_present = AXIS2_TRUE; + builder_helper->sub_sub_code_present = AXIS2_FALSE; + builder_helper->sub_code_processing = AXIS2_FALSE; + } + } + else if(axutil_strcmp(ele_localname, AXIOM_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME) == 0) + { + if(builder_helper->subcode_value_present) + { + if(!(builder_helper->sub_sub_code_present)) + { + axiom_soap_fault_code_t *fault_code = NULL; + axiom_soap_fault_sub_code_t *parent_subcode = NULL; + axiom_soap_fault_sub_code_t *subcode = NULL; + + subcode = axiom_soap_fault_sub_code_create(env); + if(!subcode) + { + return AXIS2_FAILURE; + } + + axiom_soap_fault_sub_code_set_base_node(subcode, env, om_ele_node); + + fault_code = axiom_soap_fault_get_code(soap_fault, env); + if(!fault_code) + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, + "fault code null when it should not be null"); + return AXIS2_FAILURE; + } + parent_subcode = axiom_soap_fault_code_get_sub_code(fault_code, env); + if(!parent_subcode) + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, + "fault subcode null when it should not be null"); + return AXIS2_FAILURE; + } + + axiom_soap_fault_sub_code_set_sub_code(parent_subcode, env, subcode); + + builder_helper->subcode_value_present = AXIS2_FALSE; + builder_helper->sub_sub_code_present = AXIS2_TRUE; + builder_helper->sub_code_processing = AXIS2_TRUE; + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_MULTIPLE_SUB_CODE_VALUES_ENCOUNTERED, AXIS2_FAILURE); + + return AXIS2_FAILURE; + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SOAP_FAULT_VALUE_SHOULD_BE_PRESENT_BEFORE_SUB_CODE, + AXIS2_FAILURE); + + return AXIS2_FAILURE; + + } + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_THIS_LOCALNAME_IS_NOT_SUPPORTED_INSIDE_THE_SUB_CODE_ELEMENT, + AXIS2_FAILURE); + + return AXIS2_FAILURE; + } + } + else if(axiom_soap_builder_is_processing_detail_elements(builder_helper->soap_builder, env)) + { + + int detail_element_level = 0; + axis2_bool_t local_name_exists = AXIS2_FALSE; + int i = 0; + if(!(builder_helper->detail_element_names)) + { + return AXIS2_FAILURE; + } + + for(i = 0; i < axutil_array_list_size(builder_helper->detail_element_names, env); i++) + { + if(axutil_strcmp(parent_localname, axutil_array_list_get( + builder_helper->detail_element_names, env, i)) == 0) + { + local_name_exists = AXIS2_TRUE; + detail_element_level = i + 1; + } + } + if(local_name_exists) + { + axutil_array_list_add(builder_helper->detail_element_names, env, ele_localname); + } + else + { + return AXIS2_FAILURE; + } + } + } + return AXIS2_SUCCESS; +} diff --git a/axiom/src/soap/soap_body.c b/axiom/src/soap/soap_body.c new file mode 100644 index 0000000..8fb7d8f --- /dev/null +++ b/axiom/src/soap/soap_body.c @@ -0,0 +1,547 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "_axiom_soap_envelope.h" +#include "_axiom_soap_body.h" +#include +#include +#include +#include +#include +#include +#include +#include "_axiom_soap_fault_value.h" +#include "_axiom_soap_fault_text.h" +#include + +struct axiom_soap_body +{ + axiom_node_t *om_ele_node; + + axis2_bool_t has_fault; + + axiom_soap_fault_t *soap_fault; + + axiom_soap_builder_t *soap_builder; + + int soap_version; +}; + +AXIS2_EXTERN axiom_soap_body_t *AXIS2_CALL +axiom_soap_body_create( + const axutil_env_t * env) +{ + axiom_soap_body_t *soap_body = NULL; + + soap_body = (axiom_soap_body_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_soap_body_t)); + + if(!soap_body) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + soap_body->om_ele_node = NULL; + soap_body->soap_builder = NULL; + soap_body->has_fault = AXIS2_FALSE; + soap_body->soap_fault = NULL; + + return soap_body; +} + +AXIS2_EXTERN axiom_soap_body_t *AXIS2_CALL +axiom_soap_body_create_with_parent( + const axutil_env_t * env, + axiom_soap_envelope_t * envelope) +{ + axiom_soap_body_t *soap_body = NULL; + axiom_element_t *ele = NULL; + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + axiom_namespace_t *om_ns = NULL; + + AXIS2_PARAM_CHECK(env->error, envelope, NULL); + + soap_body = axiom_soap_body_create(env); + if(!soap_body) + { + return NULL; + } + + /*get parent node from SOAP envelope */ + parent_node = axiom_soap_envelope_get_base_node(envelope, env); + if(!parent_node) + { + axiom_soap_body_free(soap_body, env); + return NULL; + } + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + + if(!parent_ele) + { + axiom_soap_body_free(soap_body, env); + return NULL; + } + + om_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + + ele = axiom_element_create(env, parent_node, AXIOM_SOAP_BODY_LOCAL_NAME, om_ns, + &(soap_body->om_ele_node)); + if(!ele) + { + axiom_soap_body_free(soap_body, env); + return NULL; + } + + axiom_soap_envelope_set_body(envelope, env, soap_body); + + return soap_body; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_body_free( + axiom_soap_body_t * soap_body, + const axutil_env_t * env) +{ + + if(soap_body->soap_fault) + { + axiom_soap_fault_free(soap_body->soap_fault, env); + soap_body->soap_fault = NULL; + } + AXIS2_FREE(env->allocator, soap_body); + soap_body = NULL; + return; +} + +/** + * Indicates whether a soap fault is available with this soap body + * @param soap_body axiom_soap_body struct + * @param env environment must not be null + * @return AXIS2_TRUE if fault is available, AXIS2_FALSE otherwise + */ +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_soap_body_has_fault( + axiom_soap_body_t * soap_body, + const axutil_env_t * env) +{ + if(soap_body->soap_fault) + { + soap_body->has_fault = AXIS2_TRUE; + } + else + { + while(!axiom_node_is_complete(soap_body->om_ele_node, env)) + { + if(axiom_soap_builder_next(soap_body->soap_builder, env) != AXIS2_SUCCESS) + { + /* problem in building the SOAP body. Note that has_fault is about soap fault, + * not about problem in building the node. So, even though there is a problem + * building the body, has_fault should be AXIS2_FALSE + */ + break; + } + + if(soap_body->soap_fault) + { + soap_body->has_fault = AXIS2_TRUE; + break; + } + } + } + + return soap_body->has_fault; +} + +/** + * Returns the axiom_soap_fault_t struct in this axiom_soap_bodY_t + * struct + * + * @return the SOAPFault object in this SOAPBody + * object + */ +AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL +axiom_soap_body_get_fault( + axiom_soap_body_t * soap_body, + const axutil_env_t * env) +{ + if(soap_body->soap_fault) + { + return soap_body->soap_fault; + } + else if(soap_body->soap_builder) + { + while(!(soap_body->soap_fault) && !(axiom_node_is_complete(soap_body->om_ele_node, env))) + { + int status = AXIS2_SUCCESS; + status = axiom_soap_builder_next(soap_body->soap_builder, env); + if(status == AXIS2_FAILURE) + { + return NULL; + } + } + if(soap_body->soap_fault) + { + soap_body->has_fault = AXIS2_TRUE; + return soap_body->soap_fault; + } + } + return NULL; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_soap_body_get_base_node( + axiom_soap_body_t * soap_body, + const axutil_env_t * env) +{ + return soap_body->om_ele_node; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_body_set_base_node( + axiom_soap_body_t * soap_body, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + soap_body->om_ele_node = node; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_body_set_builder( + axiom_soap_body_t * soap_body, + const axutil_env_t * env, + axiom_soap_builder_t * builder) +{ + AXIS2_PARAM_CHECK(env->error, builder, AXIS2_FAILURE); + + soap_body->soap_builder = builder; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_soap_builder_t *AXIS2_CALL +axiom_soap_body_get_builder( + axiom_soap_body_t * soap_body, + const axutil_env_t * env) +{ + if(!soap_body) + { + return NULL; + } + return soap_body->soap_builder; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_body_build( + axiom_soap_body_t * soap_body, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + axiom_node_t *xop_node = NULL; + axis2_bool_t is_replaced = AXIS2_FALSE; + axiom_element_t *xop_element = NULL; + + if(soap_body->om_ele_node && soap_body->soap_builder) + { + xop_node + = axiom_util_get_node_by_local_name(env, soap_body->om_ele_node, AXIS2_XOP_INCLUDE); + + if(xop_node) + { + xop_element = (axiom_element_t *)axiom_node_get_data_element(xop_node, env); + if(xop_element) + { + is_replaced = axiom_soap_builder_replace_xop(soap_body->soap_builder, env, + xop_node, xop_element); + } + } + + while(axiom_node_is_complete(soap_body->om_ele_node, env) != AXIS2_TRUE) + { + status = axiom_soap_builder_next(soap_body->soap_builder, env); + if(status == AXIS2_FAILURE) + { + return AXIS2_FAILURE; + } + } + } + return AXIS2_SUCCESS; +} + +/** + This is an internal function + + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_body_set_fault( + axiom_soap_body_t * soap_body, + const axutil_env_t * env, + axiom_soap_fault_t * soap_fault) +{ + AXIS2_PARAM_CHECK(env->error, soap_fault, AXIS2_FAILURE); + if(soap_body->soap_fault) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_ONLY_ONE_SOAP_FAULT_ALLOWED_IN_BODY, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + else + { + soap_body->soap_fault = soap_fault; + soap_body->has_fault = AXIS2_TRUE; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_body_add_child( + axiom_soap_body_t * soap_body, + const axutil_env_t * env, + axiom_node_t * child) +{ + AXIS2_PARAM_CHECK(env->error, child, AXIS2_FAILURE); + + if(soap_body->om_ele_node) + { + return axiom_node_add_child(soap_body->om_ele_node, env, child); + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN int AXIS2_CALL +axiom_soap_body_get_soap_version( + axiom_soap_body_t * soap_body, + const axutil_env_t * env) +{ + axiom_element_t *body_ele = NULL; + axiom_namespace_t *om_ns = NULL; + axis2_char_t *uri = NULL; + + if(!soap_body->om_ele_node) + { + return AXIS2_FAILURE; + } + body_ele = axiom_node_get_data_element(soap_body->om_ele_node, env); + if(!body_ele) + { + return AXIS2_FAILURE; + } + om_ns = axiom_element_get_namespace(body_ele, env, soap_body->om_ele_node); + if(!om_ns) + { + return AXIS2_FAILURE; + } + uri = axiom_namespace_get_uri(om_ns, env); + if(uri) + { + if(axutil_strcmp(uri, AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI) == 0) + { + return AXIOM_SOAP11; + } + else if(axutil_strcmp(uri, AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI) == 0) + { + return AXIOM_SOAP12; + } + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_body_convert_fault_to_soap11( + axiom_soap_body_t * soap_body, + const axutil_env_t * env) +{ + if(soap_body) + { + axiom_soap_fault_t *soap_fault = NULL; + if(axiom_soap_body_has_fault(soap_body, env)) + { + soap_fault = axiom_soap_body_get_fault(soap_body, env); + if(soap_fault) + { + axiom_soap_fault_code_t *fault_code = NULL; + axiom_soap_fault_reason_t *fault_reason = NULL; + axiom_soap_fault_detail_t *fault_detail = NULL; + axiom_soap_fault_role_t *fault_role = NULL; + fault_code = axiom_soap_fault_get_code(soap_fault, env); + if(fault_code) + { + axiom_node_t *fault_code_om_node = NULL; + axiom_element_t *fault_code_om_ele = NULL; + axiom_node_t *fault_value_om_node = NULL; + axiom_element_t *fault_value_om_ele = NULL; + axiom_soap_fault_value_t *fault_value = NULL; + axis2_char_t *text = NULL; + + fault_code_om_node = axiom_soap_fault_code_get_base_node(fault_code, env); + if(fault_code_om_node) + { + fault_code_om_ele = (axiom_element_t *)axiom_node_get_data_element( + fault_code_om_node, env); + if(fault_code_om_ele) + { + axiom_element_set_localname(fault_code_om_ele, env, + AXIOM_SOAP11_SOAP_FAULT_CODE_LOCAL_NAME); + + fault_value = axiom_soap_fault_code_get_value(fault_code, env); + + if(fault_value) + { + fault_value_om_node = axiom_soap_fault_value_get_base_node( + fault_value, env); + if(fault_value_om_node) + { + fault_value_om_ele + = (axiom_element_t *)axiom_node_get_data_element( + fault_value_om_node, env); + if(fault_value_om_ele) + { + text = axiom_element_get_text(fault_value_om_ele, env, + fault_value_om_node); + if(text) + { + axiom_element_set_text(fault_code_om_ele, env, text, + fault_code_om_node); + } + } + axiom_node_free_tree(fault_value_om_node, env); + axiom_soap_fault_value_set_base_node(fault_value, env, NULL); + } + } + } + } + } + fault_reason = axiom_soap_fault_get_reason(soap_fault, env); + if(fault_reason) + { + axiom_node_t *fault_reason_om_node = NULL; + axiom_element_t *fault_reason_om_ele = NULL; + axiom_node_t *fault_text_om_node = NULL; + axiom_element_t *fault_text_om_ele = NULL; + axiom_soap_fault_text_t *fault_text = NULL; + axis2_char_t *text = NULL; + + fault_reason_om_node = axiom_soap_fault_reason_get_base_node(fault_reason, env); + if(fault_reason_om_node) + { + fault_reason_om_ele = (axiom_element_t *)axiom_node_get_data_element( + fault_reason_om_node, env); + + if(fault_reason_om_ele) + { + + axiom_element_set_localname(fault_reason_om_ele, env, + AXIOM_SOAP11_SOAP_FAULT_STRING_LOCAL_NAME); + + fault_text = axiom_soap_fault_reason_get_first_soap_fault_text( + fault_reason, env); + if(fault_text) + { + fault_text_om_node = axiom_soap_fault_text_get_base_node( + fault_text, env); + if(fault_text_om_node) + { + fault_text_om_ele + = (axiom_element_t *)axiom_node_get_data_element( + fault_text_om_node, env); + if(fault_text_om_ele) + { + text = axiom_element_get_text(fault_text_om_ele, env, + fault_text_om_node); + if(text) + { + axiom_element_set_text(fault_reason_om_ele, env, text, + fault_reason_om_node); + } + } + axiom_node_free_tree(fault_text_om_node, env); + axiom_soap_fault_text_set_base_node(fault_text, env, NULL); + } + } + } + } + } + + fault_role = axiom_soap_fault_get_role(soap_fault, env); + if(fault_role) + { + axiom_node_t *fault_role_om_node = NULL; + axiom_element_t *fault_role_om_ele = NULL; + + fault_role_om_node = axiom_soap_fault_role_get_base_node(fault_role, env); + if(fault_role_om_node) + { + fault_role_om_ele = (axiom_element_t *)axiom_node_get_data_element( + fault_role_om_node, env); + if(fault_role_om_ele) + { + axiom_element_set_localname(fault_role_om_ele, env, + AXIOM_SOAP11_SOAP_FAULT_ACTOR_LOCAL_NAME); + } + } + } + + fault_detail = axiom_soap_fault_get_detail(soap_fault, env); + if(fault_detail) + { + axiom_node_t *fault_detail_om_node = NULL; + axiom_element_t *fault_detail_om_ele = NULL; + fault_detail_om_node = axiom_soap_fault_detail_get_base_node(fault_detail, env); + if(fault_detail_om_node) + { + fault_detail_om_ele = (axiom_element_t *)axiom_node_get_data_element( + fault_detail_om_node, env); + if(fault_detail_om_ele) + { + axiom_element_set_localname(fault_detail_om_ele, env, + AXIOM_SOAP11_SOAP_FAULT_DETAIL_LOCAL_NAME); + } + } + } + } + } + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_body_process_attachments( + axiom_soap_body_t * soap_body, + const axutil_env_t * env, + void *user_pram, + axis2_char_t *callback_name) +{ + axis2_status_t status = AXIS2_FAILURE; + + status = axiom_soap_builder_create_attachments(soap_body->soap_builder, env, user_pram, + callback_name); + + if(status == AXIS2_FAILURE) + { + return status; + } + else + { + return axiom_soap_body_build(soap_body, env); + } +} + + diff --git a/axiom/src/soap/soap_builder.c b/axiom/src/soap/soap_builder.c new file mode 100644 index 0000000..6960c03 --- /dev/null +++ b/axiom/src/soap/soap_builder.c @@ -0,0 +1,1206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "_axiom_soap_envelope.h" +#include "_axiom_soap_header.h" +#include "axiom_soap11_builder_helper.h" +#include "axiom_soap12_builder_helper.h" +#include +#include "_axiom_soap_body.h" +#include "_axiom_soap_header_block.h" +#include +#include "_axiom_soap_fault.h" +#include + +static axis2_status_t +axiom_soap_builder_construct_node( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env, + axiom_node_t * om_element_node); + +static axis2_status_t +axiom_soap_builder_identify_soap_version( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env, + const axis2_char_t * soap_version_uri_from_transport); + +static axis2_status_t +axiom_soap_builder_parse_headers( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env); + +static axis2_status_t +axiom_soap_builder_process_namespace_data( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env, + axiom_node_t * om_node); + +static axis2_status_t +axiom_soap_builder_construct_soap_header( + axiom_soap_builder_t *soap_builder, + const axutil_env_t *env, + axiom_node_t *om_node); + +static axis2_status_t +axiom_soap_builder_construct_soap_body( + axiom_soap_builder_t *soap_builder, + const axutil_env_t *env, + axiom_node_t *om_node); + +static axis2_status_t +axiom_soap_builder_construct_soap_fault( + axiom_soap_builder_t *soap_builder, + const axutil_env_t *env, + axiom_node_t *om_node); + +static axis2_status_t +axiom_soap_builder_construct_xop_include( + axiom_soap_builder_t *soap_builder, + const axutil_env_t *env, + axiom_node_t *om_element_node); + +struct axiom_soap_builder +{ + axiom_stax_builder_t *om_builder; + + axiom_soap_envelope_t *soap_envelope; + + axis2_bool_t header_present; + + axis2_bool_t body_present; + + int element_level; + + axis2_bool_t processing_fault; + + axis2_bool_t processing_detail_elements; + + axis2_char_t *sender_fault_code; + + axis2_char_t *receiver_fault_code; + + axis2_bool_t processing_mandatory_fault_elements; + + void *builder_helper; + + axiom_namespace_t *envelope_ns; + + int soap_version; + + int last_node_status; + + axis2_bool_t done; + + axutil_hash_t *mime_body_parts; + + axiom_mime_parser_t *mime_parser; + + AXIS2_READ_INPUT_CALLBACK callback; + + void *callback_ctx; + +}; + +typedef enum axis2_builder_last_node_states +{ + AXIS2_BUILDER_LAST_NODE_NULL = 0, + AXIS2_BUILDER_LAST_NODE_NOT_NULL +} axis2_builder_last_node_states; + +#define AXIS2_MAX_EVENT 100 + +AXIS2_EXTERN axiom_soap_builder_t *AXIS2_CALL +axiom_soap_builder_create( + const axutil_env_t * env, + axiom_stax_builder_t * stax_builder, + const axis2_char_t * soap_version) +{ + axiom_soap_builder_t *soap_builder = NULL; + axis2_status_t status = AXIS2_SUCCESS; + + AXIS2_PARAM_CHECK(env->error, stax_builder, NULL); + + soap_builder = (axiom_soap_builder_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap_builder_t)); + + if(soap_builder == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + soap_builder->done = AXIS2_FALSE; + soap_builder->body_present = AXIS2_FALSE; + soap_builder->builder_helper = NULL; + soap_builder->element_level = 0; + soap_builder->header_present = AXIS2_FALSE; + soap_builder->processing_detail_elements = AXIS2_FALSE; + soap_builder->processing_fault = AXIS2_FALSE; + soap_builder->processing_mandatory_fault_elements = AXIS2_FALSE; + soap_builder->receiver_fault_code = NULL; + soap_builder->sender_fault_code = NULL; + soap_builder->soap_version = AXIOM_SOAP12; + soap_builder->last_node_status = -1; + soap_builder->envelope_ns = NULL; + soap_builder->soap_envelope = NULL; + soap_builder->mime_body_parts = NULL; + soap_builder->om_builder = stax_builder; + soap_builder->mime_parser = NULL; + soap_builder->callback = NULL; + soap_builder->callback_ctx = NULL; + + status = axiom_soap_builder_identify_soap_version(soap_builder, env, soap_version); + if(status == AXIS2_FAILURE) + { + axiom_soap_builder_free(soap_builder, env); + return NULL; + } + status = axiom_soap_builder_parse_headers(soap_builder, env); + if(status == AXIS2_FAILURE) + { + axiom_soap_builder_free(soap_builder, env); + return NULL; + } + return soap_builder; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_builder_free( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env) +{ + if(!soap_builder) + { + return; + } + if(soap_builder->builder_helper) + { + if(soap_builder->soap_version == AXIOM_SOAP11 && soap_builder->builder_helper) + { + axiom_soap11_builder_helper_free( + (axiom_soap11_builder_helper_t *)(soap_builder->builder_helper), env); + soap_builder->builder_helper = NULL; + } + else if(soap_builder->soap_version == AXIOM_SOAP12 && soap_builder->builder_helper) + { + axiom_soap12_builder_helper_free( + (axiom_soap12_builder_helper_t *)(soap_builder->builder_helper), env); + soap_builder->builder_helper = NULL; + } + } + + if(soap_builder->om_builder) + { + axiom_stax_builder_free(soap_builder->om_builder, env); + soap_builder->om_builder = NULL; + } + + if(soap_builder->mime_body_parts) + { + axutil_hash_index_t *hi = NULL; + void *val = NULL; + const void *key = NULL; + for(hi = axutil_hash_first(soap_builder->mime_body_parts, env); hi; hi = axutil_hash_next( + env, hi)) + { + axutil_hash_this(hi, &key, NULL, &val); + + if(key) + { + AXIS2_FREE(env->allocator, (char *)key); + } + + val = NULL; + key = NULL; + } + + axutil_hash_free(soap_builder->mime_body_parts, env); + soap_builder->mime_body_parts = NULL; + } + + if(soap_builder->mime_parser) + { + axiom_mime_parser_free(soap_builder->mime_parser, env); + soap_builder->mime_parser = NULL; + } + + if(soap_builder->callback_ctx) + { + axis2_callback_info_t *callback_info = NULL; + + callback_info = (axis2_callback_info_t *)(soap_builder->callback_ctx); + if(callback_info) + { + if(callback_info->chunked_stream) + { + axutil_http_chunked_stream_free(callback_info->chunked_stream, env); + callback_info->chunked_stream = NULL; + } + + AXIS2_FREE(env->allocator, callback_info); + callback_info = NULL; + soap_builder->callback_ctx = NULL; + } + } + + if(soap_builder) + { + AXIS2_FREE(env->allocator, soap_builder); + soap_builder = NULL; + } + + return; +} + +AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL +axiom_soap_builder_get_soap_envelope( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + + if(!soap_builder) + { + return NULL; + } + if(!(soap_builder->om_builder)) + { + return NULL; + } + while(!(soap_builder->soap_envelope) && !axiom_stax_builder_is_complete( + soap_builder->om_builder, env)) + { + status = axiom_soap_builder_next(soap_builder, env); + if(status == AXIS2_FAILURE) + { + break; + } + } + + return soap_builder->soap_envelope; +} + +AXIS2_EXTERN axiom_document_t *AXIS2_CALL axiom_soap_builder_get_document( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env) +{ + if (!soap_builder) + { + return NULL; + } + if (soap_builder->om_builder) + { + return axiom_stax_builder_get_document(soap_builder->om_builder, env); + } + else + return NULL; +} + +/** + * Builds next element of the OM structure + * @param builder pointer to the SOAP Builder struct + * @param env Environment. MUST NOT be NULL + * @return AXIS2_SUCCESS if the next element is present else AXIS2_FAILURE + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_builder_next( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env) +{ + int current_event = AXIS2_MAX_EVENT; + int status = AXIS2_SUCCESS; + + if((!soap_builder) || (soap_builder->done) || (!soap_builder->om_builder)) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid soap builder"); + return AXIS2_FAILURE; + } + + /* Get the status of previous node before building next node. We need the previous state of the + * node to identify very first element, which is SOAP Envelope. If last_node_status is + * AXIS2_BUILDER_LAST_NODE_NULL, then it means next node is SOAP Envelope + */ + if(axiom_stax_builder_get_lastnode(soap_builder->om_builder, env)) + { + soap_builder->last_node_status = AXIS2_BUILDER_LAST_NODE_NOT_NULL; + } + else + { + soap_builder->last_node_status = AXIS2_BUILDER_LAST_NODE_NULL; + } + + current_event = axiom_stax_builder_next_with_token(soap_builder->om_builder, env); + if(current_event == AXIOM_XML_READER_START_ELEMENT + || current_event == AXIOM_XML_READER_EMPTY_ELEMENT) + { + axiom_node_t *current_node = axiom_stax_builder_get_lastnode(soap_builder->om_builder, env); + if(current_node) + { + status = axiom_soap_builder_construct_node(soap_builder, env, current_node); + } + else + { + /* there is an error. So, don't continue building it */ + soap_builder->done = AXIS2_TRUE; + status = AXIS2_FAILURE; + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error occurred when building node"); + } + } + else if(current_event == -1) + { + /* there is an error. So, don't continue building it */ + soap_builder->done = AXIS2_TRUE; + status = AXIS2_FAILURE; + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error occurred when building node"); + } + + /* for any other event types, return AXIS2_SUCCESS as the return value. */ + + return status; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_soap_builder_get_document_element( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env) +{ + axiom_node_t *document_node = NULL; + if(soap_builder->soap_envelope) + { + document_node = axiom_soap_envelope_get_base_node(soap_builder->soap_envelope, env); + } + + return document_node; +} + +static axis2_status_t +axiom_soap_builder_construct_node( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env, + axiom_node_t * om_element_node) +{ + axiom_element_t *om_element = NULL; + const axis2_char_t *ele_localname = NULL; + int element_level = 0; + int status = AXIS2_SUCCESS; + axiom_node_t *parent = NULL; + + /* get OM element struct from node */ + om_element = (axiom_element_t *)axiom_node_get_data_element(om_element_node, env); + if(!om_element) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot construct node. Invalid element"); + return AXIS2_FAILURE; + } + + /* get element local name */ + ele_localname = axiom_element_get_localname(om_element, env); + if(!ele_localname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot construct node. Invalid element name"); + return AXIS2_FAILURE; + } + + parent = axiom_node_get_parent(om_element_node, env); + if(!parent) + { + /* parent node doesn't exist means, this should be SOAP Envelope */ + if(soap_builder->last_node_status != AXIS2_BUILDER_LAST_NODE_NULL) + { + /* this means, there are two elements in the first level */ + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SOAP_MESSAGE_FIRST_ELEMENT_MUST_CONTAIN_LOCAL_NAME, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Soap message can contain only one SOAP Envelope as the top level element"); + return AXIS2_FAILURE; + } + + if(axutil_strcasecmp(ele_localname, AXIOM_SOAP_ENVELOPE_LOCAL_NAME) != 0) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SOAP_MESSAGE_FIRST_ELEMENT_MUST_CONTAIN_LOCAL_NAME, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "SOAP message first element must be Envelope"); + return AXIS2_FAILURE; + } + + /** create a null soap envelope struct */ + soap_builder->soap_envelope = axiom_soap_envelope_create_null(env); + if(!soap_builder->soap_envelope) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create SOAP Envelope"); + return AXIS2_FAILURE; + } + + /** wrap this OM node in it */ + axiom_soap_envelope_set_base_node(soap_builder->soap_envelope, env, om_element_node); + axiom_soap_envelope_set_builder(soap_builder->soap_envelope, env, soap_builder); + status = axiom_soap_builder_process_namespace_data(soap_builder, env, om_element_node); + if(status != AXIS2_SUCCESS) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "SOAP Envelope is having invalid namespace"); + } + + return status; + } + + /** a parent node exist , so not soap envelope. Can be either header/body/children of them */ + + /* get element level of this OM element. Envelope will be in element_level 1. Body and Header + * will be in element level 2. SOAP fault will be child of Body, so it will be in level 3*/ + element_level = axiom_stax_builder_get_element_level(soap_builder->om_builder, env); + if(axiom_stax_builder_get_current_event(soap_builder->om_builder, env) + == AXIOM_XML_READER_EMPTY_ELEMENT) + { + /* if it is an empty element, increase the element level. This is because the element level + * is incremented by STAX builder only if tag is identified. It will not be + * incremented if tag is seen. But for our logic, even empty element should be + * considered as full element. so, = . */ + ++element_level; + } + + if(element_level == 2) + { + /* At this level, we can only have soap:Header or soap:Body */ + status = axiom_soap_builder_process_namespace_data(soap_builder, env, om_element_node); + if(status != AXIS2_SUCCESS) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "invalid SOAP namespace"); + return AXIS2_FAILURE; + } + + if(axutil_strcmp(ele_localname, AXIOM_SOAP_HEADER_LOCAL_NAME) == 0) + { + /* this is the soap header element */ + status = axiom_soap_builder_construct_soap_header(soap_builder, env, om_element_node); + } + else if(axutil_strcmp(ele_localname, AXIOM_SOAP_BODY_LOCAL_NAME) == 0) + { + /* This is the SOAP Body element */ + status = axiom_soap_builder_construct_soap_body(soap_builder, env, om_element_node); + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SOAP_BUILDER_ENVELOPE_CAN_HAVE_ONLY_HEADER_AND_BODY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "SOAP builder found a child element other than header or body in envelope element"); + return AXIS2_FAILURE; + } + } + else if(element_level == 3) + { + axiom_element_t *parent_ele = NULL; + axis2_char_t *parent_localname = NULL; + + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent, env); + if(parent_ele) + { + parent_localname = axiom_element_get_localname(parent_ele, env); + } + + if(!parent_localname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot identify parent element local name"); + return AXIS2_FAILURE; + } + + if(axutil_strcasecmp(parent_localname, AXIOM_SOAP_HEADER_LOCAL_NAME) == 0) + { + axiom_soap_header_block_t *header_block = NULL; + axiom_soap_header_t *soap_header = NULL; + + soap_header = axiom_soap_envelope_get_header(soap_builder->soap_envelope, env); + if(!soap_header) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot get SOAP Header from OM Envelope"); + return AXIS2_FAILURE; + } + + header_block = axiom_soap_header_block_create(env); + if(!header_block) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create SOAP Header block"); + return AXIS2_FAILURE; + } + + axiom_soap_header_block_set_base_node(header_block, env, om_element_node); + axiom_soap_header_set_header_block(soap_header, env, header_block); + axiom_soap_header_block_set_soap_version(header_block, env, soap_builder->soap_version); + } + else if(axutil_strcasecmp(parent_localname, AXIOM_SOAP_BODY_LOCAL_NAME) == 0) + { + /* if the node is or MTOM message */ + if(axutil_strcmp(ele_localname, AXIS2_XOP_INCLUDE) == 0) + { + return axiom_soap_builder_construct_xop_include(soap_builder, env, om_element_node); + } + + if(axutil_strcasecmp(ele_localname, AXIOM_SOAP_BODY_FAULT_LOCAL_NAME) == 0) + { + return axiom_soap_builder_construct_soap_fault(soap_builder, env, om_element_node); + } + + /* We don't need to process any other children of SOAP Body. */ + } + else + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SOAP_BUILDER_ENVELOPE_CAN_HAVE_ONLY_HEADER_AND_BODY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "SOAP builder found a child element other than header or body in envelope element"); + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; + } + else if(element_level > 3) + { + if(soap_builder->processing_fault) + { + if(soap_builder->soap_version == AXIOM_SOAP11) + { + status = axiom_soap11_builder_helper_handle_event((axiom_soap11_builder_helper_t *) + soap_builder->builder_helper, env, om_element_node, element_level); + } + else if(soap_builder->soap_version == AXIOM_SOAP12) + { + status = axiom_soap12_builder_helper_handle_event((axiom_soap12_builder_helper_t *) + soap_builder->builder_helper, env, om_element_node, element_level); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unknown SOAP Version"); + status = AXIS2_FAILURE; + } + } + + /* if the node is or MTOM message */ + else if(axutil_strcmp(ele_localname, AXIS2_XOP_INCLUDE) == 0) + { + return axiom_soap_builder_construct_xop_include(soap_builder, env, om_element_node); + } + + /* we don't need to consider any other elements at this level. */ + } + return status; +} + +static axis2_status_t +axiom_soap_builder_construct_soap_header( + axiom_soap_builder_t *soap_builder, + const axutil_env_t *env, + axiom_node_t *om_node) +{ + axiom_soap_header_t *soap_header = NULL; + if(soap_builder->header_present) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_BUILDER_MULTIPLE_HEADERS_ENCOUNTERED, + AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "SOAP builder encountered multiple headers"); + return AXIS2_FAILURE; + } + if(soap_builder->body_present) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_BUILDER_HEADER_BODY_WRONG_ORDER, + AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "SOAP builder encountered body element first and header next"); + return AXIS2_FAILURE; + } + + soap_builder->header_present = AXIS2_TRUE; + soap_header = axiom_soap_header_create(env); + if(!soap_header) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create SOAP Header"); + return AXIS2_FAILURE; + } + + axiom_soap_header_set_base_node(soap_header, env, om_node); + axiom_soap_envelope_set_header(soap_builder->soap_envelope, env, soap_header); + axiom_soap_header_set_builder(soap_header, env, soap_builder); + axiom_soap_header_set_soap_version(soap_header, env, soap_builder->soap_version); + + return AXIS2_SUCCESS; +} + +static axis2_status_t +axiom_soap_builder_construct_soap_body( + axiom_soap_builder_t *soap_builder, + const axutil_env_t *env, + axiom_node_t *om_node) +{ + axiom_soap_body_t *soap_body = NULL; + if(soap_builder->body_present) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_SOAP_BUILDER_MULTIPLE_BODY_ELEMENTS_ENCOUNTERED, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "SOAP builder multiple body elements encountered"); + return AXIS2_FAILURE; + } + + soap_builder->body_present = AXIS2_TRUE; + soap_body = axiom_soap_body_create(env); + if(!soap_body) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Unable to create SOAP Body"); + return AXIS2_FAILURE; + } + + axiom_soap_body_set_base_node(soap_body, env, om_node); + axiom_soap_body_set_builder(soap_body, env, soap_builder); + axiom_soap_envelope_set_body(soap_builder->soap_envelope, env, soap_body); + + return AXIS2_SUCCESS; +} + +static axis2_status_t +axiom_soap_builder_construct_soap_fault( + axiom_soap_builder_t *soap_builder, + const axutil_env_t *env, + axiom_node_t *om_node) +{ + axiom_soap_body_t *soap_body = NULL; + axiom_soap_fault_t *soap_fault = NULL; + axiom_namespace_t *env_ns = NULL; + + env_ns = axiom_soap_envelope_get_namespace(soap_builder->soap_envelope, env); + if(!env_ns) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot get soap envelope namespace"); + return AXIS2_FAILURE; + } + + soap_body = axiom_soap_envelope_get_body(soap_builder->soap_envelope, env); + if(!soap_body) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot get soap body from OM Envelope"); + return AXIS2_FAILURE; + } + + soap_fault = axiom_soap_fault_create(env); + if(!soap_fault) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create SOAP Fault structure"); + return AXIS2_FAILURE; + } + + axiom_soap_fault_set_base_node(soap_fault, env, om_node); + axiom_soap_body_set_fault(soap_body, env, soap_fault); + axiom_soap_fault_set_builder(soap_fault, env, soap_builder); + soap_builder->processing_fault = AXIS2_TRUE; + soap_builder->processing_mandatory_fault_elements = AXIS2_TRUE; + + if(axutil_strcmp(AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI, + axiom_namespace_get_uri(env_ns, env)) == 0) + { + soap_builder->builder_helper = axiom_soap12_builder_helper_create(env, soap_builder); + } + else if(axutil_strcmp(AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI, + axiom_namespace_get_uri(env_ns, env)) == 0) + { + soap_builder->builder_helper = axiom_soap11_builder_helper_create( + env, soap_builder,soap_builder->om_builder); + } + + if(!soap_builder->builder_helper) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create soap builder helper"); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +static axis2_status_t +axiom_soap_builder_construct_xop_include( + axiom_soap_builder_t *soap_builder, + const axutil_env_t *env, + axiom_node_t *om_element_node) +{ + axiom_namespace_t *ns = NULL; + axis2_char_t *uri = NULL; + axiom_element_t *om_element = NULL; + axutil_qname_t *qname = NULL; + axis2_char_t *id = NULL; + + om_element = (axiom_element_t *)axiom_node_get_data_element(om_element_node, env); + ns = axiom_element_get_namespace(om_element, env, om_element_node); + if(!ns) + { + /* this is not a xop:include element. so, we can safely return success */ + return AXIS2_SUCCESS; + } + + uri = axiom_namespace_get_uri(ns, env); + if((!uri) || (axutil_strcmp(uri, AXIS2_XOP_NAMESPACE_URI) != 0)) + { + /* this is not a xop:include element. so, we can safely return success */ + return AXIS2_SUCCESS; + } + + qname = axutil_qname_create(env, "href", NULL, NULL); + if(!qname) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create qname with value href"); + return AXIS2_FAILURE; + } + + id = axiom_element_get_attribute_value(om_element, env, qname); + axutil_qname_free(qname, env); + if(!id) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot get href ID of the xop:include element"); + return AXIS2_FAILURE; + } + + if(!axutil_strstr(id, "cid:")) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "ID of xop:include doesn't include 'cid:' part"); + return AXIS2_FAILURE; + } + + /* everything looks fine, so recursively build the OM tree, so that we can get data handlers */ + while(!axiom_node_is_complete(om_element_node, env)) + { + axiom_stax_builder_next_with_token(soap_builder->om_builder, env); + } + + if(soap_builder->mime_body_parts) + { + axiom_data_handler_t *data_handler = NULL; + axis2_char_t *id_decoded = NULL; + axiom_text_t *data_text = NULL; + axiom_node_t *data_om_node = NULL; + axiom_node_t *parent = NULL; + + /* Get the value of href id, after "cid:" */ + id += 4; + id_decoded = axutil_strdup(env, id); + axutil_url_decode(env, id_decoded, id_decoded); + + /* Find the data handler of given xop:include */ + data_handler = (axiom_data_handler_t *)axutil_hash_get( + soap_builder-> mime_body_parts, (void *)id_decoded, AXIS2_HASH_KEY_STRING); + if(!data_handler) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Cannot find data handler corresponding to id %s", id_decoded); + AXIS2_FREE(env->allocator, id_decoded); + return AXIS2_FAILURE; + } + + /* remove the element, and add the data handler as the child of + * xop:include's parent */ + parent = axiom_node_get_parent(om_element_node, env); + axiom_node_free_tree(om_element_node, env); + data_text = axiom_text_create_with_data_handler(env, parent, data_handler, &data_om_node); + axiom_text_set_content_id(data_text, env, id_decoded); + axiom_stax_builder_set_lastnode(soap_builder->om_builder,env, parent); + AXIS2_FREE(env->allocator, id_decoded); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot find mime_body_part in soap builder"); + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +/* check whether the namespace of given node is either SOAP11 or SOAP12 namespace */ +static axis2_status_t +axiom_soap_builder_process_namespace_data( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env, + axiom_node_t * om_node) +{ + axiom_element_t *om_ele = NULL; + axiom_namespace_t *om_ns = NULL; + + om_ele = (axiom_element_t *)axiom_node_get_data_element(om_node, env); + om_ns = axiom_element_get_namespace(om_ele, env, om_node); + if(om_ns) + { + axis2_char_t *ns_uri = NULL; + ns_uri = axiom_namespace_get_uri(om_ns, env); + if(ns_uri) + { + if((axutil_strcmp(ns_uri, AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI) == 0) + || (axutil_strcmp(ns_uri, AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI) == 0)) + { + return AXIS2_SUCCESS; + } + } + } + + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_SOAP_NAMESPACE_URI, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid SOAP Namespace URI"); + return AXIS2_FAILURE; +} + +static axis2_status_t +axiom_soap_builder_identify_soap_version( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env, + const axis2_char_t * soap_version_uri_from_transport) +{ + axiom_namespace_t *om_ns = NULL; + axiom_node_t *envelope_node = NULL; + axiom_element_t *om_ele = NULL; + axis2_char_t *ns_uri = NULL; + + AXIS2_PARAM_CHECK(env->error, soap_version_uri_from_transport, AXIS2_FAILURE); + if(!soap_builder) + { + return AXIS2_FAILURE; + } + soap_builder->soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env); + + if(soap_builder->soap_envelope == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_MESSAGE_DOES_NOT_CONTAIN_AN_ENVELOPE, + AXIS2_FAILURE); + AXIS2_LOG_CRITICAL(env->log, AXIS2_LOG_SI, + "SOAP message does not have a SOAP envelope element "); + return AXIS2_FAILURE; + } + + envelope_node = axiom_soap_envelope_get_base_node(soap_builder->soap_envelope, env); + + if(!envelope_node) + { + return AXIS2_FAILURE; + } + om_ele = (axiom_element_t *)axiom_node_get_data_element(envelope_node, env); + if(!om_ele) + { + return AXIS2_FAILURE; + } + om_ns = axiom_element_get_namespace(om_ele, env, envelope_node); + if(!om_ns) + { + return AXIS2_FAILURE; + } + ns_uri = axiom_namespace_get_uri(om_ns, env); + + if(ns_uri) + { + if(soap_version_uri_from_transport + && axutil_strcmp(soap_version_uri_from_transport, ns_uri) != 0) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_TRANSPORT_LEVEL_INFORMATION_DOES_NOT_MATCH_WITH_SOAP, AXIS2_FAILURE); + + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "AXIS2_ERROR_TRANSPORT_LEVEL_INFORMATION_DOES_NOT_MATCH_WITH_SOAP"); + return AXIS2_FAILURE; + } + if(axutil_strcmp(AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI, ns_uri) == 0) + { + soap_builder->soap_version = AXIOM_SOAP11; + + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Identified soap version is soap11"); + + axiom_soap_envelope_set_soap_version_internal(soap_builder-> soap_envelope, env, + soap_builder-> soap_version); + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI, ns_uri) == 0) + { + soap_builder->soap_version = AXIOM_SOAP12; + + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "identified soap version is soap12"); + + axiom_soap_envelope_set_soap_version_internal(soap_builder-> soap_envelope, env, + soap_builder-> soap_version); + + return AXIS2_SUCCESS; + } + } + return AXIS2_FAILURE; +} + +static axis2_status_t +axiom_soap_builder_parse_headers( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env) +{ + axiom_node_t *om_node = NULL; + axiom_soap_header_t *soap_header = NULL; + int status = AXIS2_SUCCESS; + if(!soap_builder) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Soap Builder is NULL"); + return AXIS2_FAILURE; + } + if(!soap_builder->soap_envelope) + { + return AXIS2_FAILURE; + } + soap_header = axiom_soap_envelope_get_header(soap_builder->soap_envelope, env); + + if(soap_header) + { + om_node = axiom_soap_header_get_base_node(soap_header, env); + if(om_node) + { + while(!axiom_node_is_complete(om_node, env)) + { + status = axiom_soap_builder_next(soap_builder, env); + if(status == AXIS2_FAILURE) + return AXIS2_FAILURE; + } + /*HACK: to fix AXIS2C-129 - Samisa */ + /* + axiom_stax_builder_set_element_level( + soap_builder->om_builder, env, 1); + */ + } + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_builder_set_bool_processing_mandatory_fault_elements( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env, + axis2_bool_t value) +{ + soap_builder->processing_mandatory_fault_elements = value; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_builder_set_processing_detail_elements( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env, + axis2_bool_t value) +{ + soap_builder->processing_detail_elements = value; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_soap_builder_is_processing_detail_elements( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env) +{ + return soap_builder->processing_detail_elements; +} + +AXIS2_EXTERN int AXIS2_CALL +axiom_soap_builder_get_soap_version( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env) +{ + return soap_builder->soap_version; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_builder_set_mime_body_parts( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env, + axutil_hash_t * map) +{ + soap_builder->mime_body_parts = map; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axiom_soap_builder_get_mime_body_parts( + axiom_soap_builder_t * builder, + const axutil_env_t * env) +{ + return builder->mime_body_parts; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_builder_set_mime_parser( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + axiom_mime_parser_t *mime_parser) +{ + builder->mime_parser = mime_parser; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_builder_set_callback_function( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + AXIS2_READ_INPUT_CALLBACK callback) +{ + builder->callback = callback; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_builder_set_callback_ctx( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + void *callback_ctx) +{ + builder->callback_ctx = callback_ctx; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_builder_create_attachments( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + void *user_param, + axis2_char_t *callback_name) +{ + axutil_hash_t *attachments_map = NULL; + axis2_char_t *mime_boundary = NULL; + + if(builder->mime_parser) + { + if(builder->callback_ctx) + { + mime_boundary = axiom_mime_parser_get_mime_boundary(builder->mime_parser, env); + + if(mime_boundary) + { + if(callback_name) + { + axiom_mime_parser_set_caching_callback_name(builder->mime_parser, env, + callback_name); + } + attachments_map = axiom_mime_parser_parse_for_attachments(builder->mime_parser, + env, builder->callback, builder->callback_ctx, mime_boundary, user_param); + + if(attachments_map) + { + builder->mime_body_parts = attachments_map; + return AXIS2_SUCCESS; + } + else + { + return AXIS2_FAILURE; + } + } + else + { + return AXIS2_FAILURE; + } + } + else + { + return AXIS2_FAILURE; + } + } + else + { + return AXIS2_FAILURE; + } +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_soap_builder_replace_xop( + axiom_soap_builder_t * builder, + const axutil_env_t * env, + axiom_node_t *om_element_node, + axiom_element_t *om_element) +{ + axiom_namespace_t *ns = NULL; + axis2_bool_t is_replaced = AXIS2_FALSE; + + ns = axiom_element_get_namespace(om_element, env, om_element_node); + if(ns) + { + axis2_char_t *uri = axiom_namespace_get_uri(ns, env); + if(uri) + { + if(axutil_strcmp(uri, AXIS2_XOP_NAMESPACE_URI) == 0) + { + axutil_qname_t *qname = NULL; + qname = axutil_qname_create(env, "href", NULL, NULL); + if(qname) + { + axis2_char_t *id = NULL; + id = axiom_element_get_attribute_value(om_element, env, qname); + if(id) + { + axis2_char_t *pos = NULL; + pos = axutil_strstr(id, "cid:"); + if(pos) + { + axiom_data_handler_t *data_handler = NULL; + id += 4; + + if(builder->mime_body_parts) + { + + axis2_char_t *id_decoded = NULL; + + id_decoded = axutil_strdup(env, id); + + axutil_url_decode(env, id_decoded, id_decoded); + + data_handler = (axiom_data_handler_t *)axutil_hash_get( + builder-> mime_body_parts, (void *)id_decoded, + AXIS2_HASH_KEY_STRING); + if(data_handler) + { + axiom_text_t *data_text = NULL; + axiom_node_t *data_om_node = NULL; + axiom_node_t *parent = NULL; + + parent = axiom_node_get_parent(om_element_node, env); + + /*remove the element */ + axiom_node_free_tree(om_element_node, env); + + data_text = axiom_text_create_with_data_handler(env, parent, + data_handler, &data_om_node); + + axiom_text_set_content_id(data_text, env, id_decoded); + /*axiom_stax_builder_set_lastnode + (soap_builder->om_builder, env, + parent);*/ + is_replaced = AXIS2_TRUE; + } + if(id_decoded) + { + AXIS2_FREE(env->allocator, id_decoded); + } + } + } + } + } + axutil_qname_free(qname, env); + } + } + } + + return is_replaced; +} + +AXIS2_EXTERN axiom_stax_builder_t *AXIS2_CALL +axiom_soap_builder_get_om_builder( + axiom_soap_builder_t * soap_builder, + const axutil_env_t * env) +{ + if(!soap_builder) + { + return NULL; + } + return soap_builder->om_builder; +} + diff --git a/axiom/src/soap/soap_envelope.c b/axiom/src/soap/soap_envelope.c new file mode 100644 index 0000000..48e10f7 --- /dev/null +++ b/axiom/src/soap/soap_envelope.c @@ -0,0 +1,631 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "_axiom_soap_envelope.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct axiom_soap_envelope +{ + /* corresponding om element node */ + axiom_node_t *om_ele_node; + /* soap version */ + int soap_version; + /* soap header */ + axiom_soap_header_t *header; + /* soap body */ + axiom_soap_body_t *body; + /* pointer to soap builder */ + axiom_soap_builder_t *soap_builder; + int ref; +}; +static axis2_status_t +check_and_set_soap_version( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env, + axiom_namespace_t * ns); + +AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL +axiom_soap_envelope_create_null( + const axutil_env_t * env) +{ + axiom_soap_envelope_t *soap_envelope = NULL; + + soap_envelope = (axiom_soap_envelope_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap_envelope_t)); + if(!soap_envelope) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create a SOAP Envelope"); + return NULL; + } + soap_envelope->om_ele_node = NULL; + soap_envelope->soap_version = AXIOM_SOAP12; + soap_envelope->header = NULL; + soap_envelope->body = NULL; + soap_envelope->ref = 1; + soap_envelope->soap_builder = NULL; + + return soap_envelope; +} + +AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL +axiom_soap_envelope_create( + const axutil_env_t * env, + axiom_namespace_t * ns) +{ + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_element_t *ele = NULL; + int status = AXIS2_SUCCESS; + + AXIS2_PARAM_CHECK(env->error, ns, NULL); + + soap_envelope = axiom_soap_envelope_create_null(env); + if(!soap_envelope) + { + return NULL; + } + status = check_and_set_soap_version(soap_envelope, env, ns); + if(status == AXIS2_FAILURE) + { + AXIS2_FREE(env->allocator, soap_envelope); + return NULL; + } + + ele = axiom_element_create(env, NULL, AXIOM_SOAP_ENVELOPE_LOCAL_NAME, ns, + &(soap_envelope->om_ele_node)); + if(!ele) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create a SOAP element"); + axiom_soap_envelope_free(soap_envelope, env); + return NULL; + } + return soap_envelope; +} + +AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL +axiom_soap_envelope_create_with_soap_version_prefix( + const axutil_env_t * env, + int soap_version, + const axis2_char_t * prefix) +{ + axiom_namespace_t *ns = NULL; + const axis2_char_t *ns_prefix = NULL; + const axis2_char_t *ns_uri = NULL; + + if(soap_version == AXIOM_SOAP11) + { + ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; + } + else if(soap_version == AXIOM_SOAP12) + { + ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; + } + else + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_SOAP_VERSION, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid SOAP version"); + return NULL; + } + if(!prefix || axutil_strcmp(prefix, "") == 0) + { + ns_prefix = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX; + } + else + { + ns_prefix = prefix; + } + + ns = axiom_namespace_create(env, ns_uri, ns_prefix); + if(!ns) + return NULL; + return axiom_soap_envelope_create(env, ns); +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_envelope_free( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env) +{ + if(--(soap_envelope->ref) > 0) + { + return; + } + if(soap_envelope->header) + { + axiom_soap_header_free(soap_envelope->header, env); + } + if(soap_envelope->body) + { + axiom_soap_body_free(soap_envelope->body, env); + } + if(soap_envelope->om_ele_node) + { + if(soap_envelope->soap_builder) + { + axiom_soap_builder_free(soap_envelope->soap_builder, env); + soap_envelope->om_ele_node = NULL; + } + else + { + axiom_node_free_tree(soap_envelope->om_ele_node, env); + } + } + + AXIS2_FREE(env->allocator, soap_envelope); + return; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_soap_envelope_get_base_node( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env) +{ + return soap_envelope->om_ele_node; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_envelope_set_base_node( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + soap_envelope->om_ele_node = node; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN int AXIS2_CALL +axiom_soap_envelope_get_soap_version( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env) +{ + return soap_envelope->soap_version; +} + +/** this is an internal function */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_envelope_set_soap_version_internal( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env, + int soap_version) +{ + soap_envelope->soap_version = soap_version; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_soap_header_t *AXIS2_CALL +axiom_soap_envelope_get_header( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + + if(soap_envelope->header) + { + return soap_envelope->header; + } + else if(soap_envelope->soap_builder) + { + while(!(soap_envelope->header) && !(soap_envelope->body) && !axiom_node_is_complete( + soap_envelope->om_ele_node, env)) + { + status = axiom_soap_builder_next(soap_envelope->soap_builder, env); + if(status == AXIS2_FAILURE) + { + break; + } + } + } + + return soap_envelope->header; +} + +AXIS2_EXTERN axiom_soap_header_block_t *AXIS2_CALL +axiom_soap_envelope_add_header( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env, + axis2_char_t * namespace_uri, + axis2_char_t * name) +{ + axiom_namespace_t *ns = NULL; + + if(!soap_envelope->header) + { + return NULL; + } + if(namespace_uri) + { + ns = axiom_namespace_create(env, namespace_uri, NULL); + } + + return axiom_soap_header_block_create_with_parent(env, name, ns, soap_envelope->header); +} + +AXIS2_EXTERN axiom_soap_body_t *AXIS2_CALL +axiom_soap_envelope_get_body( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + + if(soap_envelope->body) + { + return soap_envelope->body; + } + else if(soap_envelope->soap_builder) + { + while(!(soap_envelope->body) && !axiom_node_is_complete(soap_envelope->om_ele_node, env)) + { + status = axiom_soap_builder_next(soap_envelope->soap_builder, env); + if(status == AXIS2_FAILURE) + { + return NULL; + } + } + } + return soap_envelope->body; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_envelope_serialize( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env, + axiom_output_t * om_output, + axis2_bool_t cache) +{ + AXIS2_PARAM_CHECK(env->error, soap_envelope, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE); + + /* + if soap version is soap11 we modify the soap fault part. + This is done because the builder construct a soap12 fault all + the time. So when serializing if the soap version is soap11 + we should convert it back to soap11 fault + */ + if(soap_envelope->soap_version == AXIOM_SOAP11) + { + axiom_soap_body_t *soap_body = NULL; + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + axiom_soap_body_convert_fault_to_soap11(soap_body, env); + } + /* write the xml version and encoding + These should be set to om output before calling the serialize function + Otherwise default values will be written + */ + axiom_output_get_content_type(om_output, env); + return axiom_node_serialize(soap_envelope->om_ele_node, env, om_output); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_envelope_set_body( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env, + axiom_soap_body_t * body) +{ + + if(!(soap_envelope->body)) + { + soap_envelope->body = body; + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "trying to set a soap bedy to soap_envelope when a soap body alrady exists"); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_envelope_set_header( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env, + axiom_soap_header_t * header) +{ + + if(!(soap_envelope->header)) + { + soap_envelope->header = header; + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + " trying to set a soap header to soap_envelope when a soap header alrady exists"); + return AXIS2_FAILURE; + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_namespace_t *AXIS2_CALL +axiom_soap_envelope_get_namespace( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env) +{ + + if(soap_envelope->om_ele_node) + { + axiom_element_t *ele = NULL; + if(axiom_node_get_node_type(soap_envelope->om_ele_node, env) == AXIOM_ELEMENT) + { + ele = (axiom_element_t *)axiom_node_get_data_element(soap_envelope-> om_ele_node, env); + if(ele) + { + return axiom_element_get_namespace(ele, env, soap_envelope->om_ele_node); + } + } + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_envelope_set_builder( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env, + axiom_soap_builder_t * soap_builder) +{ + AXIS2_PARAM_CHECK(env->error, soap_builder, AXIS2_FAILURE); + soap_envelope->soap_builder = soap_builder; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_soap_builder_t *AXIS2_CALL +axiom_soap_envelope_get_builder( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env) +{ + if(!soap_envelope) + { + return NULL; + } + return soap_envelope->soap_builder; +} + +AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL +axiom_soap_envelope_create_default_soap_envelope( + const axutil_env_t * env, + int soap_version) +{ + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_soap_header_t *soap_header = NULL; + axiom_soap_body_t *soap_body = NULL; + axiom_namespace_t *om_ns = NULL; + + if(soap_version == AXIOM_SOAP11) + { + om_ns = axiom_namespace_create(env, AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI, + AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX); + if(!om_ns) + { + return NULL; + } + soap_envelope = axiom_soap_envelope_create(env, om_ns); + + soap_header = axiom_soap_header_create_with_parent(env, soap_envelope); + soap_body = axiom_soap_body_create_with_parent(env, soap_envelope); + soap_envelope->body = soap_body; + soap_envelope->header = soap_header; + return soap_envelope; + } + else if(soap_version == AXIOM_SOAP12) + { + om_ns = axiom_namespace_create(env, AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI, + AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX); + if(!om_ns) + { + return NULL; + } + soap_envelope = axiom_soap_envelope_create(env, om_ns); + + soap_header = axiom_soap_header_create_with_parent(env, soap_envelope); + soap_body = axiom_soap_body_create_with_parent(env, soap_envelope); + soap_envelope->body = soap_body; + soap_envelope->header = soap_header; + return soap_envelope; + } + + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_SOAP_VERSION, AXIS2_FAILURE); + return NULL; +} + +AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL +axiom_soap_envelope_create_default_soap_fault_envelope( + const axutil_env_t * env, + const axis2_char_t * code_value, + const axis2_char_t * reason_text, + const int soap_version, + axutil_array_list_t * sub_codes, + axiom_node_t * detail_node) +{ + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_soap_body_t *soap_body = NULL; + axiom_soap_fault_t *fault = NULL; + + if(AXIOM_SOAP11 != soap_version && AXIOM_SOAP12 != soap_version) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_SOAP_VERSION, AXIS2_FAILURE); + return NULL; + } + + soap_envelope = axiom_soap_envelope_create_default_soap_envelope(env, soap_version); + if(!soap_envelope) + { + return NULL; + } + + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + if(!soap_body) + { + axiom_soap_envelope_free(soap_envelope, env); + return NULL; + } + fault = axiom_soap_fault_create_default_fault(env, soap_body, code_value, reason_text, + soap_version); + if(!fault) + { + axiom_soap_envelope_free(soap_envelope, env); + return NULL; + } + + if(sub_codes) + { + int i = 0; + axiom_soap_fault_code_t *fault_code = NULL; + fault_code = axiom_soap_fault_get_code(fault, env); + if(fault_code) + { + for(i = 0; i < axutil_array_list_size(sub_codes, env); i++) + { + axis2_char_t *sub_code = (axis2_char_t *)axutil_array_list_get(sub_codes, env, i); + if(sub_code) + { + axiom_soap_fault_sub_code_create_with_parent_value(env, fault_code, sub_code); + } + } + } + } + + if(detail_node) + { + axiom_soap_fault_detail_t *detail = axiom_soap_fault_detail_create_with_parent(env, fault); + if(detail) + { + axiom_soap_fault_detail_add_detail_entry(detail, env, detail_node); + } + } + + return soap_envelope; + +} + +static axis2_status_t +check_and_set_soap_version( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env, + axiom_namespace_t * ns) +{ + axis2_char_t *uri = NULL; + if(!soap_envelope) + { + return AXIS2_FAILURE; + } + if(!ns) + { + return AXIS2_FAILURE; + } + uri = axiom_namespace_get_uri(ns, env); + if(!uri) + { + return AXIS2_FAILURE; + } + if(axutil_strcmp(uri, AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI) == 0) + { + soap_envelope->soap_version = AXIOM_SOAP11; + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(uri, AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI) == 0) + { + soap_envelope->soap_version = AXIOM_SOAP12; + return AXIS2_SUCCESS; + } + else + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_SOAP_NAMESPACE_URI, AXIS2_FAILURE); + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_envelope_set_soap_version( + axiom_soap_envelope_t * soap_envelope, + const axutil_env_t * env, + int soap_version) +{ + axiom_element_t *env_ele = NULL; + axiom_namespace_t *env_ns = NULL; + const axis2_char_t *ns_uri = NULL; + int status = AXIS2_SUCCESS; + + if(soap_version == AXIOM_SOAP11) + { + ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; + } + else if(soap_version == AXIOM_SOAP12) + { + ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; + } + else + { + return AXIS2_FAILURE; + } + + env_ele = (axiom_element_t *)axiom_node_get_data_element(soap_envelope->om_ele_node, env); + if(!env_ele) + { + return AXIS2_FAILURE; + } + + env_ns = axiom_element_get_namespace(env_ele, env, soap_envelope->om_ele_node); + if(!env_ns) + { + return AXIS2_FAILURE; + } + status = axiom_namespace_set_uri(env_ns, env, ns_uri); + if(status == AXIS2_SUCCESS) + { + axiom_soap_envelope_set_soap_version_internal(soap_envelope, env, soap_version); + return AXIS2_SUCCESS; + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_envelope_increment_ref( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env) +{ + envelope->ref++; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN struct axiom_soap_builder *AXIS2_CALL +axiom_soap_envelope_get_soap_builder( + axiom_soap_envelope_t * envelope, + const axutil_env_t * env) +{ + return envelope->soap_builder; +} + diff --git a/axiom/src/soap/soap_fault.c b/axiom/src/soap/soap_fault.c new file mode 100644 index 0000000..7ee69a8 --- /dev/null +++ b/axiom/src/soap/soap_fault.c @@ -0,0 +1,630 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "_axiom_soap_fault.h" +#include +#include "_axiom_soap_body.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct axiom_soap_fault +{ + /* om element node corresponding to soap soap_fault */ + axiom_node_t *om_ele_node; + + /* soap soap_fault code sub element */ + axiom_soap_fault_code_t *fcode; + /* soap soap_fault reason sub element */ + axiom_soap_fault_reason_t *freason; + /* soap soap_fault node sub element */ + axiom_soap_fault_node_t *fnode; + /* soap soap_fault role sub element */ + axiom_soap_fault_role_t *frole; + /* soap soap_fault detail sub element */ + axiom_soap_fault_detail_t *fdetail; + + axis2_char_t *exception; + /* reference to soap builder */ + axiom_soap_builder_t *soap_builder; + + int soap_version; +}; + +AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL +axiom_soap_fault_create( + const axutil_env_t * env) +{ + axiom_soap_fault_t *soap_fault = NULL; + soap_fault = (axiom_soap_fault_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_soap_fault_t)); + if(!soap_fault) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create a SOAP fault"); + return NULL; + } + soap_fault->exception = NULL; + soap_fault->fcode = NULL; + soap_fault->fdetail = NULL; + soap_fault->fnode = NULL; + soap_fault->freason = NULL; + soap_fault->frole = NULL; + soap_fault->om_ele_node = NULL; + soap_fault->soap_builder = NULL; + soap_fault->soap_version = -1; + return soap_fault; +} + +AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL +axiom_soap_fault_create_with_parent( + const axutil_env_t * env, + axiom_soap_body_t * body) +{ + axiom_soap_fault_t *soap_fault = NULL; + axiom_element_t *this_ele = NULL; + axiom_node_t *this_node = NULL; + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + axiom_namespace_t *parent_ns = NULL; + + AXIS2_PARAM_CHECK(env->error, body, NULL); + + soap_fault = axiom_soap_fault_create(env); + if(!soap_fault) + { + return NULL; + } + parent_node = axiom_soap_body_get_base_node(body, env); + if(!parent_node) + { + AXIS2_FREE(env->allocator, soap_fault); + return NULL; + } + soap_fault->soap_version = axiom_soap_body_get_soap_version(body, env); + + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(!parent_ele) + { + AXIS2_FREE(env->allocator, soap_fault); + return NULL; + } + parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + + this_ele = axiom_element_create(env, parent_node, AXIOM_SOAP_FAULT_LOCAL_NAME, parent_ns, + &this_node); + if(!this_ele) + { + AXIS2_FREE(env->allocator, soap_fault); + return NULL; + } + + soap_fault->om_ele_node = this_node; + axiom_soap_body_set_fault(body, env, soap_fault); + return soap_fault; +} + +AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL +axiom_soap_fault_create_with_exception( + const axutil_env_t * env, + axiom_soap_body_t * body, + axis2_char_t * exception) +{ + axiom_soap_fault_t *soap_fault = NULL; + axis2_status_t status = AXIS2_SUCCESS; + AXIS2_PARAM_CHECK(env->error, body, NULL); + AXIS2_PARAM_CHECK(env->error, exception, NULL); + soap_fault = axiom_soap_fault_create_with_parent(env, body); + if(!soap_fault) + { + return NULL; + } + status = axiom_soap_fault_set_exception(soap_fault, env, exception); + if(status == AXIS2_FAILURE) + { + axiom_soap_fault_free(soap_fault, env); + return NULL; + } + return soap_fault; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_fault_free( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env) +{ + + if(soap_fault->fcode) + { + axiom_soap_fault_code_free(soap_fault->fcode, env); + soap_fault->fcode = NULL; + } + if(soap_fault->fdetail) + { + axiom_soap_fault_detail_free(soap_fault->fdetail, env); + soap_fault->fdetail = NULL; + } + if(soap_fault->fnode) + { + axiom_soap_fault_node_free(soap_fault->fnode, env); + soap_fault->fnode = NULL; + } + if(soap_fault->freason) + { + axiom_soap_fault_reason_free(soap_fault->freason, env); + soap_fault->freason = NULL; + } + if(soap_fault->frole) + { + axiom_soap_fault_role_free(soap_fault->frole, env); + soap_fault->frole = NULL; + } + AXIS2_FREE(env->allocator, soap_fault); + soap_fault = NULL; + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_set_code( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env, + axiom_soap_fault_code_t * code) +{ + AXIS2_PARAM_CHECK(env->error, code, AXIS2_FAILURE); + if(!(soap_fault->fcode)) + { + soap_fault->fcode = code; + return AXIS2_SUCCESS; + } + else + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, + "tring to set multiple code elements to soap_fault "); + + } + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_soap_fault_code_t *AXIS2_CALL +axiom_soap_fault_get_code( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + if(soap_fault->fcode) + { + return soap_fault->fcode; + } + else if(soap_fault->soap_builder) + { + while(!(soap_fault->fcode) && !(axiom_node_is_complete(soap_fault->om_ele_node, env))) + { + status = axiom_soap_builder_next(soap_fault->soap_builder, env); + if(status == AXIS2_FAILURE) + { + break; + } + } + } + return soap_fault->fcode; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_set_reason( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env, + axiom_soap_fault_reason_t * reason) +{ + AXIS2_PARAM_CHECK(env->error, reason, AXIS2_FAILURE); + if(!(soap_fault->freason)) + { + soap_fault->freason = reason; + return AXIS2_SUCCESS; + } + else + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "tring to set soap_fault reason twice"); + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_soap_fault_reason_t *AXIS2_CALL +axiom_soap_fault_get_reason( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + if(soap_fault->freason) + { + return soap_fault->freason; + } + else if(soap_fault->soap_builder) + { + while(!(soap_fault->freason) && !(axiom_node_is_complete(soap_fault->om_ele_node, env))) + { + status = axiom_soap_builder_next(soap_fault->soap_builder, env); + if(status == AXIS2_FAILURE) + { + break; + } + } + } + return soap_fault->freason; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_set_node( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env, + axiom_soap_fault_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + if(!(soap_fault->fnode)) + { + soap_fault->fnode = node; + return AXIS2_SUCCESS; + } + else + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "tring to set soap_fault node more than once"); + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_soap_fault_node_t *AXIS2_CALL +axiom_soap_fault_get_node( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + + if(soap_fault->fnode) + { + return soap_fault->fnode; + } + else if(soap_fault->soap_builder) + { + while(!(soap_fault->fnode) && !(axiom_node_is_complete(soap_fault->om_ele_node, env))) + { + status = axiom_soap_builder_next(soap_fault->soap_builder, env); + if(status == AXIS2_FAILURE) + { + break; + } + } + } + return soap_fault->fnode; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_set_role( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env, + axiom_soap_fault_role_t * role) +{ + AXIS2_PARAM_CHECK(env->error, role, AXIS2_FAILURE); + + if(!(soap_fault->frole)) + { + soap_fault->frole = role; + return AXIS2_FAILURE; + } + else + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "tring to set soap_fault role more than once "); + } + return AXIS2_FAILURE; + +} + +AXIS2_EXTERN axiom_soap_fault_role_t *AXIS2_CALL +axiom_soap_fault_get_role( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + if(soap_fault->frole) + { + return soap_fault->frole; + } + else if(soap_fault->soap_builder) + { + while(!(soap_fault->frole) && !(axiom_node_is_complete(soap_fault->om_ele_node, env))) + { + status = axiom_soap_builder_next(soap_fault->soap_builder, env); + if(status == AXIS2_FAILURE) + { + break; + } + } + } + return soap_fault->frole; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_set_detail( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env, + axiom_soap_fault_detail_t * detail) +{ + AXIS2_PARAM_CHECK(env->error, detail, AXIS2_FAILURE); + + if(!(soap_fault->fdetail)) + { + soap_fault->fdetail = detail; + return AXIS2_SUCCESS; + } + else + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, " tring to set soap_fault detail more than once"); + + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_soap_fault_detail_t *AXIS2_CALL +axiom_soap_fault_get_detail( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + if(soap_fault->fdetail) + { + return soap_fault->fdetail; + } + else if(soap_fault->soap_builder) + { + while(!(soap_fault->fdetail) && !(axiom_node_is_complete(soap_fault->om_ele_node, env))) + { + status = axiom_soap_builder_next(soap_fault->soap_builder, env); + if(status == AXIS2_FAILURE) + { + break; + } + } + } + return soap_fault->fdetail; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_set_base_node( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + soap_fault->om_ele_node = node; + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_soap_fault_get_base_node( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env) +{ + return soap_fault->om_ele_node; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_soap_fault_get_exception( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env) +{ + axiom_soap_fault_detail_t *detail = NULL; + axiom_node_t *detail_node = NULL; + axiom_element_t *detail_ele = NULL; + axiom_node_t *exception_node = NULL; + axiom_element_t *exception_ele = NULL; + axutil_qname_t *qn = NULL; + axis2_char_t *excep = NULL; + + detail = axiom_soap_fault_get_detail(soap_fault, env); + if(!detail) + { + return NULL; + } + detail_node = axiom_soap_fault_detail_get_base_node(detail, env); + if(detail_node) + { + detail_ele = (axiom_element_t *)axiom_node_get_data_element(detail_node, env); + + qn = axutil_qname_create(env, AXIOM_SOAP_FAULT_DETAIL_EXCEPTION_ENTRY, NULL, NULL); + if(qn) + { + exception_ele = axiom_element_get_first_child_with_qname(detail_ele, env, qn, + detail_node, &exception_node); + axutil_qname_free(qn, env); + if(exception_ele) + { + excep = axiom_element_get_text(exception_ele, env, exception_node); + } + return excep; + } + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_set_exception( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env, + axis2_char_t * exception) +{ + axiom_soap_fault_detail_t *detail = NULL; + axiom_node_t *fault_detail_entry_node = NULL; + axiom_element_t *fault_detail_ele = NULL; + + AXIS2_PARAM_CHECK(env->error, exception, AXIS2_FAILURE); + + detail = axiom_soap_fault_get_detail(soap_fault, env); + + if(!detail) + { + detail = axiom_soap_fault_detail_create_with_parent(env, soap_fault); + if(!detail) + { + return AXIS2_FAILURE; + } + } + + /** create an om element with the exception enrty */ + + fault_detail_ele = axiom_element_create(env, NULL, AXIOM_SOAP_FAULT_DETAIL_EXCEPTION_ENTRY, + NULL, &fault_detail_entry_node); + if(!fault_detail_ele) + { + return AXIS2_FAILURE; + } + + /** set the exception string as a text node of newly created om element */ + axiom_element_set_text(fault_detail_ele, env, exception, fault_detail_entry_node); + + /** now add this om element as a child of soap soap_fault detail om element node */ + return axiom_soap_fault_detail_add_detail_entry(detail, env, fault_detail_entry_node); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_set_builder( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env, + axiom_soap_builder_t * builder) +{ + AXIS2_PARAM_CHECK(env->error, builder, AXIS2_FAILURE); + soap_fault->soap_builder = builder; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_soap_fault_t *AXIS2_CALL +axiom_soap_fault_create_default_fault( + const axutil_env_t * env, + struct axiom_soap_body * parent, + const axis2_char_t * code_value, + const axis2_char_t * reason_text, + const int soap_version) +{ + axiom_soap_fault_t *soap_fault = NULL; + axiom_node_t *fault_node = NULL; + + axiom_soap_fault_code_t *soap_fault_code = NULL; + axiom_soap_fault_value_t *soap_fault_value = NULL; + + axiom_soap_fault_reason_t *soap_fault_reason = NULL; + axiom_soap_fault_text_t *soap_fault_text = NULL; + + axiom_node_t *value_node = NULL; + axiom_element_t *value_ele = NULL; + + axiom_node_t *text_node = NULL; + axiom_element_t *text_ele = NULL; + + AXIS2_PARAM_CHECK(env->error, code_value, NULL); + AXIS2_PARAM_CHECK(env->error, reason_text, NULL); + + soap_fault = axiom_soap_fault_create_with_parent(env, parent); + if(!soap_fault) + { + return NULL; + } + fault_node = axiom_soap_fault_get_base_node(soap_fault, env); + if(!fault_node) + { + axiom_soap_fault_free(soap_fault, env); + return NULL; + } + + soap_fault_code = axiom_soap_fault_code_create_with_parent(env, soap_fault); + if(!soap_fault_code) + { + axiom_soap_fault_free(soap_fault, env); + axiom_node_free_tree(fault_node, env); + return NULL; + } + soap_fault_reason = axiom_soap_fault_reason_create_with_parent(env, soap_fault); + if(!soap_fault_reason) + { + axiom_soap_fault_free(soap_fault, env); + axiom_node_free_tree(fault_node, env); + return NULL; + } + + soap_fault_value = axiom_soap_fault_value_create_with_code(env, soap_fault_code); + if(!soap_fault_value) + { + axiom_soap_fault_free(soap_fault, env); + axiom_node_free_tree(fault_node, env); + return NULL; + } + + value_node = axiom_soap_fault_value_get_base_node(soap_fault_value, env); + if(!value_node) + { + return NULL; + } + value_ele = (axiom_element_t *)axiom_node_get_data_element(value_node, env); + + axiom_element_set_text(value_ele, env, code_value, value_node); + + soap_fault_text = axiom_soap_fault_text_create_with_parent(env, soap_fault_reason); + if(!soap_fault_text) + { + axiom_soap_fault_free(soap_fault, env); + axiom_node_free_tree(fault_node, env); + return NULL; + } + axiom_soap_fault_text_set_lang(soap_fault_text, env, "en"); + + text_node = axiom_soap_fault_text_get_base_node(soap_fault_text, env); + if(!text_node) + { + return NULL; + } + text_ele = (axiom_element_t *)axiom_node_get_data_element(text_node, env); + + axiom_element_set_text(text_ele, env, reason_text, text_node); + + return soap_fault; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_set_soap_version( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env, + int soap_version) +{ + soap_fault->soap_version = soap_version; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN int AXIS2_CALL +axiom_soap_fault_get_soap_version( + axiom_soap_fault_t * soap_fault, + const axutil_env_t * env) +{ + return soap_fault->soap_version; +} diff --git a/axiom/src/soap/soap_fault_code.c b/axiom/src/soap/soap_fault_code.c new file mode 100644 index 0000000..b0ded55 --- /dev/null +++ b/axiom/src/soap/soap_fault_code.c @@ -0,0 +1,308 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "_axiom_soap_fault_code.h" +#include +#include +#include +#include "_axiom_soap_fault.h" + +struct axiom_soap_fault_code +{ + axiom_node_t *om_ele_node; + + axiom_soap_fault_sub_code_t *subcode; + + axiom_soap_fault_value_t *value; + + axiom_soap_builder_t *builder; + + int soap_version; + +}; + +AXIS2_EXTERN axiom_soap_fault_code_t *AXIS2_CALL +axiom_soap_fault_code_create( + const axutil_env_t * env) +{ + axiom_soap_fault_code_t *fault_code = NULL; + fault_code = (axiom_soap_fault_code_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap_fault_code_t)); + + if(!fault_code) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create SOAP fault code"); + return NULL; + } + + fault_code->om_ele_node = NULL; + fault_code->subcode = NULL; + fault_code->value = NULL; + fault_code->builder = NULL; + fault_code->soap_version = AXIOM_SOAP_VERSION_NOT_SET; + + return fault_code; +} + +AXIS2_EXTERN axiom_soap_fault_code_t *AXIS2_CALL +axiom_soap_fault_code_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault) +{ + axiom_soap_fault_code_t *fault_code = NULL; + axiom_element_t *this_ele = NULL; + axiom_node_t *this_node = NULL; + + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + + axiom_namespace_t *parent_ns = NULL; + + AXIS2_PARAM_CHECK(env->error, fault, NULL); + + fault_code = axiom_soap_fault_code_create(env); + if(!fault_code) + { + return NULL; + } + + parent_node = axiom_soap_fault_get_base_node(fault, env); + if(!parent_node) + { + axiom_soap_fault_code_free(fault_code, env); + return NULL; + } + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + + if(!parent_ele) + { + axiom_soap_fault_code_free(fault_code, env); + return NULL; + } + fault_code->soap_version = axiom_soap_fault_get_soap_version(fault, env); + if(fault_code->soap_version == AXIOM_SOAP12) + { + parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + } + this_ele = axiom_element_create(env, parent_node, AXIOM_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME, + parent_ns, &this_node); + + if(!this_ele) + { + axiom_soap_fault_code_free(fault_code, env); + return NULL; + } + + fault_code->om_ele_node = this_node; + + axiom_soap_fault_set_code(fault, env, fault_code); + + return fault_code; +} + +AXIS2_EXTERN axiom_soap_fault_code_t *AXIS2_CALL +axiom_soap_fault_code_create_with_parent_value( + const axutil_env_t * env, + axiom_soap_fault_t * fault, + axis2_char_t * value) +{ + axiom_soap_fault_code_t *fault_code = NULL; + axiom_soap_fault_value_t *fault_value = NULL; + AXIS2_PARAM_CHECK(env->error, value, NULL); + + fault_code = axiom_soap_fault_code_create_with_parent(env, fault); + if(!fault_code) + { + return NULL; + } + + fault_value = axiom_soap_fault_value_create_with_code(env, fault_code); + if(!fault_value) + { + axiom_soap_fault_code_free(fault_code, env); + return NULL; + } + axiom_soap_fault_value_set_text(fault_value, env, value); + return fault_code; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_fault_code_free( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env) +{ + + if(fault_code->subcode) + { + axiom_soap_fault_sub_code_free(fault_code->subcode, env); + } + if(fault_code->value) + { + axiom_soap_fault_value_free(fault_code->value, env); + } + + AXIS2_FREE(env->allocator, fault_code); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_code_set_value( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env, + axiom_soap_fault_value_t * fault_val) +{ + + AXIS2_PARAM_CHECK(env->error, fault_val, AXIS2_FAILURE); + + if(!(fault_code->value)) + { + fault_code->value = fault_val; + return AXIS2_SUCCESS; + } + else + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, + "trying to set fault value to fault code more than once"); + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_code_set_sub_code( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env, + axiom_soap_fault_sub_code_t * fault_subcode) +{ + AXIS2_PARAM_CHECK(env->error, fault_subcode, AXIS2_FAILURE); + + if(!(fault_code->subcode)) + { + fault_code->subcode = fault_subcode; + return AXIS2_SUCCESS; + } + else + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, + "trying to set fault subcode to fault code more than once "); + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_soap_fault_sub_code_t *AXIS2_CALL +axiom_soap_fault_code_get_sub_code( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + + if(fault_code->subcode) + { + return fault_code->subcode; + } + else if(fault_code->builder) + { + while(!(fault_code->subcode) && !(axiom_node_is_complete(fault_code->om_ele_node, env))) + { + status = axiom_soap_builder_next(fault_code->builder, env); + if(status == AXIS2_FAILURE) + { + break; + } + } + } + return fault_code->subcode; +} + +AXIS2_EXTERN axiom_soap_fault_value_t *AXIS2_CALL +axiom_soap_fault_code_get_value( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + + if(fault_code->value) + { + return fault_code->value; + } + else if(fault_code->builder) + { + while(!(fault_code->value) && !(axiom_node_is_complete(fault_code->om_ele_node, env))) + { + status = axiom_soap_builder_next(fault_code->builder, env); + if(status == AXIS2_FAILURE) + { + break; + } + } + } + return fault_code->value; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_code_set_base_node( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + fault_code->om_ele_node = node; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_soap_fault_code_get_base_node( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env) +{ + return fault_code->om_ele_node; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_code_set_builder( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env, + axiom_soap_builder_t * soap_builder) +{ + AXIS2_PARAM_CHECK(env->error, soap_builder, AXIS2_FAILURE); + fault_code->builder = soap_builder; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN int AXIS2_CALL +axiom_soap_fault_code_get_soap_version( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env) +{ + return fault_code->soap_version; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_code_set_soap_version( + axiom_soap_fault_code_t * fault_code, + const axutil_env_t * env, + int soap_version) +{ + fault_code->soap_version = soap_version; + return AXIS2_SUCCESS; +} diff --git a/axiom/src/soap/soap_fault_detail.c b/axiom/src/soap/soap_fault_detail.c new file mode 100644 index 0000000..0375767 --- /dev/null +++ b/axiom/src/soap/soap_fault_detail.c @@ -0,0 +1,160 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "_axiom_soap_fault.h" +#include +#include +#include "_axiom_soap_fault_detail.h" + +struct axiom_soap_fault_detail +{ + axiom_node_t *om_ele_node; +}; + +AXIS2_EXTERN axiom_soap_fault_detail_t *AXIS2_CALL +axiom_soap_fault_detail_create( + const axutil_env_t * env) +{ + axiom_soap_fault_detail_t *fault_detail = NULL; + + fault_detail = (axiom_soap_fault_detail_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap_fault_detail_t)); + if(!fault_detail) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create a fault detail"); + return NULL; + } + + fault_detail->om_ele_node = NULL; + + return fault_detail; +} + +AXIS2_EXTERN axiom_soap_fault_detail_t *AXIS2_CALL +axiom_soap_fault_detail_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault) +{ + axiom_soap_fault_detail_t *fault_detail = NULL; + axiom_element_t *this_ele = NULL; + axiom_node_t *this_node = NULL; + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + axiom_namespace_t *parent_ns = NULL; + int soap_version = -1; + + AXIS2_PARAM_CHECK(env->error, fault, NULL); + + fault_detail = axiom_soap_fault_detail_create(env); + if(!fault_detail) + { + return NULL; + } + parent_node = axiom_soap_fault_get_base_node(fault, env); + if(!parent_node) + { + return NULL; + } + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(!parent_ele) + { + return NULL; + } + soap_version = axiom_soap_fault_get_soap_version(fault, env); + if(soap_version == AXIOM_SOAP12) + { + parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + } + this_ele = axiom_element_create(env, parent_node, AXIOM_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME, + parent_ns, &this_node); + + if(!this_ele) + { + axiom_soap_fault_detail_free(fault_detail, env); + return NULL; + } + fault_detail->om_ele_node = this_node; + axiom_soap_fault_set_detail(fault, env, fault_detail); + return fault_detail; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_fault_detail_free( + axiom_soap_fault_detail_t * fault_detail, + const axutil_env_t * env) +{ + AXIS2_FREE(env->allocator, fault_detail); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_detail_add_detail_entry( + axiom_soap_fault_detail_t * fault_detail, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_OM_ELEMENT_EXPECTED, AXIS2_FAILURE); + + return AXIS2_FAILURE; + } + + axiom_node_add_child(fault_detail->om_ele_node, env, node); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_children_iterator_t *AXIS2_CALL +axiom_soap_fault_detail_get_all_detail_entries( + axiom_soap_fault_detail_t * fault_detail, + const axutil_env_t * env) +{ + axiom_element_t *om_ele = NULL; + if(fault_detail->om_ele_node) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(fault_detail->om_ele_node, env); + return axiom_element_get_children(om_ele, env, fault_detail->om_ele_node); + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_detail_set_base_node( + axiom_soap_fault_detail_t * fault_detail, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + fault_detail->om_ele_node = node; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL axiom_soap_fault_detail_get_base_node( + axiom_soap_fault_detail_t * fault_detail, + const axutil_env_t * env) +{ + return fault_detail->om_ele_node; +} diff --git a/axiom/src/soap/soap_fault_node.c b/axiom/src/soap/soap_fault_node.c new file mode 100644 index 0000000..143bc87 --- /dev/null +++ b/axiom/src/soap/soap_fault_node.c @@ -0,0 +1,176 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "_axiom_soap_fault_node.h" +#include +#include +#include "_axiom_soap_fault.h" + +struct axiom_soap_fault_node +{ + axiom_node_t *om_ele_node; +}; + +AXIS2_EXTERN axiom_soap_fault_node_t *AXIS2_CALL +axiom_soap_fault_node_create( + const axutil_env_t * env) +{ + axiom_soap_fault_node_t *fault_node = NULL; + + fault_node = (axiom_soap_fault_node_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap_fault_node_t)); + + if(!fault_node) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create a SOAP fault node"); + return NULL; + } + fault_node->om_ele_node = NULL; + + return fault_node; +} + +AXIS2_EXTERN axiom_soap_fault_node_t *AXIS2_CALL +axiom_soap_fault_node_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault) +{ + axiom_soap_fault_node_t *fault_node = NULL; + axiom_element_t *this_ele = NULL; + axiom_node_t *this_node = NULL; + + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + + axiom_namespace_t *parent_ns = NULL; + + AXIS2_PARAM_CHECK(env->error, fault, NULL); + + fault_node = axiom_soap_fault_node_create(env); + if(!fault_node) + { + return NULL; + } + parent_node = axiom_soap_fault_get_base_node(fault, env); + if(!parent_node) + { + axiom_soap_fault_node_free(fault_node, env); + return NULL; + } + + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(!parent_ele) + { + axiom_soap_fault_node_free(fault_node, env); + return NULL; + } + + parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + + this_ele = axiom_element_create(env, parent_node, AXIOM_SOAP12_SOAP_FAULT_NODE_LOCAL_NAME, + parent_ns, &this_node); + + if(!this_ele) + { + axiom_soap_fault_node_free(fault_node, env); + return NULL; + } + + fault_node->om_ele_node = this_node; + + axiom_soap_fault_set_node(fault, env, fault_node); + + return fault_node; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_fault_node_free( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env) +{ + AXIS2_FREE(env->allocator, fault_node); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_node_set_value( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env, + axis2_char_t * uri) +{ + axiom_element_t *om_ele = NULL; + + AXIS2_PARAM_CHECK(env->error, uri, AXIS2_FAILURE); + + if(fault_node->om_ele_node) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(fault_node-> om_ele_node, env); + + if(om_ele) + { + return axiom_element_set_text(om_ele, env, uri, fault_node->om_ele_node); + } + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_soap_fault_node_get_value( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env) +{ + axiom_element_t *om_ele = NULL; + + if(fault_node->om_ele_node) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(fault_node-> om_ele_node, env); + if(om_ele) + { + return axiom_element_get_text(om_ele, env, fault_node->om_ele_node); + } + + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_node_set_base_node( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + fault_node->om_ele_node = node; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_soap_fault_node_get_base_node( + axiom_soap_fault_node_t * fault_node, + const axutil_env_t * env) +{ + return fault_node->om_ele_node; +} diff --git a/axiom/src/soap/soap_fault_reason.c b/axiom/src/soap/soap_fault_reason.c new file mode 100644 index 0000000..516d58c --- /dev/null +++ b/axiom/src/soap/soap_fault_reason.c @@ -0,0 +1,386 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "_axiom_soap_fault.h" +#include +#include +#include +#include + +struct axiom_soap_fault_reason +{ + /* corresponding om element node */ + axiom_node_t *om_ele_node; + + axutil_array_list_t *fault_texts; + /* pointer to soap builder */ + axiom_soap_builder_t *soap_builder; + + int soap_version; +}; + +static axis2_bool_t +axiom_soap_fault_reason_lang_exists( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + axis2_char_t * lang); + +AXIS2_EXTERN axiom_soap_fault_reason_t *AXIS2_CALL +axiom_soap_fault_reason_create( + const axutil_env_t * env) +{ + axiom_soap_fault_reason_t *fault_reason = NULL; + fault_reason = (axiom_soap_fault_reason_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap_fault_reason_t)); + if(!fault_reason) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create SOAP fault reason"); + return NULL; + } + + fault_reason->om_ele_node = NULL; + fault_reason->fault_texts = NULL; + fault_reason->soap_version = -1; + return fault_reason; +} + +AXIS2_EXTERN axiom_soap_fault_reason_t *AXIS2_CALL +axiom_soap_fault_reason_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault) +{ + axiom_soap_fault_reason_t *fault_reason = NULL; + axiom_element_t *this_ele = NULL; + axiom_node_t *this_node = NULL; + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + axiom_namespace_t *parent_ns = NULL; + + AXIS2_PARAM_CHECK(env->error, fault, NULL); + + fault_reason = axiom_soap_fault_reason_create(env); + if(!fault_reason) + { + return NULL; + } + parent_node = axiom_soap_fault_get_base_node(fault, env); + if(!parent_node) + { + return NULL; + } + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(!parent_ele) + { + return NULL; + } + fault_reason->soap_version = axiom_soap_fault_get_soap_version(fault, env); + if(fault_reason->soap_version == AXIOM_SOAP12) + { + parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + } + this_ele = axiom_element_create(env, parent_node, AXIOM_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME, + parent_ns, &this_node); + if(!this_ele) + { + return NULL; + } + + fault_reason->om_ele_node = this_node; + + axiom_soap_fault_set_reason(fault, env, fault_reason); + return fault_reason; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_fault_reason_free( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env) +{ + + if(fault_reason->fault_texts) + { + int size = 0; + int i = 0; + size = axutil_array_list_size(fault_reason->fault_texts, env); + + for(i = 0; i < size; i++) + { + axiom_soap_fault_text_t *fault_text = NULL; + void *value = NULL; + value = axutil_array_list_get(fault_reason->fault_texts, env, i); + if(value) + { + fault_text = (axiom_soap_fault_text_t *)value; + axiom_soap_fault_text_free(fault_text, env); + fault_text = NULL; + } + } + axutil_array_list_free(fault_reason->fault_texts, env); + fault_reason->fault_texts = NULL; + } + + AXIS2_FREE(env->allocator, fault_reason); + + fault_reason = NULL; + + return; +} + +AXIS2_EXTERN axiom_soap_fault_text_t *AXIS2_CALL +axiom_soap_fault_reason_get_soap_fault_text( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + axis2_char_t * lang) +{ + int status = AXIS2_SUCCESS; + int size = 0; + int i = 0; + + AXIS2_PARAM_CHECK(env->error, fault_reason, NULL); + if(!lang || (axutil_strcmp(lang, "") == 0)) + { + return NULL; + } + /** Here we have to build the soap fault reason element completly */ + if(!fault_reason->fault_texts) + { + + if(fault_reason->soap_builder && !(axiom_node_is_complete(fault_reason->om_ele_node, env))) + { + while(!(axiom_node_is_complete(fault_reason->om_ele_node, env))) + { + status = axiom_soap_builder_next(fault_reason->soap_builder, env); + if(status == AXIS2_FAILURE) + { + return NULL; + } + } + } + } + + if(!fault_reason->fault_texts) + { + return NULL; + } + /** iterate the array list */ + size = axutil_array_list_size(fault_reason->fault_texts, env); + for(i = 0; i < size; i++) + { + axiom_soap_fault_text_t *fault_text = NULL; + void *value = NULL; + + value = axutil_array_list_get(fault_reason->fault_texts, env, i); + if(value) + { + axis2_char_t *fault_lang = NULL; + fault_text = (axiom_soap_fault_text_t *)value; + fault_lang = axiom_soap_fault_text_get_lang(fault_text, env); + if(fault_lang && axutil_strcmp(lang, fault_lang) == 0) + { + return fault_text; + } + } + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_reason_set_base_node( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + fault_reason->om_ele_node = node; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL axiom_soap_fault_reason_get_base_node( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env) +{ + return fault_reason->om_ele_node; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_reason_set_builder( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + axiom_soap_builder_t * builder) +{ + AXIS2_PARAM_CHECK(env->error, builder, AXIS2_FAILURE); + + fault_reason->soap_builder = builder; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axiom_soap_fault_reason_get_all_soap_fault_texts( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + + if(!(fault_reason->fault_texts) && (fault_reason->soap_builder)) + { + if(!(axiom_node_is_complete(fault_reason->om_ele_node, env))) + { + while(!(axiom_node_is_complete(fault_reason->om_ele_node, env))) + { + status = axiom_soap_builder_next(fault_reason->soap_builder, env); + if(status == AXIS2_FAILURE) + { + return NULL; + } + } + } + } + return fault_reason->fault_texts; +} + +AXIS2_EXTERN axiom_soap_fault_text_t *AXIS2_CALL +axiom_soap_fault_reason_get_first_soap_fault_text( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + + if(!(fault_reason->fault_texts) && (fault_reason->soap_builder)) + { + if(!(axiom_node_is_complete(fault_reason->om_ele_node, env))) + { + while(!(axiom_node_is_complete(fault_reason->om_ele_node, env))) + { + status = axiom_soap_builder_next(fault_reason->soap_builder, env); + if(status == AXIS2_FAILURE) + { + return NULL; + } + } + } + } + if(fault_reason->fault_texts) + { + void *value = NULL; + value = axutil_array_list_get(fault_reason->fault_texts, env, 0); + if(value) + { + return (axiom_soap_fault_text_t *)value; + } + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_reason_add_soap_fault_text( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + axiom_soap_fault_text_t * fault_text) +{ + if(!fault_text) + { + return AXIS2_FAILURE; + } + if(!(fault_reason->fault_texts)) + { + fault_reason->fault_texts = axutil_array_list_create(env, 1); + if(!fault_reason->fault_texts) + { + return AXIS2_FAILURE; + } + axutil_array_list_add(fault_reason->fault_texts, env, fault_text); + } + else + { + axis2_char_t *lang = NULL; + axis2_bool_t is_exists = AXIS2_FALSE; + lang = axiom_soap_fault_text_get_lang(fault_text, env); + if(lang) + { + is_exists = axiom_soap_fault_reason_lang_exists(fault_reason, env, lang); + if(is_exists == AXIS2_TRUE) + { + return AXIS2_FAILURE; + } + /** this soap_fault text already exists */ + } + axutil_array_list_add(fault_reason->fault_texts, env, fault_text); + } + return AXIS2_SUCCESS; +} + +static axis2_bool_t +axiom_soap_fault_reason_lang_exists( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + axis2_char_t * lang) +{ + int size = 0; + int i = 0; + + if(!lang || (axutil_strcmp(lang, "") == 0) || !fault_reason->fault_texts) + { + return AXIS2_FALSE; + } + size = axutil_array_list_size(fault_reason->fault_texts, env); + for(i = 0; i < size; i++) + { + axiom_soap_fault_text_t *fault_text = NULL; + void *value = NULL; + value = axutil_array_list_get(fault_reason->fault_texts, env, i); + if(value) + { + axis2_char_t *text_lang = NULL; + fault_text = (axiom_soap_fault_text_t *)value; + + text_lang = axiom_soap_fault_text_get_lang(fault_text, env); + if(text_lang && (axutil_strcmp(lang, text_lang) == 0)) + { + return AXIS2_TRUE; + } + } + } + return AXIS2_FALSE; +} + +/** internal function */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_reason_set_soap_version( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env, + int soap_version) +{ + fault_reason->soap_version = soap_version; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_reason_get_soap_version( + axiom_soap_fault_reason_t * fault_reason, + const axutil_env_t * env) +{ + return fault_reason->soap_version; +} diff --git a/axiom/src/soap/soap_fault_role.c b/axiom/src/soap/soap_fault_role.c new file mode 100644 index 0000000..a438ea4 --- /dev/null +++ b/axiom/src/soap/soap_fault_role.c @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "_axiom_soap_fault.h" +#include +#include + +struct axiom_soap_fault_role +{ + axiom_node_t *om_ele_node; +}; + +AXIS2_EXTERN axiom_soap_fault_role_t *AXIS2_CALL +axiom_soap_fault_role_create( + const axutil_env_t * env) +{ + axiom_soap_fault_role_t *fault_role = NULL; + + fault_role = (axiom_soap_fault_role_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap_fault_role_t)); + + if(!fault_role) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create SOAP fault role"); + return NULL; + } + + fault_role->om_ele_node = NULL; + + return fault_role; +} + +AXIS2_EXTERN axiom_soap_fault_role_t *AXIS2_CALL +axiom_soap_fault_role_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_t * fault) +{ + axiom_soap_fault_role_t *fault_role = NULL; + int soap_version = -1; + + axiom_element_t *this_ele = NULL; + axiom_node_t *this_node = NULL; + + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + + axiom_namespace_t *parent_ns = NULL; + + AXIS2_PARAM_CHECK(env->error, fault, NULL); + + fault_role = axiom_soap_fault_role_create(env); + if(!fault_role) + { + return NULL; + } + parent_node = axiom_soap_fault_get_base_node(fault, env); + if(!parent_node) + { + axiom_soap_fault_role_free(fault_role, env); + return NULL; + } + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + + if(!parent_ele) + { + axiom_soap_fault_role_free(fault_role, env); + return NULL; + } + soap_version = axiom_soap_fault_get_soap_version(fault, env); + if(soap_version == AXIOM_SOAP12) + { + parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + } + this_ele = axiom_element_create(env, parent_node, AXIOM_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME, + parent_ns, &this_node); + + if(!this_ele) + { + axiom_soap_fault_role_free(fault_role, env); + return NULL; + } + + fault_role->om_ele_node = this_node; + + axiom_soap_fault_set_role(fault, env, fault_role); + + return fault_role; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_fault_role_free( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env) +{ + AXIS2_FREE(env->allocator, fault_role); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_role_set_role_value( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env, + axis2_char_t * uri) +{ + axiom_element_t *role_ele = NULL; + + AXIS2_PARAM_CHECK(env->error, uri, AXIS2_FAILURE); + + if(!fault_role->om_ele_node) + { + return AXIS2_FAILURE; + } + role_ele = (axiom_element_t *)axiom_node_get_data_element(fault_role->om_ele_node, env); + + if(role_ele) + { + return axiom_element_set_text(role_ele, env, uri, fault_role->om_ele_node); + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL axiom_soap_fault_role_get_role_value( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env) +{ + axiom_element_t *role_ele = NULL; + + if (!fault_role->om_ele_node) + { + return NULL; + } + role_ele = (axiom_element_t *) axiom_node_get_data_element + (fault_role->om_ele_node, env); + + if (role_ele) + { + return axiom_element_get_text(role_ele, env, fault_role->om_ele_node); + } + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_role_set_base_node( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + fault_role->om_ele_node = node; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL axiom_soap_fault_role_get_base_node( + axiom_soap_fault_role_t * fault_role, + const axutil_env_t * env) +{ + return fault_role->om_ele_node; +} diff --git a/axiom/src/soap/soap_fault_sub_code.c b/axiom/src/soap/soap_fault_sub_code.c new file mode 100644 index 0000000..904b406 --- /dev/null +++ b/axiom/src/soap/soap_fault_sub_code.c @@ -0,0 +1,298 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "_axiom_soap_fault_code.h" +#include +#include + +struct axiom_soap_fault_sub_code +{ + /* corresponding om element node */ + axiom_node_t *om_ele_node; + /* sub element fault value */ + axiom_soap_fault_value_t *value; + /* sub element fault subcode */ + axiom_soap_fault_sub_code_t *subcode; + /* pointer to soap builder */ + axiom_soap_builder_t *builder; + + int soap_version; +}; + +AXIS2_EXTERN axiom_soap_fault_sub_code_t *AXIS2_CALL +axiom_soap_fault_sub_code_create( + const axutil_env_t * env) +{ + axiom_soap_fault_sub_code_t *fault_sub_code = NULL; + AXIS2_ENV_CHECK(env, NULL); + fault_sub_code = (axiom_soap_fault_sub_code_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap_fault_sub_code_t)); + if(!fault_sub_code) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create SOAP fault sub-code"); + return NULL; + } + + fault_sub_code->om_ele_node = NULL; + fault_sub_code->value = NULL; + fault_sub_code->subcode = NULL; + fault_sub_code->builder = NULL; + + return fault_sub_code; +} + +AXIS2_EXTERN axiom_soap_fault_sub_code_t *AXIS2_CALL +axiom_soap_fault_sub_code_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_code_t * fault_code) +{ + axiom_soap_fault_sub_code_t *fault_sub_code = NULL; + axiom_element_t *this_ele = NULL; + axiom_node_t *this_node = NULL; + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + axiom_namespace_t *parent_ns = NULL; + + AXIS2_PARAM_CHECK(env->error, fault_code, NULL); + fault_sub_code = axiom_soap_fault_sub_code_create(env); + + if(!fault_sub_code) + { + return NULL; + } + parent_node = axiom_soap_fault_code_get_base_node(fault_code, env); + if(!parent_node) + { + axiom_soap_fault_sub_code_free(fault_sub_code, env); + return NULL; + } + + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(!parent_ele) + { + axiom_soap_fault_sub_code_free(fault_sub_code, env); + return NULL; + } + fault_sub_code->soap_version = axiom_soap_fault_code_get_soap_version(fault_code, env); + + if(fault_sub_code->soap_version == AXIOM_SOAP12) + { + parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + } + + this_ele = axiom_element_create(env, parent_node, AXIOM_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME, + parent_ns, &this_node); + + if(!this_ele) + { + axiom_soap_fault_sub_code_free(fault_sub_code, env); + return NULL; + } + + fault_sub_code->om_ele_node = this_node; + + axiom_soap_fault_code_set_sub_code(fault_code, env, fault_sub_code); + + return fault_sub_code; +} + +AXIS2_EXTERN axiom_soap_fault_sub_code_t *AXIS2_CALL +axiom_soap_fault_sub_code_create_with_parent_value( + const axutil_env_t * env, + axiom_soap_fault_code_t * fault_code, + axis2_char_t * value) +{ + axiom_soap_fault_sub_code_t *fault_sub_code = NULL; + axiom_soap_fault_value_t *fault_value = NULL; + AXIS2_PARAM_CHECK(env->error, value, NULL); + + fault_sub_code = axiom_soap_fault_sub_code_create_with_parent(env, fault_code); + if(!fault_sub_code) + { + return NULL; + } + fault_value = axiom_soap_fault_value_create_with_subcode(env, fault_sub_code); + if(!fault_value) + { + axiom_soap_fault_sub_code_free(fault_sub_code, env); + return NULL; + } + + axiom_soap_fault_value_set_text(fault_value, env, value); + return fault_sub_code; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_fault_sub_code_free( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env) +{ + if(fault_sub_code->value) + { + axiom_soap_fault_value_free(fault_sub_code->value, env); + fault_sub_code->value = NULL; + } + if(fault_sub_code->subcode) + { + axiom_soap_fault_sub_code_free(fault_sub_code->subcode, env); + fault_sub_code->subcode = NULL; + } + AXIS2_FREE(env->allocator, fault_sub_code); + + fault_sub_code = NULL; + + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_sub_code_set_sub_code( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env, + axiom_soap_fault_sub_code_t * subcode) +{ + AXIS2_PARAM_CHECK(env->error, subcode, AXIS2_FAILURE); + + if(!(fault_sub_code->subcode)) + { + fault_sub_code->subcode = subcode; + return AXIS2_SUCCESS; + } + else + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "error tring to set fault subcode more than once"); + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_soap_fault_value_t *AXIS2_CALL +axiom_soap_fault_sub_code_get_value( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + + if(fault_sub_code->builder) + { + while(!(fault_sub_code->value) && !axiom_node_is_complete(fault_sub_code->om_ele_node, env)) + { + status = axiom_soap_builder_next(fault_sub_code->builder, env); + if(status == AXIS2_FAILURE) + { + break; + } + } + } + return fault_sub_code->value; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_sub_code_set_value( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env, + axiom_soap_fault_value_t * fault_sub_code_val) +{ + AXIS2_PARAM_CHECK(env->error, fault_sub_code_val, AXIS2_FAILURE); + + if(!(fault_sub_code->value)) + { + fault_sub_code->value = fault_sub_code_val; + return AXIS2_SUCCESS; + } + else + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, + "error tring to set fault subcode value more than once"); + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_soap_fault_sub_code_t *AXIS2_CALL +axiom_soap_fault_sub_code_get_subcode( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env) +{ + int status = AXIS2_SUCCESS; + + if(fault_sub_code->builder) + { + while(!(fault_sub_code->subcode) && !axiom_node_is_complete(fault_sub_code->om_ele_node, + env)) + { + status = axiom_soap_builder_next(fault_sub_code->builder, env); + if(status == AXIS2_FAILURE) + { + break; + } + } + } + return fault_sub_code->subcode; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_sub_code_set_base_node( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + fault_sub_code->om_ele_node = node; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL axiom_soap_fault_sub_code_get_base_node( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env) +{ + return fault_sub_code->om_ele_node; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_sub_code_set_builder( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env, + axiom_soap_builder_t * builder) +{ + AXIS2_PARAM_CHECK(env->error, builder, AXIS2_FAILURE); + + fault_sub_code->builder = builder; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_sub_code_set_soap_version( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env, + int soap_version) +{ + fault_sub_code->soap_version = soap_version; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN int AXIS2_CALL axiom_soap_fault_sub_code_get_soap_version( + axiom_soap_fault_sub_code_t * fault_sub_code, + const axutil_env_t * env) +{ + return fault_sub_code->soap_version; +} diff --git a/axiom/src/soap/soap_fault_text.c b/axiom/src/soap/soap_fault_text.c new file mode 100644 index 0000000..9c51821 --- /dev/null +++ b/axiom/src/soap/soap_fault_text.c @@ -0,0 +1,305 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "_axiom_soap_fault_text.h" +#include "_axiom_soap_fault_reason.h" +#include +#include + +struct axiom_soap_fault_text +{ + axiom_attribute_t *lang_attribute; + + axiom_namespace_t *lang_namespace; + + axiom_node_t *om_ele_node; + + axis2_bool_t lang_ns_used; +}; + +AXIS2_EXTERN axiom_soap_fault_text_t *AXIS2_CALL +axiom_soap_fault_text_create( + const axutil_env_t * env) +{ + axiom_soap_fault_text_t *fault_text = NULL; + + fault_text = (axiom_soap_fault_text_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap_fault_text_t)); + if(!fault_text) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create SOAP fault text"); + return NULL; + } + + fault_text->om_ele_node = NULL; + fault_text->lang_attribute = NULL; + fault_text->lang_namespace = NULL; + fault_text->lang_ns_used = AXIS2_FALSE; + + fault_text->lang_namespace = axiom_namespace_create(env, + AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_NS_URI, + AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_NS_PREFIX); + + if(!(fault_text->lang_namespace)) + { + return NULL; + } + + return fault_text; +} + +AXIS2_EXTERN axiom_soap_fault_text_t *AXIS2_CALL +axiom_soap_fault_text_create_with_parent( + const axutil_env_t * env, + axiom_soap_fault_reason_t * parent) +{ + axiom_soap_fault_text_t *fault_text = NULL; + axiom_element_t *this_ele = NULL; + int soap_version = -1; + axiom_node_t *this_node = NULL; + axiom_namespace_t *parent_ns = NULL; + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + + AXIS2_PARAM_CHECK(env->error, parent, NULL); + + fault_text = axiom_soap_fault_text_create(env); + + if(!fault_text) + { + return NULL; + } + + parent_node = axiom_soap_fault_reason_get_base_node(parent, env); + if(!parent_node) + { + axiom_soap_fault_text_free(fault_text, env); + return NULL; + } + + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(!parent_ele) + { + axiom_soap_fault_text_free(fault_text, env); + return NULL; + } + + soap_version = axiom_soap_fault_reason_get_soap_version(parent, env); + if(AXIOM_SOAP12 == soap_version) + { + parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + } + this_ele = axiom_element_create(env, parent_node, AXIOM_SOAP12_SOAP_FAULT_TEXT_LOCAL_NAME, + parent_ns, &this_node); + + if(!this_ele) + { + axiom_soap_fault_text_free(fault_text, env); + return NULL; + } + + fault_text->om_ele_node = this_node; + + axiom_soap_fault_reason_add_soap_fault_text(parent, env, fault_text); + + return fault_text; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_fault_text_free( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env) +{ + + if(fault_text->lang_ns_used == AXIS2_FALSE && fault_text->lang_namespace) + { + axiom_namespace_free(fault_text->lang_namespace, env); + fault_text->lang_namespace = NULL; + } + AXIS2_FREE(env->allocator, fault_text); + fault_text = NULL; + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_text_set_lang( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env, + const axis2_char_t * lang) +{ + int status = AXIS2_SUCCESS; + axiom_element_t *om_ele = NULL; + + AXIS2_PARAM_CHECK(env->error, lang, AXIS2_FAILURE); + + if(fault_text->lang_attribute) + { + axis2_char_t *attr_lang = NULL; + attr_lang = axiom_attribute_get_value(fault_text->lang_attribute, env); + if(attr_lang) + { + if(axutil_strcmp(attr_lang, lang) == 0) + { + + /** this attribute already exists */ + return AXIS2_SUCCESS; + } + } + axiom_attribute_set_value(fault_text->lang_attribute, env, lang); + return AXIS2_SUCCESS; + } + + fault_text->lang_attribute = axiom_attribute_create(env, + AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME, lang, fault_text-> lang_namespace); + if(!fault_text->lang_attribute) + { + return AXIS2_FAILURE; + } + + if(!fault_text->om_ele_node) + { + return AXIS2_FAILURE; + } + om_ele = (axiom_element_t *)axiom_node_get_data_element(fault_text->om_ele_node, env); + if(!om_ele) + { + return AXIS2_FAILURE; + } + + status = axiom_element_add_attribute(om_ele, env, fault_text->lang_attribute, + fault_text->om_ele_node); + + if(status == AXIS2_SUCCESS) + { + fault_text->lang_ns_used = AXIS2_TRUE; + } + else + { + axiom_attribute_free(fault_text->lang_attribute, env); + fault_text->lang_attribute = NULL; + } + return status; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_soap_fault_text_get_lang( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env) +{ + axiom_element_t *om_ele = NULL; + axutil_qname_t *tmp_qname = NULL; + + if(!fault_text->om_ele_node) + { + return NULL; + } + om_ele = (axiom_element_t *)axiom_node_get_data_element(fault_text->om_ele_node, env); + if(!om_ele) + { + return NULL; + } + if(!(fault_text->lang_attribute)) + { + + /* this logic need to be rechecked */ + tmp_qname = axutil_qname_create(env, AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME, + AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_NS_URI, + AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_NS_PREFIX); + + fault_text->lang_attribute = axiom_element_get_attribute(om_ele, env, tmp_qname); + axutil_qname_free(tmp_qname, env); + } + if(fault_text->lang_attribute) + { + return axiom_attribute_get_value(fault_text->lang_attribute, env); + } + else + return NULL; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_text_set_base_node( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env, + axiom_node_t * node) +{ + + if(node && (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT)) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + fault_text->om_ele_node = node; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_soap_fault_text_get_base_node( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env) +{ + return fault_text->om_ele_node; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_text_set_text( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env, + axis2_char_t * value, + axis2_char_t * lang) +{ + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + + if(fault_text->om_ele_node) + { + axiom_element_t *text_ele = NULL; + text_ele = (axiom_element_t *)axiom_node_get_data_element(fault_text->om_ele_node, env); + if(text_ele) + { + axiom_element_set_text(text_ele, env, value, fault_text->om_ele_node); + if(lang) + { + axiom_soap_fault_text_set_lang(fault_text, env, lang); + } + return AXIS2_SUCCESS; + } + } + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_soap_fault_text_get_text( + axiom_soap_fault_text_t * fault_text, + const axutil_env_t * env) +{ + axis2_char_t *text = NULL; + + if(fault_text->om_ele_node) + { + axiom_element_t *text_ele = NULL; + text_ele = (axiom_element_t *)axiom_node_get_data_element(fault_text->om_ele_node, env); + if(text_ele) + { + text = axiom_element_get_text(text_ele, env, fault_text->om_ele_node); + return text; + } + } + return NULL; +} diff --git a/axiom/src/soap/soap_fault_value.c b/axiom/src/soap/soap_fault_value.c new file mode 100644 index 0000000..775cba4 --- /dev/null +++ b/axiom/src/soap/soap_fault_value.c @@ -0,0 +1,237 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include "_axiom_soap_fault_sub_code.h" +#include "_axiom_soap_fault_code.h" +#include +#include + +struct axiom_soap_fault_value +{ + + /** store om element node */ + axiom_node_t *om_ele_node; +}; + +AXIS2_EXTERN axiom_soap_fault_value_t *AXIS2_CALL +axiom_soap_fault_value_create( + const axutil_env_t * env) +{ + axiom_soap_fault_value_t *fault_value = NULL; + + fault_value = (axiom_soap_fault_value_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap_fault_value_t)); + + if(!fault_value) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create SOAP fault value"); + return NULL; + } + + fault_value->om_ele_node = NULL; + + return fault_value; +} + +AXIS2_EXTERN axiom_soap_fault_value_t *AXIS2_CALL +axiom_soap_fault_value_create_with_subcode( + const axutil_env_t * env, + axiom_soap_fault_sub_code_t * parent) +{ + axiom_soap_fault_value_t *fault_value = NULL; + + axiom_element_t *this_ele = NULL; + axiom_node_t *this_node = NULL; + axiom_namespace_t *parent_ns = NULL; + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + int soap_version = -1; + + AXIS2_PARAM_CHECK(env->error, parent, NULL); + + fault_value = axiom_soap_fault_value_create(env); + + if(!fault_value) + { + return NULL; + } + + parent_node = axiom_soap_fault_sub_code_get_base_node(parent, env); + + if(!parent_node) + { + axiom_soap_fault_value_free(fault_value, env); + return NULL; + } + + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + + if(!parent_ele) + { + axiom_soap_fault_value_free(fault_value, env); + return NULL; + } + soap_version = axiom_soap_fault_sub_code_get_soap_version(parent, env); + if(soap_version == AXIOM_SOAP12) + { + parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + } + + this_ele = axiom_element_create(env, parent_node, AXIOM_SOAP12_SOAP_FAULT_VALUE_LOCAL_NAME, + parent_ns, &this_node); + + if(!this_ele) + { + axiom_soap_fault_value_free(fault_value, env); + return NULL; + } + + fault_value->om_ele_node = this_node; + + axiom_soap_fault_sub_code_set_value(parent, env, fault_value); + + return fault_value; +} + +AXIS2_EXTERN axiom_soap_fault_value_t *AXIS2_CALL +axiom_soap_fault_value_create_with_code( + const axutil_env_t * env, + axiom_soap_fault_code_t * parent) +{ + axiom_soap_fault_value_t *fault_value = NULL; + int soap_version = -1; + axiom_element_t *this_ele = NULL; + axiom_node_t *this_node = NULL; + axiom_namespace_t *parent_ns = NULL; + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + + AXIS2_PARAM_CHECK(env->error, parent, NULL); + + fault_value = axiom_soap_fault_value_create(env); + + if(!fault_value) + { + return NULL; + } + + parent_node = axiom_soap_fault_code_get_base_node(parent, env); + if(!parent_node) + { + axiom_soap_fault_value_free(fault_value, env); + return NULL; + } + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(!parent_ele) + { + axiom_soap_fault_value_free(fault_value, env); + return NULL; + } + soap_version = axiom_soap_fault_code_get_soap_version(parent, env); + if(soap_version == AXIOM_SOAP12) + { + parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + } + this_ele = axiom_element_create(env, parent_node, AXIOM_SOAP12_SOAP_FAULT_VALUE_LOCAL_NAME, + parent_ns, &this_node); + + if(!this_ele) + { + axiom_soap_fault_value_free(fault_value, env); + return NULL; + } + fault_value->om_ele_node = this_node; + + axiom_soap_fault_code_set_value(parent, env, fault_value); + + return fault_value; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_fault_value_free( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env) +{ + AXIS2_FREE(env->allocator, fault_value); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_value_set_base_node( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env, + axiom_node_t * node) +{ + + if(node && (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT)) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + fault_value->om_ele_node = node; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_soap_fault_value_get_base_node( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env) +{ + return fault_value->om_ele_node; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_soap_fault_value_get_text( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env) +{ + axiom_node_t *value_node = NULL; + axiom_element_t *value_element = NULL; + + value_node = axiom_soap_fault_value_get_base_node(fault_value, env); + + if(!value_node) + { + return NULL; + } + value_element = (axiom_element_t *)axiom_node_get_data_element(value_node, env); + + if(!value_element) + { + return NULL; + } + return axiom_element_get_text(value_element, env, value_node); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_fault_value_set_text( + axiom_soap_fault_value_t * fault_value, + const axutil_env_t * env, + axis2_char_t * text) +{ + AXIS2_PARAM_CHECK(env->error, text, AXIS2_FAILURE); + if(fault_value->om_ele_node && axiom_node_get_node_type(fault_value->om_ele_node, env) + == AXIOM_ELEMENT) + { + axiom_element_t *om_ele = NULL; + om_ele = (axiom_element_t *)axiom_node_get_data_element(fault_value->om_ele_node, env); + return axiom_element_set_text(om_ele, env, text, fault_value->om_ele_node); + } + return AXIS2_FAILURE; +} diff --git a/axiom/src/soap/soap_header.c b/axiom/src/soap/soap_header.c new file mode 100644 index 0000000..6c6a71c --- /dev/null +++ b/axiom/src/soap/soap_header.c @@ -0,0 +1,655 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "_axiom_soap_envelope.h" +#include "_axiom_soap_header.h" +#include "_axiom_soap_body.h" +#include +#include +#include +#include +#include +#include +#include + +struct axiom_soap_header +{ + axiom_node_t *om_ele_node; + + int soap_version; + + axutil_hash_t *header_blocks; + + int hbnumber; + + axiom_soap_builder_t *soap_builder; + + axiom_soap_envelope_t *soap_envelope; + + axutil_array_list_t *header_block_keys; +}; + +static axis2_bool_t AXIS2_CALL axiom_soap_header_qname_matches( + const axutil_env_t * env, + axutil_qname_t * element_qname, + axutil_qname_t * qname_to_match); + +AXIS2_EXTERN axiom_soap_header_t *AXIS2_CALL +axiom_soap_header_create( + const axutil_env_t * env) +{ + axiom_soap_header_t *soap_header = NULL; + + soap_header = (axiom_soap_header_t *)AXIS2_MALLOC(env->allocator, sizeof(axiom_soap_header_t)); + if(!soap_header) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create SOAP header"); + return NULL; + } + + soap_header->om_ele_node = NULL; + soap_header->soap_envelope = NULL; + soap_header->hbnumber = 0; + soap_header->header_blocks = NULL; + + /** default value */ + soap_header->soap_version = AXIOM_SOAP12; + soap_header->header_block_keys = NULL; + + soap_header->header_block_keys = axutil_array_list_create(env, 10); + if(!soap_header->header_block_keys) + { + AXIS2_FREE(env->allocator, soap_header); + return NULL; + } + + return soap_header; +} + +AXIS2_EXTERN axiom_soap_header_t *AXIS2_CALL +axiom_soap_header_create_with_parent( + const axutil_env_t * env, + axiom_soap_envelope_t * envelope) +{ + axiom_soap_header_t *soap_header = NULL; + + /*axiom_element_t *this_ele = NULL; + axiom_node_t *this_node = NULL;*/ + axiom_node_t *body_node = NULL; + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + + /*axiom_namespace_t *parent_ns = NULL;*/ + + AXIS2_PARAM_CHECK(env->error, envelope, NULL); + + soap_header = axiom_soap_header_create(env); + if(!soap_header) + { + return NULL; + } + soap_header->soap_version = axiom_soap_envelope_get_soap_version(envelope, env); + + parent_node = axiom_soap_envelope_get_base_node(envelope, env); + + if(!parent_node || axiom_node_get_node_type(parent_node, env) != AXIOM_ELEMENT) + { + axiom_soap_header_free(soap_header, env); + return NULL; + } + + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(!parent_ele) + { + axiom_soap_header_free(soap_header, env); + return NULL; + } + if(axiom_node_get_first_element(parent_node, env)) + { + body_node = axiom_node_get_first_element(parent_node, env); + axiom_node_detach(body_node, env); + } + + /*parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + this_ele = axiom_element_create(env, parent_node, + AXIOM_SOAP_HEADER_LOCAL_NAME, parent_ns, + &this_node); + if (!this_ele) + { + axiom_soap_header_free(soap_header, env); + return NULL; + } + + soap_header->om_ele_node = this_node;*/ + + axiom_soap_envelope_set_header(envelope, env, soap_header); + + if(body_node) + { + axiom_node_add_child(parent_node, env, body_node); + } + + soap_header->soap_envelope = envelope; + + return soap_header; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_header_free( + axiom_soap_header_t * soap_header, + const axutil_env_t * env) +{ + + if(soap_header->header_blocks) + { + axutil_hash_index_t *hi = NULL; + void *val = NULL; + for(hi = axutil_hash_first(soap_header->header_blocks, env); hi; hi = axutil_hash_next(env, + hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + + if(val) + { + axiom_soap_header_block_free((axiom_soap_header_block_t *)val, env); + val = NULL; + } + } + + axutil_hash_free(soap_header->header_blocks, env); + } + if(soap_header->header_block_keys) + { + int size = 0; + void *val = NULL; + int i = 0; + size = axutil_array_list_size(soap_header->header_block_keys, env); + for(i = 0; i < size; i++) + { + val = axutil_array_list_get(soap_header->header_block_keys, env, i); + if(val) + { + AXIS2_FREE(env->allocator, (char *)val); + val = NULL; + } + } + axutil_array_list_free(soap_header->header_block_keys, env); + soap_header->header_block_keys = NULL; + } + AXIS2_FREE(env->allocator, soap_header); + + soap_header = NULL; + + return; +} + +AXIS2_EXTERN axiom_soap_header_block_t *AXIS2_CALL +axiom_soap_header_add_header_block( + axiom_soap_header_t * soap_header, + const axutil_env_t * env, + const axis2_char_t * localname, + axiom_namespace_t * ns) +{ + axiom_soap_header_block_t *header_block = NULL; + + axiom_namespace_t *cloned_ns = NULL; + + axiom_node_t *header_block_node = NULL; + + AXIS2_PARAM_CHECK(env->error, localname, NULL); + AXIS2_PARAM_CHECK(env->error, ns, NULL); + + cloned_ns = axiom_namespace_clone(ns, env); + if(!cloned_ns) + { + return NULL; + } + header_block = axiom_soap_header_block_create_with_parent(env, localname, cloned_ns, + soap_header); + + if(!header_block) + { + return NULL; + } + header_block_node = axiom_soap_header_block_get_base_node(header_block, env); + + if(header_block_node) + { + axiom_node_set_complete(header_block_node, env, AXIS2_TRUE); + + return header_block; + } + else + { + return NULL; + } +} +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL axiom_soap_header_examine_header_blocks( + axiom_soap_header_t * soap_header, + const axutil_env_t * env, + axis2_char_t * param_role) +{ + AXIS2_PARAM_CHECK(env->error, param_role, NULL); + + return soap_header->header_blocks; +} + +AXIS2_EXTERN axiom_children_qname_iterator_t *AXIS2_CALL +axiom_soap_header_examine_all_header_blocks( + axiom_soap_header_t * soap_header, + const axutil_env_t * env) +{ + axiom_element_t *om_ele = NULL; + + if(!soap_header->om_ele_node) + { + return NULL; + } + om_ele = (axiom_element_t *)axiom_node_get_data_element(soap_header-> om_ele_node, env); + + if(om_ele) + { + return axiom_element_get_children_with_qname(om_ele, env, NULL, soap_header->om_ele_node); + } + else + return NULL; +} + +AXIS2_EXTERN axiom_children_with_specific_attribute_iterator_t *AXIS2_CALL +axiom_soap_header_extract_header_blocks( + axiom_soap_header_t * soap_header, + const axutil_env_t * env, + axis2_char_t * role) +{ + const axis2_char_t *localname = NULL; + const axis2_char_t *nsuri = NULL; + + axiom_node_t *first_node = NULL; + axiom_element_t *first_ele = NULL; + + axutil_qname_t *qn = NULL; + + axiom_element_t *header_om_ele = NULL; + axiom_children_with_specific_attribute_iterator_t *iter = NULL; + + if(soap_header->soap_version == AXIOM_SOAP_VERSION_NOT_SET) + { + return NULL; + } + if(soap_header->soap_version == AXIOM_SOAP11) + { + localname = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; + nsuri = AXIOM_SOAP11_ATTR_ACTOR; + } + if(soap_header->soap_version == AXIOM_SOAP12) + { + localname = AXIOM_SOAP12_SOAP_ROLE; + nsuri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; + } + + qn = axutil_qname_create(env, localname, nsuri, NULL); + if(!qn) + { + return NULL; + } + header_om_ele = (axiom_element_t *)axiom_node_get_data_element(soap_header->om_ele_node, env); + + if(header_om_ele) + { + first_ele = axiom_element_get_first_element(header_om_ele, env, soap_header->om_ele_node, + &first_node); + if(first_node) + { + return axiom_children_with_specific_attribute_iterator_create(env, first_node, qn, + role, AXIS2_TRUE); + } + } + + axutil_qname_free(qn, env); + + return iter; + +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_set_base_node( + axiom_soap_header_t * soap_header, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + + soap_header->om_ele_node = node; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_soap_header_get_base_node( + axiom_soap_header_t * soap_header, + const axutil_env_t * env) +{ + if(!soap_header->om_ele_node) + { + axiom_node_t *parent_node = NULL; + axiom_element_t *parent_ele = NULL; + axiom_namespace_t *parent_ns = NULL; + axiom_element_t *this_ele = NULL; + axiom_node_t *this_node = NULL; + axiom_soap_body_t *soap_body = NULL; + axiom_node_t *body_node = NULL; + + parent_node = axiom_soap_envelope_get_base_node(soap_header->soap_envelope, env); + + if(!parent_node || axiom_node_get_node_type(parent_node, env) != AXIOM_ELEMENT) + { + axiom_soap_header_free(soap_header, env); + return NULL; + } + + parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); + if(!parent_ele) + { + axiom_soap_header_free(soap_header, env); + return NULL; + } + + parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); + this_ele = axiom_element_create(env, NULL, AXIOM_SOAP_HEADER_LOCAL_NAME, parent_ns, + &this_node); + if(!this_ele) + { + axiom_soap_header_free(soap_header, env); + return NULL; + } + + soap_body = axiom_soap_envelope_get_body(soap_header->soap_envelope, env); + if(soap_body) + { + body_node = axiom_soap_body_get_base_node(soap_body, env); + axiom_node_insert_sibling_before(body_node, env, this_node); + } + else + { + axiom_node_add_child(parent_node, env, this_node); + } + soap_header->om_ele_node = this_node; + } + + return soap_header->om_ele_node; +} + +/** + set soap version and get soap version are internal functions + + */ +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_get_soap_version( + axiom_soap_header_t * soap_header, + const axutil_env_t * env) +{ + return soap_header->soap_version; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_set_soap_version( + axiom_soap_header_t * soap_header, + const axutil_env_t * env, + int soap_version) +{ + soap_header->soap_version = soap_version; + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_set_header_block( + axiom_soap_header_t * soap_header, + const axutil_env_t * env, + struct axiom_soap_header_block * header_block) +{ + axis2_char_t *key = NULL; + AXIS2_PARAM_CHECK(env->error, header_block, AXIS2_FAILURE); + + key = (axis2_char_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 10); + + if(!key) + { + return AXIS2_FAILURE; + } + sprintf(key, "%d", soap_header->hbnumber++); + + if(soap_header->header_blocks) + { + axutil_hash_set(soap_header->header_blocks, key, AXIS2_HASH_KEY_STRING, header_block); + } + else + { + soap_header->header_blocks = axutil_hash_make(env); + axutil_hash_set(soap_header->header_blocks, key, AXIS2_HASH_KEY_STRING, header_block); + } + if(soap_header->header_block_keys) + { + axutil_array_list_add(soap_header->header_block_keys, env, key); + } + return AXIS2_SUCCESS; + +} +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_set_builder( + axiom_soap_header_t * soap_header, + const axutil_env_t * env, + struct axiom_soap_builder * builder) +{ + AXIS2_PARAM_CHECK(env->error, builder, AXIS2_FAILURE); + + soap_header->soap_builder = builder; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +axiom_soap_header_get_header_blocks_with_namespace_uri( + axiom_soap_header_t * soap_header, + const axutil_env_t * env, + const axis2_char_t * ns_uri) +{ + axutil_array_list_t *header_block_list = NULL; + axutil_hash_index_t *hash_index = NULL; + + axiom_soap_header_block_t *header_block = NULL; + + axiom_node_t *header_block_om_node = NULL; + axiom_element_t *header_block_om_ele = NULL; + + axiom_namespace_t *ns = NULL; + axis2_char_t *hb_namespace_uri = NULL; + + int found = 0; + void *hb = NULL; + + AXIS2_PARAM_CHECK(env->error, ns_uri, NULL); + + if(!(soap_header->header_blocks)) + { + return NULL; + } + header_block_list = axutil_array_list_create(env, 10); + if(!header_block_list) + { + return NULL; + } + for(hash_index = axutil_hash_first(soap_header->header_blocks, env); hash_index; hash_index + = axutil_hash_next(env, hash_index)) + { + axutil_hash_this(hash_index, NULL, NULL, &hb); + if(hb) + { + header_block = (axiom_soap_header_block_t *)hb; + + header_block_om_node = axiom_soap_header_block_get_base_node(header_block, env); + if(header_block_om_node) + { + header_block_om_ele = (axiom_element_t *)axiom_node_get_data_element( + header_block_om_node, env); + if(header_block_om_ele) + { + ns + = axiom_element_get_namespace(header_block_om_ele, env, + header_block_om_node); + if(ns) + { + hb_namespace_uri = axiom_namespace_get_uri(ns, env); + if(axutil_strcmp(hb_namespace_uri, ns_uri) == 0) + { + axutil_array_list_add(header_block_list, env, header_block); + found++; + } + } + } + } + hb = NULL; + header_block = NULL; + header_block_om_ele = NULL; + header_block_om_node = NULL; + ns = NULL; + hb_namespace_uri = NULL; + } + } + if(found > 0) + { + return header_block_list; + } + else + { + axutil_array_list_free(header_block_list, env); + } + return NULL; +} + +AXIS2_EXTERN axutil_hash_t *AXIS2_CALL +axiom_soap_header_get_all_header_blocks( + axiom_soap_header_t * soap_header, + const axutil_env_t * env) +{ + return soap_header->header_blocks; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_remove_header_block( + axiom_soap_header_t * soap_header, + const axutil_env_t * env, + axutil_qname_t * qname) +{ + axis2_char_t *qn_localname = NULL; + axis2_char_t *qname_ns = NULL; + axis2_char_t *qname_prefix = NULL; + axutil_hash_index_t *hi = NULL; + + AXIS2_PARAM_CHECK(env->error, qname, AXIS2_FAILURE); + + qn_localname = axutil_qname_get_localpart(qname, env); + qname_ns = axutil_qname_get_uri(qname, env); + qname_prefix = axutil_qname_get_prefix(qname, env); + + if(!soap_header->header_blocks) + { + return AXIS2_FAILURE; + } + for(hi = axutil_hash_first(soap_header->header_blocks, env); hi; hi = axutil_hash_next(env, hi)) + { + const void *key = NULL; + void *val = NULL; + + axutil_hash_this(hi, &key, NULL, &val); + if(val) + { + axiom_soap_header_block_t *header_block = NULL; + axiom_element_t *ele = NULL; + axiom_node_t *node = NULL; + + header_block = (axiom_soap_header_block_t *)val; + node = axiom_soap_header_block_get_base_node(header_block, env); + if(node) + { + axutil_qname_t *element_qname = NULL; + + ele = (axiom_element_t *)axiom_node_get_data_element(node, env); + element_qname = axiom_element_get_qname(ele, env, node); + if(axiom_soap_header_qname_matches(env, element_qname, qname) == AXIS2_TRUE) + { + axiom_node_detach(node, env); + /* axiom_node_free_tree(node, env); */ + axutil_hash_set(soap_header->header_blocks, key, AXIS2_HASH_KEY_STRING, NULL); + axiom_soap_header_block_free(header_block, env); + axiom_node_free_tree(node, env); + break; + } + } + } + } + + if(hi) + { + AXIS2_FREE(env->allocator, hi); + } + + return AXIS2_SUCCESS; +} + +static axis2_bool_t AXIS2_CALL +axiom_soap_header_qname_matches( + const axutil_env_t * env, + axutil_qname_t * element_qname, + axutil_qname_t * qname_to_match) +{ + int lparts_match = 0; + int uris_match = 0; + axis2_char_t *ele_lpart = NULL; + axis2_char_t *match_lpart = NULL; + axis2_char_t *ele_nsuri = NULL; + axis2_char_t *match_nsuri = NULL; + + if(!(qname_to_match)) + { + return AXIS2_TRUE; + } + if(qname_to_match) + { + match_lpart = axutil_qname_get_localpart(qname_to_match, env); + match_nsuri = axutil_qname_get_uri(qname_to_match, env); + } + if(element_qname) + { + ele_lpart = axutil_qname_get_localpart(element_qname, env); + ele_nsuri = axutil_qname_get_uri(element_qname, env); + } + + lparts_match = (!match_lpart || (axutil_strcmp(match_lpart, "") == 0) || (element_qname + && (axutil_strcmp(ele_lpart, match_lpart) == 0))); + + uris_match = (!match_nsuri || (axutil_strcmp(match_nsuri, "") == 0) || (element_qname + && (axutil_strcmp(ele_nsuri, match_nsuri) == 0))); + + return lparts_match && uris_match; +} diff --git a/axiom/src/soap/soap_header_block.c b/axiom/src/soap/soap_header_block.c new file mode 100644 index 0000000..6f80f3a --- /dev/null +++ b/axiom/src/soap/soap_header_block.c @@ -0,0 +1,460 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "_axiom_soap_header_block.h" +#include "_axiom_soap_header.h" +#include +#include + +struct axiom_soap_header_block +{ + + /** om_element node corresponding to this headerblock */ + axiom_node_t *om_ele_node; + + /** soap version */ + int soap_version; + axis2_bool_t processed; +}; + +AXIS2_EXTERN axiom_soap_header_block_t *AXIS2_CALL +axiom_soap_header_block_create( + const axutil_env_t * env) +{ + axiom_soap_header_block_t *header_block = NULL; + AXIS2_ENV_CHECK(env, NULL); + header_block = (axiom_soap_header_block_t *)AXIS2_MALLOC(env->allocator, + sizeof(axiom_soap_header_block_t)); + if(!header_block) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create SOAP header block"); + return NULL; + } + + header_block->om_ele_node = NULL; + header_block->soap_version = AXIOM_SOAP_VERSION_NOT_SET; + header_block->processed = AXIS2_FALSE; + + return header_block; +} + +AXIS2_EXTERN axiom_soap_header_block_t *AXIS2_CALL +axiom_soap_header_block_create_with_parent( + const axutil_env_t * env, + const axis2_char_t * localname, + axiom_namespace_t * ns, + axiom_soap_header_t * header) +{ + axiom_soap_header_block_t *header_block = NULL; + axiom_node_t *this_node = NULL; + axiom_node_t *parent_node = NULL; + axiom_element_t *om_ele = NULL; + AXIS2_PARAM_CHECK(env->error, localname, NULL); + + header_block = axiom_soap_header_block_create(env); + if(!header_block) + { + return NULL; + } + parent_node = axiom_soap_header_get_base_node(header, env); + if(!parent_node) + { + return NULL; + } + om_ele = axiom_element_create(env, parent_node, localname, ns, &this_node); + if(!om_ele) + { + axiom_soap_header_block_free(header_block, env); + return NULL; + } + header_block->om_ele_node = this_node; + + axiom_soap_header_set_header_block(header, env, header_block); + + header_block->soap_version = axiom_soap_header_get_soap_version(header, env); + + return header_block; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_soap_header_block_free( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env) +{ + AXIS2_FREE(env->allocator, header_block); + return; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_block_set_role( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + axis2_char_t * role_uri) +{ + const axis2_char_t *attr_localname = NULL; + const axis2_char_t *attr_nsuri = NULL; + + if(header_block->soap_version == AXIOM_SOAP_VERSION_NOT_SET) + { + return AXIS2_FAILURE; + } + if(header_block->soap_version == AXIOM_SOAP11) + { + attr_localname = AXIOM_SOAP11_ATTR_ACTOR; + attr_nsuri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; + } + if(header_block->soap_version == AXIOM_SOAP12) + { + attr_localname = AXIOM_SOAP12_SOAP_ROLE; + attr_nsuri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; + } + axiom_soap_header_block_set_attribute(header_block, env, attr_localname, role_uri, attr_nsuri); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL axiom_soap_header_block_get_role( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env) +{ + const axis2_char_t *attr_localname = NULL; + const axis2_char_t *attr_nsuri = NULL; + + if (header_block->soap_version == AXIOM_SOAP_VERSION_NOT_SET) + { + return NULL; + } + if (header_block->soap_version == AXIOM_SOAP11) + { + attr_localname = AXIOM_SOAP11_ATTR_ACTOR; + attr_nsuri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; + } + if (header_block->soap_version == AXIOM_SOAP12) + { + attr_localname = AXIOM_SOAP12_SOAP_ROLE; + attr_nsuri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; + } + return axiom_soap_header_block_get_attribute(header_block, env, + attr_localname, attr_nsuri); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_block_set_must_understand_with_bool( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + axis2_bool_t must_understand) +{ + const axis2_char_t *attr_nsuri = NULL; + const axis2_char_t *attr_value = NULL; + + if(header_block->soap_version == AXIOM_SOAP_VERSION_NOT_SET) + { + return AXIS2_FAILURE; + } + if(header_block->soap_version == AXIOM_SOAP11) + { + attr_nsuri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; + } + if(header_block->soap_version == AXIOM_SOAP12) + { + attr_nsuri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; + } + if(must_understand) + { + attr_value = "1"; + } + else + { + attr_value = "0"; + } + return axiom_soap_header_block_set_attribute(header_block, env, + AXIOM_SOAP_ATTR_MUST_UNDERSTAND, attr_value, attr_nsuri); + +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_block_set_must_understand_with_string( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + axis2_char_t * must_understand) +{ + const axis2_char_t *attr_nsuri = NULL; + + AXIS2_PARAM_CHECK(env->error, must_understand, AXIS2_FAILURE); + + if(header_block->soap_version == AXIOM_SOAP_VERSION_NOT_SET) + { + return AXIS2_FAILURE; + } + if(header_block->soap_version == AXIOM_SOAP11) + { + attr_nsuri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; + } + if(header_block->soap_version == AXIOM_SOAP12) + { + attr_nsuri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; + } + + if(axutil_strcmp(AXIOM_SOAP_ATTR_MUST_UNDERSTAND_TRUE, must_understand) == 0 || axutil_strcmp( + AXIOM_SOAP_ATTR_MUST_UNDERSTAND_FALSE, must_understand) == 0 || axutil_strcmp( + AXIOM_SOAP_ATTR_MUST_UNDERSTAND_0, must_understand) == 0 || axutil_strcmp( + AXIOM_SOAP_ATTR_MUST_UNDERSTAND_1, must_understand) == 0) + { + + axiom_soap_header_block_set_attribute(header_block, env, AXIOM_SOAP_ATTR_MUST_UNDERSTAND, + must_understand, attr_nsuri); + return AXIS2_SUCCESS; + } + else + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_MUST_UNDERSTAND_SHOULD_BE_1_0_TRUE_FALSE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_soap_header_block_get_must_understand( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env) +{ + const axis2_char_t *must_understand = NULL; + const axis2_char_t *attr_nsuri = NULL; + + if(header_block->soap_version == AXIOM_SOAP_VERSION_NOT_SET) + { + return AXIS2_FAILURE; + } + if(header_block->soap_version == AXIOM_SOAP11) + { + attr_nsuri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; + } + if(header_block->soap_version == AXIOM_SOAP12) + { + attr_nsuri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; + } + must_understand = axiom_soap_header_block_get_attribute(header_block, env, + AXIOM_SOAP_ATTR_MUST_UNDERSTAND, attr_nsuri); + if(!must_understand) + { + return AXIS2_FALSE; + } + if(axutil_strcmp(must_understand, AXIOM_SOAP_ATTR_MUST_UNDERSTAND_1) == 0 || axutil_strcmp( + must_understand, AXIOM_SOAP_ATTR_MUST_UNDERSTAND_TRUE) == 0) + { + return AXIS2_TRUE; + } + else if(axutil_strcmp(must_understand, AXIOM_SOAP_ATTR_MUST_UNDERSTAND_0) == 0 + || axutil_strcmp(must_understand, AXIOM_SOAP_ATTR_MUST_UNDERSTAND_FALSE) == 0) + { + return AXIS2_FALSE; + } + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_VALUE_FOUND_IN_MUST_UNDERSTAND, AXIS2_FAILURE); + return AXIS2_FALSE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_block_set_attribute( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + const axis2_char_t * attr_name, + const axis2_char_t * attr_value, + const axis2_char_t * soap_envelope_namespace_uri) +{ + axiom_attribute_t *om_attr = NULL; + axiom_node_t *header_node = NULL; + axiom_element_t *header_ele = NULL; + axiom_namespace_t *header_ns = NULL; + axis2_char_t *prefix = NULL; + axutil_qname_t *qn = NULL; + axiom_namespace_t *om_ns = NULL; + axiom_element_t *om_ele = NULL; + + AXIS2_PARAM_CHECK(env->error, attr_name, AXIS2_FAILURE); + + header_node = axiom_node_get_parent(header_block->om_ele_node, env); + if(!header_node) + { + return AXIS2_FAILURE; + } + if(axiom_node_get_node_type(header_node, env) == AXIOM_ELEMENT) + { + header_ele = (axiom_element_t *)axiom_node_get_data_element(header_node, env); + if(!header_ele) + { + return AXIS2_FAILURE; + } + header_ns = axiom_element_get_namespace(header_ele, env, header_node); + if(!header_ns) + { + return AXIS2_FAILURE; + } + prefix = axiom_namespace_get_prefix(header_ns, env); + } + + qn = axutil_qname_create(env, attr_name, soap_envelope_namespace_uri, prefix); + + if(!qn) + { + return AXIS2_FAILURE; + } + if(!header_block->om_ele_node) + { + return AXIS2_FAILURE; + } + om_ele = (axiom_element_t *)axiom_node_get_data_element(header_block-> om_ele_node, env); + + om_attr = axiom_element_get_attribute(om_ele, env, qn); + + axutil_qname_free(qn, env); + if(om_attr) + { + return axiom_attribute_set_value(om_attr, env, attr_value); + } + if(soap_envelope_namespace_uri) + { + if(prefix) + { + om_ns = axiom_namespace_create(env, soap_envelope_namespace_uri, prefix); + } + else + { + om_ns = axiom_namespace_create(env, soap_envelope_namespace_uri, + AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX); + } + } + om_attr = axiom_attribute_create(env, attr_name, attr_value, om_ns); + if(!om_attr && om_ns) + { + axiom_namespace_free(om_ns, env); + return AXIS2_FAILURE; + } + + return axiom_element_add_attribute(om_ele, env, om_attr, header_block->om_ele_node); +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_soap_header_block_get_attribute( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + const axis2_char_t * attr_name, + const axis2_char_t * soap_envelope_namespace_uri) +{ + axiom_attribute_t *om_attr = NULL; + axis2_char_t *attr_value = NULL; + axiom_node_t *header_node = NULL; + axiom_element_t *header_ele = NULL; + axiom_namespace_t *header_ns = NULL; + axis2_char_t *prefix = NULL; + axutil_qname_t *qn = NULL; + axiom_element_t *om_ele = NULL; + AXIS2_PARAM_CHECK(env->error, attr_name, NULL); + AXIS2_PARAM_CHECK(env->error, soap_envelope_namespace_uri, NULL); + + header_node = axiom_node_get_parent(header_block->om_ele_node, env); + if(!header_node) + { + return NULL; + } + if(axiom_node_get_node_type(header_node, env) == AXIOM_ELEMENT) + { + header_ele = (axiom_element_t *)axiom_node_get_data_element(header_node, env); + if(!header_ele) + { + return NULL; + } + header_ns = axiom_element_get_namespace(header_ele, env, header_node); + if(!header_ns) + { + return NULL; + } + prefix = axiom_namespace_get_prefix(header_ns, env); + } + qn = axutil_qname_create(env, attr_name, soap_envelope_namespace_uri, prefix); + if(!qn) + { + return NULL; + } + om_ele = (axiom_element_t *)axiom_node_get_data_element(header_block-> om_ele_node, env); + om_attr = axiom_element_get_attribute(om_ele, env, qn); + if(om_attr) + { + attr_value = axiom_attribute_get_value(om_attr, env); + } + axutil_qname_free(qn, env); + return attr_value; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_soap_header_block_is_processed( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env) +{ + return header_block->processed; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_block_set_processed( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env) +{ + header_block->processed = AXIS2_TRUE; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_block_set_base_node( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + axiom_node_t * node) +{ + AXIS2_PARAM_CHECK(env->error, node, AXIS2_FAILURE); + + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_INVALID_BASE_TYPE, AXIS2_FAILURE); + return AXIS2_FAILURE; + } + header_block->om_ele_node = node; + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL axiom_soap_header_block_get_base_node( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env) +{ + return header_block->om_ele_node; +} + +AXIS2_EXTERN int AXIS2_CALL axiom_soap_header_block_get_soap_version( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env) +{ + return header_block->soap_version; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axiom_soap_header_block_set_soap_version( + axiom_soap_header_block_t * header_block, + const axutil_env_t * env, + int soap_version) +{ + + header_block->soap_version = soap_version; + return AXIS2_SUCCESS; +} diff --git a/axiom/src/util/Makefile.am b/axiom/src/util/Makefile.am new file mode 100644 index 0000000..ea76b68 --- /dev/null +++ b/axiom/src/util/Makefile.am @@ -0,0 +1,8 @@ +noinst_LTLIBRARIES = libaxis2_axiom_util.la +libaxis2_axiom_util_la_SOURCES = om_util.c + +libaxis2_axiom_util_la_LIBADD = +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/src/parser \ + -I$(top_builddir)/src/om \ + -I ../../../util/include diff --git a/axiom/src/util/om_util.c b/axiom/src/util/om_util.c new file mode 100644 index 0000000..fcdd90b --- /dev/null +++ b/axiom/src/util/om_util.c @@ -0,0 +1,1181 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include + + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_util_get_child_text( + axiom_node_t *node, + const axutil_env_t * env) +{ + axiom_element_t *ele = NULL; + axis2_char_t *txt = NULL; + + ele = (axiom_element_t*)axiom_node_get_data_element(node, env); + txt = axiom_element_get_text(ele, env, node); + + return txt; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_first_child_element_with_uri( + axiom_node_t * ele_node, + const axutil_env_t * env, + axis2_char_t * uri, + axiom_node_t ** child) +{ + axiom_node_t *child_node = NULL; + + if(!ele_node || !uri) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Element node or uri is NULL"); + return NULL; + } + + child_node = axiom_node_get_first_child(ele_node, env); + while(child_node) + { + if(axiom_node_get_node_type(child_node, env) == AXIOM_ELEMENT) + { + axiom_element_t *child_ele = NULL; + axiom_namespace_t *ns = NULL; + + child_ele = (axiom_element_t *)axiom_node_get_data_element(child_node, env); + ns = axiom_element_get_namespace(child_ele, env, child_node); + if(ns) + { + axis2_char_t *child_uri = NULL; + child_uri = axiom_namespace_get_uri(ns, env); + if(child_uri && axutil_strcmp(child_uri, uri) == 0) + { + (*child) = child_node; + return child_ele; + } + } + } + child_node = axiom_node_get_next_sibling(child_node, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_next_sibling_element_with_uri( + axiom_node_t * ele_node, + const axutil_env_t * env, + axis2_char_t * uri, + axiom_node_t ** next_node) +{ + axiom_node_t *next_sib_node = NULL; + if(!ele_node || !uri) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Element node or uri is NULL"); + return NULL; + } + + next_sib_node = axiom_node_get_next_sibling(ele_node, env); + while(next_sib_node) + { + if(axiom_node_get_node_type(next_sib_node, env) == AXIOM_ELEMENT) + { + axiom_element_t *sib_ele = NULL; + axiom_namespace_t *ns = NULL; + + sib_ele = (axiom_element_t *)axiom_node_get_data_element(next_sib_node, env); + ns = axiom_element_get_namespace(sib_ele, env, next_sib_node); + if(ns) + { + axis2_char_t *sib_uri = NULL; + sib_uri = axiom_namespace_get_uri(ns, env); + if(sib_uri && axutil_strcmp(sib_uri, uri) == 0) + { + (*next_node) = next_sib_node; + return sib_ele; + } + } + } + next_sib_node = axiom_node_get_next_sibling(next_sib_node, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_first_child_element( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axiom_node_t ** child_node) +{ + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + AXIS2_PARAM_CHECK(env->error, child_node, NULL); + + return axiom_element_get_first_element(ele, env, ele_node, child_node); +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_last_child_element( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axiom_node_t ** child_node) +{ + axiom_node_t *last_node = NULL; + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + AXIS2_PARAM_CHECK(env->error, child_node, NULL); + + last_node = axiom_node_get_last_child(ele_node, env); + while(last_node) + { + if(axiom_node_get_node_type(last_node, env) == AXIOM_ELEMENT) + { + *child_node = last_node; + return (axiom_element_t *)axiom_node_get_data_element(last_node, env); + + } + last_node = axiom_node_get_previous_sibling(ele_node, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_next_sibling_element( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axiom_node_t ** next_node) +{ + axiom_node_t *next_sibling = NULL; + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + + next_sibling = axiom_node_get_next_sibling(ele_node, env); + while(next_sibling) + { + if(axiom_node_get_node_type(next_sibling, env) == AXIOM_ELEMENT) + { + *next_node = next_sibling; + return (axiom_element_t *)axiom_node_get_data_element(next_sibling, env); + } + next_sibling = axiom_node_get_next_sibling(next_sibling, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_first_child_element_with_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axiom_node_t ** child_node) +{ + axiom_node_t *child = NULL; + axiom_node_t *next_sibling = NULL; + axis2_char_t *child_localname = NULL; + axiom_element_t *om_ele = NULL; + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + AXIS2_PARAM_CHECK(env->error, child_node, NULL); + AXIS2_PARAM_CHECK(env->error, localname, NULL); + + child = axiom_node_get_first_child(ele_node, env); + if(child) + { + if(axiom_node_get_node_type(child, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(child, env); + if(om_ele) + { + child_localname = axiom_element_get_localname(om_ele, env); + if(child_localname && axutil_strcmp(child_localname, localname) == 0) + { + *child_node = child; + return om_ele; + } + } + } + om_ele = NULL; + child_localname = NULL; + } + + next_sibling = axiom_node_get_next_sibling(child, env); + while(next_sibling) + { + if(axiom_node_get_node_type(next_sibling, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(next_sibling, env); + if(om_ele) + { + child_localname = axiom_element_get_localname(om_ele, env); + if(child_localname && axutil_strcmp(child_localname, localname) == 0) + { + *child_node = next_sibling; + return om_ele; + } + + } + om_ele = NULL; + child_localname = NULL; + } + next_sibling = axiom_node_get_next_sibling(next_sibling, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_last_child_element_with_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axiom_node_t ** child_node) +{ + axiom_node_t *child = NULL; + axiom_element_t *om_ele = NULL; + axis2_char_t *child_localname = NULL; + + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + AXIS2_PARAM_CHECK(env->error, localname, NULL); + AXIS2_PARAM_CHECK(env->error, child_node, NULL); + + child = axiom_node_get_last_child(ele_node, env); + while(child) + { + if(axiom_node_get_node_type(child, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(ele_node, env); + if(om_ele) + { + child_localname = axiom_element_get_localname(om_ele, env); + if(child_localname && axutil_strcmp(child_localname, localname) == 0) + { + *child_node = child; + return om_ele; + } + + } + om_ele = NULL; + child_localname = NULL; + } + child = axiom_node_get_previous_sibling(child, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_next_siblng_element_with_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axiom_node_t ** next_node) +{ + axiom_node_t *next_sibling = NULL; + axiom_element_t *om_ele = NULL; + axis2_char_t *ele_localname = NULL; + + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + + next_sibling = axiom_node_get_next_sibling(ele_node, env); + while(next_sibling) + { + if(axiom_node_get_node_type(next_sibling, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(next_sibling, env); + if(om_ele) + { + ele_localname = axiom_element_get_localname(om_ele, env); + if(ele_localname && axutil_strcmp(localname, ele_localname) == 0) + { + *next_node = next_sibling; + return om_ele; + } + } + om_ele = NULL; + ele_localname = NULL; + } + next_sibling = axiom_node_get_next_sibling(next_sibling, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_first_child_element_with_uri_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * uri, + axiom_node_t ** child_node) +{ + axiom_node_t *child = NULL; + axiom_node_t *next_sibling = NULL; + axis2_char_t *child_localname = NULL; + axiom_element_t *om_ele = NULL; + axiom_namespace_t *ns = NULL; + axis2_char_t *ns_uri = NULL; + + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + AXIS2_PARAM_CHECK(env->error, child_node, NULL); + AXIS2_PARAM_CHECK(env->error, localname, NULL); + AXIS2_PARAM_CHECK(env->error, uri, NULL); + + child = axiom_node_get_first_child(ele_node, env); + if(!child) + { + return NULL; + + } + if(axiom_node_get_node_type(ele_node, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(child, env); + if(om_ele) + { + child_localname = axiom_element_get_localname(om_ele, env); + ns = axiom_element_get_namespace(om_ele, env, child); + if(ns) + { + ns_uri = axiom_namespace_get_uri(ns, env); + } + + if((child_localname) && (axutil_strcmp(child_localname, localname) == 0) && (ns_uri) + && (axutil_strcmp(ns_uri, uri) == 0)) + { + *child_node = child; + return om_ele; + } + } + } + om_ele = NULL; + child_localname = NULL; + ns = NULL; + ns_uri = NULL; + + next_sibling = axiom_node_get_next_sibling(child, env); + while(next_sibling) + { + if(axiom_node_get_node_type(next_sibling, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(next_sibling, env); + if(om_ele) + { + child_localname = axiom_element_get_localname(om_ele, env); + ns = axiom_element_get_namespace(om_ele, env, next_sibling); + if(ns) + { + ns_uri = axiom_namespace_get_uri(ns, env); + } + + if((child_localname) && (axutil_strcmp(child_localname, localname) == 0) + && (ns_uri) && (axutil_strcmp(ns_uri, uri) == 0)) + { + *child_node = next_sibling; + return om_ele; + } + + } + om_ele = NULL; + child_localname = NULL; + ns = NULL; + ns_uri = NULL; + } + next_sibling = axiom_node_get_next_sibling(next_sibling, env); + } + return NULL; +} +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_last_child_element_with_uri_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * uri, + axiom_node_t ** child_node) +{ + axiom_node_t *child = NULL; + axiom_element_t *om_ele = NULL; + axis2_char_t *child_localname = NULL; + axiom_namespace_t *ns = NULL; + axis2_char_t *ns_uri = NULL; + + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + AXIS2_PARAM_CHECK(env->error, localname, NULL); + AXIS2_PARAM_CHECK(env->error, child_node, NULL); + AXIS2_PARAM_CHECK(env->error, uri, NULL); + + child = axiom_node_get_last_child(ele_node, env); + while(child) + { + if(axiom_node_get_node_type(child, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(ele_node, env); + if(om_ele) + { + ns = axiom_element_get_namespace(om_ele, env, ele_node); + if(ns) + { + ns_uri = axiom_namespace_get_uri(ns, env); + } + child_localname = axiom_element_get_localname(om_ele, env); + if(child_localname && (axutil_strcmp(child_localname, localname) == 0) && (ns_uri) + && (axutil_strcmp(ns_uri, uri) == 0)) + { + *child_node = child; + return om_ele; + } + } + om_ele = NULL; + child_localname = NULL; + ns = NULL; + ns_uri = NULL; + } + child = axiom_node_get_previous_sibling(child, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_next_sibling_element_with_uri_localname( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * uri, + axiom_node_t ** next_node) +{ + axiom_node_t *next_sibling = NULL; + axiom_element_t *om_ele = NULL; + axis2_char_t *ele_localname = NULL; + axiom_namespace_t *ns = NULL; + axis2_char_t *ns_uri = NULL; + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + + next_sibling = axiom_node_get_next_sibling(ele_node, env); + while(next_sibling) + { + if(axiom_node_get_node_type(next_sibling, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(next_sibling, env); + if(om_ele) + { + ns = axiom_element_get_namespace(om_ele, env, next_sibling); + if(ns) + { + ns_uri = axiom_namespace_get_uri(ns, env); + } + ele_localname = axiom_element_get_localname(om_ele, env); + if(ele_localname && (axutil_strcmp(localname, ele_localname) == 0) && (ns) + && (axutil_strcmp(ns_uri, uri) == 0)) + { + *next_node = next_sibling; + return om_ele; + } + } + om_ele = NULL; + ele_localname = NULL; + ns_uri = NULL; + ns = NULL; + } + next_sibling = axiom_node_get_next_sibling(next_sibling, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_first_child_element_with_localnames( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axutil_array_list_t * names, + axiom_node_t ** child_node) +{ + axiom_node_t *child = NULL; + axiom_node_t *next_sibling = NULL; + axis2_char_t *child_localname = NULL; + axis2_char_t *given_localname = NULL; + axiom_element_t *om_ele = NULL; + int size = 0; + int i = 0; + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + AXIS2_PARAM_CHECK(env->error, child_node, NULL); + AXIS2_PARAM_CHECK(env->error, names, NULL); + + child = axiom_node_get_first_child(ele_node, env); + if(child) + { + if(axiom_node_get_node_type(child, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(child, env); + if(om_ele) + { + size = axutil_array_list_size(names, env); + child_localname = axiom_element_get_localname(om_ele, env); + + for(i = 0; i < size; i++) + { + given_localname = (axis2_char_t *)axutil_array_list_get(names, env, i); + + if((child_localname) && (NULL != given_localname) && axutil_strcmp( + child_localname, given_localname) == 0) + { + *child_node = child; + return om_ele; + } + given_localname = NULL; + } + } + } + om_ele = NULL; + child_localname = NULL; + given_localname = NULL; + size = 0; + } + + next_sibling = axiom_node_get_next_sibling(child, env); + while(next_sibling) + { + if(axiom_node_get_node_type(next_sibling, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(next_sibling, env); + if(om_ele) + { + size = axutil_array_list_size(names, env); + child_localname = axiom_element_get_localname(om_ele, env); + for(i = 0; i < size; i++) + { + given_localname = (axis2_char_t *)axutil_array_list_get(names, env, i); + if((child_localname) && (NULL != given_localname) && (axutil_strcmp( + child_localname, given_localname) == 0)) + { + *child_node = next_sibling; + return om_ele; + } + given_localname = NULL; + } + } + om_ele = NULL; + child_localname = NULL; + given_localname = NULL; + } + next_sibling = axiom_node_get_next_sibling(next_sibling, env); + } + return NULL; + +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_last_child_element_with_localnames( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axutil_array_list_t * names, + axiom_node_t ** child_node) +{ + axiom_node_t *child = NULL; + axiom_element_t *om_ele = NULL; + axis2_char_t *child_localname = NULL; + axis2_char_t *given_localname = NULL; + int size = 0; + int i = 0; + + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + AXIS2_PARAM_CHECK(env->error, names, NULL); + AXIS2_PARAM_CHECK(env->error, child_node, NULL); + + child = axiom_node_get_last_child(ele_node, env); + while(child) + { + if(axiom_node_get_node_type(child, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(ele_node, env); + if(om_ele) + { + size = axutil_array_list_size(names, env); + for(i = 0; i < size; i++) + { + given_localname = (axis2_char_t *)axutil_array_list_get(names, env, i); + child_localname = axiom_element_get_localname(om_ele, env); + if(child_localname && (NULL != given_localname) && (axutil_strcmp( + child_localname, given_localname) == 0)) + { + *child_node = child; + return om_ele; + } + } + } + om_ele = NULL; + child_localname = NULL; + given_localname = NULL; + } + child = axiom_node_get_previous_sibling(child, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_next_siblng_element_with_localnames( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axutil_array_list_t * names, + axiom_node_t ** next_node) +{ + axiom_node_t *next_sibling = NULL; + axiom_element_t *om_ele = NULL; + axis2_char_t *ele_localname = NULL; + axis2_char_t *given_localname = NULL; + int size = 0; + int i = 0; + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + AXIS2_PARAM_CHECK(env->error, names, NULL); + AXIS2_PARAM_CHECK(env->error, next_node, NULL); + + next_sibling = axiom_node_get_next_sibling(ele_node, env); + while(next_sibling) + { + if(axiom_node_get_node_type(next_sibling, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(next_sibling, env); + if(om_ele) + { + size = axutil_array_list_size(names, env); + for(i = 0; i < size; i++) + { + given_localname = (axis2_char_t *)axutil_array_list_get(names, env, i); + ele_localname = axiom_element_get_localname(om_ele, env); + if((ele_localname) && (NULL != given_localname) && (axutil_strcmp( + given_localname, ele_localname) == 0)) + { + *next_node = next_sibling; + return om_ele; + } + + } + } + om_ele = NULL; + ele_localname = NULL; + } + next_sibling = axiom_node_get_next_sibling(next_sibling, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_first_child_element_with_localname_attr( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * attr_name, + axis2_char_t * attr_value, + axiom_node_t ** child_node) +{ + axiom_node_t *child = NULL; + axiom_node_t *next_sibling = NULL; + axis2_char_t *child_localname = NULL; + axiom_element_t *om_ele = NULL; + axiom_attribute_t *om_attr = NULL; + axutil_hash_t *attr_ht = NULL; + axutil_hash_index_t *hi = NULL; + axis2_char_t *om_attr_value = NULL; + axis2_char_t *om_attr_name = NULL; + + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + AXIS2_PARAM_CHECK(env->error, child_node, NULL); + AXIS2_PARAM_CHECK(env->error, localname, NULL); + AXIS2_PARAM_CHECK(env->error, attr_name, NULL); + AXIS2_PARAM_CHECK(env->error, attr_value, NULL); + + child = axiom_node_get_first_child(ele_node, env); + + if(child) + { + if(axiom_node_get_node_type(child, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(child, env); + if(om_ele) + { + + child_localname = axiom_element_get_localname(om_ele, env); + if(child_localname && axutil_strcmp(child_localname, localname) == 0) + { + attr_ht = axiom_element_get_all_attributes(om_ele, env); + if(attr_ht) + { + for(hi = axutil_hash_first(attr_ht, env); hi; hi + = axutil_hash_next(env, hi)) + { + void *val = NULL; + axutil_hash_this(hi, NULL, NULL, &val); + if(val) + { + om_attr = (axiom_attribute_t *)val; + om_attr_name = axiom_attribute_get_localname(om_attr, env); + + om_attr_value = axiom_attribute_get_value(om_attr, env); + if(om_attr_name && NULL != om_attr_value && axutil_strcmp( + om_attr_name, attr_name) == 0 && axutil_strcmp(om_attr_value, + attr_value) == 0) + { + AXIS2_FREE(env->allocator, hi); + *child_node = child; + return om_ele; + } + om_attr = NULL; + om_attr_name = NULL; + om_attr_value = NULL; + } + } + } + } + } + } + om_ele = NULL; + child_localname = NULL; + hi = NULL; + } + + next_sibling = axiom_node_get_next_sibling(child, env); + while(next_sibling) + { + if(axiom_node_get_node_type(next_sibling, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(next_sibling, env); + if(om_ele) + { + child_localname = axiom_element_get_localname(om_ele, env); + if(child_localname && axutil_strcmp(child_localname, localname) == 0) + { + attr_ht = axiom_element_get_all_attributes(om_ele, env); + if(attr_ht) + { + + for(hi = axutil_hash_first(attr_ht, env); hi; hi + = axutil_hash_next(env, hi)) + { + void *val = NULL; + axutil_hash_this(hi, NULL, NULL, &val); + if(val) + { + om_attr = (axiom_attribute_t *)val; + om_attr_name = axiom_attribute_get_localname(om_attr, env); + + om_attr_value = axiom_attribute_get_value(om_attr, env); + + if(om_attr_name && NULL != om_attr_value && axutil_strcmp( + om_attr_name, attr_name) == 0 && axutil_strcmp(om_attr_value, + attr_value) == 0) + { + *child_node = child; + return om_ele; + } + om_attr = NULL; + om_attr_name = NULL; + om_attr_value = NULL; + } + } + } + } + + } + om_ele = NULL; + child_localname = NULL; + } + next_sibling = axiom_node_get_next_sibling(next_sibling, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_last_child_element_with_localname_attr( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * attr_name, + axis2_char_t * attr_value, + axiom_node_t ** child_node) +{ + axiom_node_t *child = NULL; + axiom_element_t *om_ele = NULL; + axis2_char_t *child_localname = NULL; + axiom_attribute_t *om_attr = NULL; + axis2_char_t *om_attr_name = NULL; + axis2_char_t *om_attr_value = NULL; + axutil_hash_index_t *hi = NULL; + axutil_hash_t *attr_ht = NULL; + + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + AXIS2_PARAM_CHECK(env->error, localname, NULL); + AXIS2_PARAM_CHECK(env->error, child_node, NULL); + + child = axiom_node_get_last_child(ele_node, env); + while(child) + { + if(axiom_node_get_node_type(child, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(ele_node, env); + if(om_ele) + { + child_localname = axiom_element_get_localname(om_ele, env); + if(child_localname && axutil_strcmp(child_localname, localname) == 0) + { + attr_ht = axiom_element_get_all_attributes(om_ele, env); + if(attr_ht) + { + for(hi = axutil_hash_first(attr_ht, env); hi; hi + = axutil_hash_next(env, hi)) + { + void *val = NULL; + axutil_hash_this(hi, NULL, NULL, &val); + if(val) + { + om_attr = (axiom_attribute_t *)val; + om_attr_name = axiom_attribute_get_localname(om_attr, env); + + om_attr_value = axiom_attribute_get_value(om_attr, env); + + if(om_attr_name && NULL != om_attr_value && axutil_strcmp( + om_attr_name, attr_name) == 0 && axutil_strcmp(om_attr_value, + attr_value) == 0) + { + AXIS2_FREE(env->allocator, hi); + *child_node = child; + return om_ele; + } + om_attr = NULL; + om_attr_name = NULL; + om_attr_value = NULL; + } + } + } + } + + } + om_ele = NULL; + child_localname = NULL; + } + child = axiom_node_get_previous_sibling(child, env); + } + return NULL; +} + +AXIS2_EXTERN axiom_element_t *AXIS2_CALL +axiom_util_get_next_siblng_element_with_localname_attr( + axiom_element_t * ele, + const axutil_env_t * env, + axiom_node_t * ele_node, + axis2_char_t * localname, + axis2_char_t * attr_name, + axis2_char_t * attr_value, + axiom_node_t ** child_node) +{ + axiom_node_t *next_sibling = NULL; + axiom_element_t *om_ele = NULL; + axis2_char_t *ele_localname = NULL; + axiom_attribute_t *om_attr = NULL; + axis2_char_t *om_attr_value = NULL; + axis2_char_t *om_attr_name = NULL; + axutil_hash_t *attr_ht = NULL; + axutil_hash_index_t *hi = NULL; + + AXIS2_PARAM_CHECK(env->error, ele_node, NULL); + + next_sibling = axiom_node_get_next_sibling(ele_node, env); + while(next_sibling) + { + if(axiom_node_get_node_type(next_sibling, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *)axiom_node_get_data_element(next_sibling, env); + if(om_ele) + { + ele_localname = axiom_element_get_localname(om_ele, env); + if(ele_localname && axutil_strcmp(localname, ele_localname) == 0) + { + attr_ht = axiom_element_get_all_attributes(om_ele, env); + if(attr_ht) + { + for(hi = axutil_hash_first(attr_ht, env); hi; hi + = axutil_hash_next(env, hi)) + { + void *val = NULL; + axutil_hash_this(hi, NULL, NULL, &val); + if(val) + { + om_attr = (axiom_attribute_t *)val; + om_attr_name = axiom_attribute_get_localname(om_attr, env); + + om_attr_value = axiom_attribute_get_value(om_attr, env); + + if(om_attr_name && NULL != om_attr_value && axutil_strcmp( + om_attr_name, attr_name) == 0 && axutil_strcmp(om_attr_value, + attr_value) == 0) + { + AXIS2_FREE(env->allocator, hi); + *child_node = next_sibling; + return om_ele; + } + om_attr = NULL; + om_attr_name = NULL; + om_attr_value = NULL; + } + } + } + } + } + om_ele = NULL; + ele_localname = NULL; + } + next_sibling = axiom_node_get_next_sibling(next_sibling, env); + } + return NULL; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_util_get_child_node_text( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + axiom_element_t *om_ele = NULL; + if(!om_node) + { + return NULL; + } + if(axiom_node_get_node_type(om_node, env) != AXIOM_ELEMENT) + { + return NULL; + } + + om_ele = (axiom_element_t *)axiom_node_get_data_element(om_node, env); + + if(om_ele) + { + return axiom_element_get_text(om_ele, env, om_node); + } + return NULL; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_util_get_localname( + axiom_node_t * node, + const axutil_env_t * env) +{ + axiom_element_t *om_ele = NULL; + + AXIS2_ENV_CHECK(env, NULL); + if(!node) + { + return NULL; + } + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + return NULL; + } + om_ele = (axiom_element_t *)axiom_node_get_data_element(node, env); + if(om_ele) + { + return axiom_element_get_localname(om_ele, env); + } + return NULL; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +axiom_util_get_node_namespace_uri( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + axiom_element_t *om_ele = NULL; + axiom_namespace_t *om_ns = NULL; + if(!om_node) + { + return NULL; + } + if(axiom_node_get_node_type(om_node, env) == AXIOM_ELEMENT) + { + om_ele = axiom_node_get_data_element(om_node, env); + if(!om_ele) + { + return NULL; + } + om_ns = axiom_element_get_namespace(om_ele, env, om_node); + if(om_ns) + { + return axiom_namespace_get_uri(om_ns, env); + } + } + return NULL; +} + +AXIS2_EXTERN axiom_child_element_iterator_t *AXIS2_CALL +axiom_util_get_child_elements( + axiom_element_t * om_ele, + const axutil_env_t * env, + axiom_node_t * om_node) +{ + axiom_element_t *first_ele = NULL; + axiom_node_t *first_node = NULL; + AXIS2_PARAM_CHECK(env->error, om_node, NULL); + AXIS2_PARAM_CHECK(env->error, om_ele, NULL); + first_ele = axiom_element_get_first_element(om_ele, env, om_node, &first_node); + if(first_ele) + { + return axiom_child_element_iterator_create(env, first_node); + } + return NULL; +} + +AXIS2_EXTERN axiom_document_t *AXIS2_CALL +axiom_util_new_document( + const axutil_env_t * env, + const axutil_uri_t * uri) +{ + axis2_char_t *path = NULL; + axiom_xml_reader_t *reader = NULL; + axiom_stax_builder_t *om_builder = NULL; + axiom_document_t *doc = NULL; + + AXIS2_PARAM_CHECK(env->error, uri, NULL); + /* This is temporary code. Later complete the code to read from uri and build + * the document + */ + if(uri) + { + path = axutil_uri_get_path((axutil_uri_t *)uri, env); + } + else + { + return NULL; + } + if(path) + { + reader = axiom_xml_reader_create_for_file(env, path, NULL); + } + else + { + return NULL; + } + if(reader) + { + om_builder = axiom_stax_builder_create(env, reader); + } + else + { + return NULL; + } + if(om_builder) + { + doc = axiom_stax_builder_get_document(om_builder, env); + } + else + { + return NULL; + } + if(doc) + { + axiom_document_build_all(doc, env); + } + else + { + return NULL; + } + + return doc; +} + +AXIS2_EXTERN axiom_node_t* AXIS2_CALL +axiom_util_get_node_by_local_name( + const axutil_env_t *env, + axiom_node_t *node, + axis2_char_t *local_name) +{ + axis2_char_t *temp_name = NULL; + + if(!node) + { + return NULL; + } + + if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) + { + return NULL; + } + + temp_name = axiom_util_get_localname(node, env); + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]Checking node %s for %s", temp_name, + local_name); + + if(!axutil_strcmp(temp_name, local_name)) + { + /* Gottcha.. return this node */ + return node; + } + else + { + /* Doesn't match? Get the children and search for them */ + axiom_node_t *temp_node = NULL; + + temp_node = axiom_node_get_first_element(node, env); + while(temp_node) + { + axiom_node_t *res_node = NULL; + res_node = axiom_util_get_node_by_local_name(env, temp_node, local_name); + if(res_node) + { + return res_node; + } + temp_node = axiom_node_get_next_sibling(temp_node, env); + } + } + return NULL; +} + +/** + * Creates a clone of given node + * @param env environment, MUST not be NULL + * @param node node to be cloned + * @return cloned node + */ +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +axiom_util_clone_node( + const axutil_env_t *env, + axiom_node_t *node) +{ + axis2_char_t* node_string = NULL; + axiom_node_t *clone = NULL; + + if(!node) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Could not be able to clone the node. Given node is not valid."); + return NULL; + } + + node_string = axiom_node_sub_tree_to_string(node, env); + clone = axiom_node_create_from_buffer(env, node_string); + + if(node_string) + { + AXIS2_FREE(env->allocator, node_string); + } + + return clone; +} diff --git a/axiom/src/xpath/Makefile.am b/axiom/src/xpath/Makefile.am new file mode 100644 index 0000000..5d4f42f --- /dev/null +++ b/axiom/src/xpath/Makefile.am @@ -0,0 +1,22 @@ +lib_LTLIBRARIES = libaxis2_xpath.la +libaxis2_xpath_la_SOURCES = xpath.c \ + xpath_functions.c \ + xpath_internals.c \ + xpath_internals_engine.c \ + xpath_internals_iterators.c \ + xpath_internals_parser.c \ + xpath_streaming.c + +libaxis2_xpath_la_LDFLAGS = -version-info $(VERSION_NO) + +libaxis2_xpath_la_LIBADD = +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/src/parser \ + -I$(top_builddir)/src/om \ + -I ../../../util/include \ + -I ../../../include + +EXTRA_DIST = xpath_functions.h xpath_internals_engine.h \ + xpath_internals.h xpath_internals_iterators.h \ + xpath_internals_parser.h xpath_streaming.h + diff --git a/axiom/src/xpath/xpath.c b/axiom/src/xpath/xpath.c new file mode 100755 index 0000000..38f422c --- /dev/null +++ b/axiom/src/xpath/xpath.c @@ -0,0 +1,462 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "xpath_internals.h" +#include "xpath_internals_parser.h" +#include "xpath_internals_engine.h" +#include "xpath_functions.h" +#include "xpath_streaming.h" + +/* Create XPath context */ +AXIS2_EXTERN axiom_xpath_context_t * AXIS2_CALL +axiom_xpath_context_create( + const axutil_env_t *env, + axiom_node_t * root_node) +{ + axiom_xpath_context_t* context; + + /*HACK: xpath impl requires a dummy root node in order to process properly.*/ + axiom_node_t * dummy_root; + dummy_root = axiom_node_create(env); + axiom_node_add_child(dummy_root, env, root_node); + + context = AXIS2_MALLOC(env->allocator, + sizeof(axiom_xpath_context_t)); + + context->env = env; + context->root_node = dummy_root; + context->node = dummy_root; + context->expr = NULL; + context->attribute = NULL; + context->namespaces = NULL; + context->functions = NULL; + + axiom_xpath_register_default_functions_set(context); + + return context; +} + +/* Compile XPath expression */ +AXIS2_EXTERN axiom_xpath_expression_t * AXIS2_CALL +axiom_xpath_compile_expression( + const axutil_env_t *env, + const axis2_char_t* xpath_expr) +{ + axiom_xpath_expression_t* expr; + + expr = AXIS2_MALLOC(env->allocator, + sizeof(axiom_xpath_expression_t)); + + expr->expr_str = axutil_strdup(env, xpath_expr); + + if (axiom_xpath_compile(env, expr) == AXIOM_XPATH_PARSE_ERROR) + { + AXIS2_FREE(env->allocator, expr->expr_str); + AXIS2_FREE(env->allocator, expr); + + return NULL; + } + else + { + return expr; + } +} + +/* Evaluate compiled XPath expression */ +AXIS2_EXTERN axiom_xpath_result_t * AXIS2_CALL +axiom_xpath_evaluate( + axiom_xpath_context_t *context, + axiom_xpath_expression_t *xpath_expr) +{ + axiom_xpath_expression_copy(context, xpath_expr); + + context->streaming = AXIS2_FALSE; + + return axiom_xpath_run(context); +} + +AXIS2_EXTERN axiom_xpath_result_t * AXIS2_CALL +axiom_xpath_evaluate_streaming( + axiom_xpath_context_t *context, + axiom_xpath_expression_t *xpath_expr) +{ + axiom_xpath_result_t *res; + + axiom_xpath_expression_copy(context, xpath_expr); + + if (axiom_xpath_streaming_check(context->env, xpath_expr)) + { + context->streaming = AXIS2_TRUE; + return axiom_xpath_run(context); + } + else + { + res = AXIS2_MALLOC( + context->env->allocator, sizeof(axiom_xpath_result_t)); + res->nodes = NULL; + res->flag = AXIOM_XPATH_ERROR_STREAMING_NOT_SUPPORTED; + + return res; + } +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_xpath_register_default_functions_set( + axiom_xpath_context_t *context) +{ + axiom_xpath_register_function( + context, "count", axiom_xpath_function_count); +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_xpath_register_function( + axiom_xpath_context_t *context, + axis2_char_t *name, + axiom_xpath_function_t func) +{ + if (name && func) + { + if (!context->functions) + { + context->functions = axutil_hash_make(context->env); + } + + axutil_hash_set(context->functions, name, AXIS2_HASH_KEY_STRING, func); + } +} + +AXIS2_EXTERN axiom_xpath_function_t AXIS2_CALL +axiom_xpath_get_function( + axiom_xpath_context_t *context, + axis2_char_t *name) +{ + axiom_xpath_function_t func = NULL; + + if(context->functions) + { + func = axutil_hash_get(context->functions, name, AXIS2_HASH_KEY_STRING); + } + + return func; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_xpath_register_namespace( + axiom_xpath_context_t *context, + axiom_namespace_t *ns) +{ + axis2_char_t *prefix = NULL; + + if (!context->namespaces) + { + context->namespaces = axutil_hash_make(context->env); + } + + prefix = axiom_namespace_get_prefix(ns, context->env); + + if (prefix) + { + axutil_hash_set( + context->namespaces, prefix, AXIS2_HASH_KEY_STRING, ns); + } +} + +AXIS2_EXTERN axiom_namespace_t * AXIS2_CALL +axiom_xpath_get_namespace( + axiom_xpath_context_t *context, + axis2_char_t *prefix) +{ + axiom_namespace_t *ns = NULL; + + if (context->namespaces) + { + ns = axutil_hash_get(context->namespaces, prefix, AXIS2_HASH_KEY_STRING); + } + + return ns; +} + +AXIS2_EXTERN void AXIS2_CALL +axiom_xpath_clear_namespaces( + axiom_xpath_context_t *context) +{ + axutil_hash_index_t *hi; + void *val; + + if (context->namespaces) + { + for (hi = axutil_hash_first(context->namespaces, context->env); + hi; + hi = axutil_hash_next(context->env, hi)) + { + axutil_hash_this(hi, NULL, NULL, &val); + axiom_namespace_free((axiom_namespace_t *)val, context->env); + } + + axutil_hash_free(context->namespaces, context->env); + } + + context->namespaces = NULL; +} + +/* Cast to boolean */ +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_xpath_cast_node_to_boolean( + const axutil_env_t *env, + axiom_xpath_result_node_t * node) +{ + if(node->type == AXIOM_XPATH_TYPE_BOOLEAN) + { + return *(axis2_bool_t *)node->value; + } + else if(node->type == AXIOM_XPATH_TYPE_NUMBER) + { + /* Cannot evaluate as *(double *)(node->value) == 1e-12 + since there might be an precision error */ + if(*(double *)(node->value) > 1e-12 || *(double *)(node->value) < -1e-12) + { + return AXIS2_TRUE; + } + else + { + return AXIS2_FALSE; + } + } + else if(node->value) + { + return AXIS2_TRUE; + } + else + { + return AXIS2_FALSE; + } +} + +/* Cast to double */ +AXIS2_EXTERN double AXIS2_CALL +axiom_xpath_cast_node_to_number( + const axutil_env_t *env, + axiom_xpath_result_node_t * node) +{ + if (node->type == AXIOM_XPATH_TYPE_BOOLEAN) + { + if (*(axis2_bool_t *)(node->value) == AXIS2_TRUE) + { + return 1.0; + } + else + { + return 0.0; + } + } + else if (node->type == AXIOM_XPATH_TYPE_NUMBER) + { + return *(double *)node->value; + } + else if (node->value) + { + return 1.0; + } + else + { + return 0.0; + } +} + +/* Cast to text */ +AXIS2_EXTERN axis2_char_t * AXIS2_CALL +axiom_xpath_cast_node_to_string( + const axutil_env_t *env, + axiom_xpath_result_node_t * node) +{ + axiom_element_t *ele; + axis2_char_t *res; + + if (!node->value) + { + return NULL; + } + + if (node->type == AXIOM_XPATH_TYPE_BOOLEAN) + { + if (*(axis2_bool_t *)(node->value) == AXIS2_TRUE) + { + return axutil_strdup(env, "true"); + } + else + { + return axutil_strdup(env, "false"); + } + } + else if (node->type == AXIOM_XPATH_TYPE_NUMBER) + { + /* Allocate 50 bytes */ + res = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 50); + + sprintf(res, "%lf", *(double *)(node->value)); + + return res; + } + else if (node->type == AXIOM_XPATH_TYPE_TEXT) + { + return (axis2_char_t *)node->value; + } + else if (node->type == AXIOM_XPATH_TYPE_NODE) + { + ele = (axiom_element_t *)axiom_node_get_data_element( + (axiom_node_t *)(node->value), env); + + if (ele) + { + return axiom_element_get_text( + ele, env, (axiom_node_t *)(node->value)); + } + else + { + return NULL; + } + } + else if (node->type == AXIOM_XPATH_TYPE_ATTRIBUTE) + { + return axiom_attribute_get_value( + (axiom_attribute_t *)(node->value), env); + } + else if (node->type == AXIOM_XPATH_TYPE_NAMESPACE) + { + return axiom_namespace_get_prefix( + (axiom_namespace_t *)(node->value), env); + } + + return NULL; +} + +/* Cast to axiom node */ +AXIS2_EXTERN axiom_node_t * AXIS2_CALL +axiom_xpath_cast_node2axiom_node( + const axutil_env_t *env, + axiom_xpath_result_node_t * node) +{ + if (node->type == AXIOM_XPATH_TYPE_NODE && node->value) + { + return (axiom_node_t *)node->value; + } + else + { + return NULL; + } +} + +/* Free context */ +AXIS2_EXTERN void AXIS2_CALL +axiom_xpath_free_context( + const axutil_env_t *env, + axiom_xpath_context_t *context) +{ + if (context) + { + /* Free the expression if not freed */ + if (context->expr) + { + /* axiom_xpath_free_expression(env, context->expr); */ + + context->expr = NULL; + } + + if (context->root_node) + { + axiom_node_detach(axiom_node_get_first_child(context->root_node, context->env), context->env); + axiom_node_free_tree(context->root_node, context->env); + context->root_node = NULL; + } + + if (context->functions) + { + axutil_hash_free(context->functions, context->env); + context->functions = NULL; + } + + if(context->namespaces) + { + axiom_xpath_clear_namespaces(context); + context->namespaces = NULL; + } + + AXIS2_FREE(env->allocator, context); + } +} + +/* Free expression */ +AXIS2_EXTERN void AXIS2_CALL +axiom_xpath_free_expression( + const axutil_env_t *env, + axiom_xpath_expression_t * xpath_expr) +{ + if (xpath_expr) + { + if (xpath_expr->expr_str) + { + AXIS2_FREE(env->allocator, xpath_expr->expr_str); + + xpath_expr->expr_str = NULL; + } + + if (xpath_expr->operations) + { + axutil_array_list_free(xpath_expr->operations, env); + xpath_expr->operations = NULL; + } + + AXIS2_FREE(env->allocator, xpath_expr); + } +} + +/* Free result set */ +AXIS2_EXTERN void AXIS2_CALL +axiom_xpath_free_result( + const axutil_env_t *env, + axiom_xpath_result_t* result) +{ + if (result) + { + if (result->nodes) + { + axutil_array_list_free(result->nodes, env); + } + + AXIS2_FREE(env->allocator, result); + } +} + +/* Check if the expression can be evaluated on streaming XML */ +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axiom_xpath_streaming_check( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + axiom_xpath_streaming_t r = AXIOM_XPATH_CHECK(expr->start); + + if(r == AXIOM_XPATH_STREAMING_NOT_SUPPORTED) + { + return AXIS2_FALSE; + } + else + { + return AXIS2_TRUE; + } +} + diff --git a/axiom/src/xpath/xpath_functions.c b/axiom/src/xpath/xpath_functions.c new file mode 100755 index 0000000..bdf65c2 --- /dev/null +++ b/axiom/src/xpath/xpath_functions.c @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "xpath_functions.h" +#include "xpath_internals_engine.h" + +int +axiom_xpath_function_count( + axiom_xpath_context_t *context, + int np) +{ + axiom_xpath_result_node_t *node; + double * v; + int i; + + node = AXIS2_MALLOC(context->env->allocator, sizeof(axiom_xpath_result_node_t)); + v = AXIS2_MALLOC(context->env->allocator, sizeof(double)); + + *v = np; + node->value = v; + node->type = AXIOM_XPATH_TYPE_NUMBER; + + for(i = 0; i < np; i++) + { + axutil_stack_pop(context->stack, context->env); + } + + axutil_stack_push(context->stack, context->env, node); + + return 1; +} diff --git a/axiom/src/xpath/xpath_functions.h b/axiom/src/xpath/xpath_functions.h new file mode 100755 index 0000000..d44f0a2 --- /dev/null +++ b/axiom/src/xpath/xpath_functions.h @@ -0,0 +1,47 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_XPATH_FUNCTIONS_H +#define AXIOM_XPATH_FUNCTIONS_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_xpath_functions functions + * @ingroup axiom_xpath + * @{ + */ + + /** + * count(node-set) function + * http://www.w3.org/TR/xpath#function-count + */ + int axiom_xpath_function_count(axiom_xpath_context_t *context, int np); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/axiom/src/xpath/xpath_internals.c b/axiom/src/xpath/xpath_internals.c new file mode 100755 index 0000000..c313baf --- /dev/null +++ b/axiom/src/xpath/xpath_internals.c @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "xpath_internals.h" + +/* Make a copy of the xpath expression */ +void +axiom_xpath_expression_copy( + axiom_xpath_context_t *context, + axiom_xpath_expression_t* expr) +{ + int i; + axiom_xpath_operation_t *op; + + context->expr = expr; + + /* Set value of pos in every operation to 0 */ + for(i = 0; i < axutil_array_list_size(expr->operations, context->env); i++) + { + op = AXIOM_XPATH_OPR_GET(i); + op->pos = 0; + } +} diff --git a/axiom/src/xpath/xpath_internals.h b/axiom/src/xpath/xpath_internals.h new file mode 100755 index 0000000..891d543 --- /dev/null +++ b/axiom/src/xpath/xpath_internals.h @@ -0,0 +1,199 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_XPATH_INTERNALS_H +#define AXIOM_XPATH_INTERNALS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_xpath_internals internals + * @ingroup axiom_xpath + * @{ + */ + + + /** Get operation at index ind */ +#define AXIOM_XPATH_OPR_GET(ind) (axiom_xpath_operation_t *) \ + axutil_array_list_get(context->expr->operations, context->env, ind) + + /** + * An error has occured while parsing + */ +#define AXIOM_XPATH_PARSE_ERROR -2 + + /** + * XPath expression was successfully compiled + */ +#define AXIOM_XPATH_PARSE_SUCCESS 0 + + /** + * End of expression reached + */ +#define AXIOM_XPATH_PARSE_END -1 + + /* Types */ + + /** + * XPath operation + * Contains the operands and parameters + */ + typedef struct axiom_xpath_operation axiom_xpath_operation_t; + + /** + * XPath node test + * Stores the components of a node test + */ + typedef struct axiom_xpath_node_test axiom_xpath_node_test_t; + + /** + * Functions to process a XPath operator + */ + typedef int (*axiom_xpath_operator_t)(axiom_xpath_context_t *context, + axiom_xpath_operation_t * op); + + /** + * Functions to iterate through different XPath axes + */ + typedef int (*axiom_xpath_iterator_t)(axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * XPath node test types + */ + typedef enum axiom_xpath_node_test_type_t + { + AXIOM_XPATH_NODE_TEST_NONE = 0, + AXIOM_XPATH_NODE_TEST_ALL, + AXIOM_XPATH_NODE_TYPE_COMMENT, + AXIOM_XPATH_NODE_TYPE_NODE, + AXIOM_XPATH_NODE_TYPE_PI, + AXIOM_XPATH_NODE_TYPE_TEXT, + AXIOM_XPATH_NODE_TEST_STANDARD + } axiom_xpath_node_test_type_t; + + /** + * XPath operations + */ + typedef enum axiom_xpath_operation_type_t + { + AXIOM_XPATH_OPERATION_ROOT_NODE = 0, + AXIOM_XPATH_OPERATION_CONTEXT_NODE, + AXIOM_XPATH_OPERATION_NODE_TEST, + AXIOM_XPATH_OPERATION_STEP, + AXIOM_XPATH_OPERATION_RESULT, + AXIOM_XPATH_OPERATION_UNION, + AXIOM_XPATH_OPERATION_EQUAL_EXPR, + AXIOM_XPATH_OPERATION_AND_EXPR, + AXIOM_XPATH_OPERATION_OR_EXPR, + AXIOM_XPATH_OPERATION_PREDICATE, + AXIOM_XPATH_OPERATION_LITERAL, + AXIOM_XPATH_OPERATION_NUMBER, + AXIOM_XPATH_OPERATION_PATH_EXPRESSION, + AXIOM_XPATH_OPERATION_FUNCTION_CALL, + AXIOM_XPATH_OPERATION_ARGUMENT + } axiom_xpath_operation_type_t; + + /** + * XPath axes + */ + typedef enum axiom_xpath_axis_t + { + AXIOM_XPATH_AXIS_NONE = -1, + AXIOM_XPATH_AXIS_CHILD, + AXIOM_XPATH_AXIS_DESCENDANT, + AXIOM_XPATH_AXIS_PARENT, + AXIOM_XPATH_AXIS_ANCESTOR, + AXIOM_XPATH_AXIS_FOLLOWING_SIBLING, + AXIOM_XPATH_AXIS_PRECEDING_SIBLING, + AXIOM_XPATH_AXIS_FOLLOWING, + AXIOM_XPATH_AXIS_PRECEDING, + AXIOM_XPATH_AXIS_ATTRIBUTE, + AXIOM_XPATH_AXIS_NAMESPACE, + AXIOM_XPATH_AXIS_SELF, + AXIOM_XPATH_AXIS_DESCENDANT_OR_SELF, + AXIOM_XPATH_AXIS_ANCESTOR_OR_SELF + } axiom_xpath_axis_t; + + /** + * XPath node test structure + */ + struct axiom_xpath_node_test + { + /** Node test type */ + axiom_xpath_node_test_type_t type; + + /** Prefix + * NULL if no prefix + */ + axis2_char_t *prefix; + + /** Name */ + axis2_char_t *name; + + /** Literal for processing instruction (PI) */ + axis2_char_t *lit; + }; + + /** + * XPath operation structure + */ + struct axiom_xpath_operation + { + /** Type of operator */ + axiom_xpath_operation_type_t opr; + + /** Parameters of the operation */ + void *par1; + void *par2; + + /** Position: Used for predicate evaluation + */ + int pos; + + /** Operands pointing to other operations */ + int op1; + int op2; + }; + + /** + * Copies an XPath expression to a context + * + * No data is duplicated just the reference is assigned. + * Some parameters in the expression are reset. + * - pos in every operation + * + * @param context XPath context must not be NULL + * @param expr Expression to be copied + */ + void axiom_xpath_expression_copy( + axiom_xpath_context_t *context, + axiom_xpath_expression_t* expr); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/axiom/src/xpath/xpath_internals_engine.c b/axiom/src/xpath/xpath_internals_engine.c new file mode 100644 index 0000000..3c96d0e --- /dev/null +++ b/axiom/src/xpath/xpath_internals_engine.c @@ -0,0 +1,1203 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "xpath_internals.h" +#include "xpath_internals_engine.h" +#include "xpath_internals_iterators.h" + +/* Evaluates the expath expression */ +axiom_xpath_result_t * +axiom_xpath_run( + axiom_xpath_context_t *context) +{ + axiom_xpath_result_t* res; + + /* Initialize result ret */ + res = AXIS2_MALLOC(context->env->allocator, sizeof(axiom_xpath_result_t)); + + res->flag = 0; + + res->nodes = axutil_array_list_create(context->env, 0); + + /* Expression is empty */ + if(context->expr->start == AXIOM_XPATH_PARSE_END) + { + return res; + } + + context->stack = axutil_stack_create(context->env); + + axiom_xpath_evaluate_operation(context, context->expr->start); + + /* Add nodes to the result set from the stack */ + while(axutil_stack_size(context->stack, context->env) > 0) + { + axutil_array_list_add(res->nodes, context->env, + axutil_stack_pop(context->stack, context->env)); + } + + axutil_stack_free(context->stack, context->env); + + return res; +} + +/* Casting functions; these make use of the casting functions defined in xpath.h */ +void +axiom_xpath_cast_boolean( + axiom_xpath_result_node_t *node, + axiom_xpath_context_t *context) +{ + axis2_bool_t v = axiom_xpath_cast_node_to_boolean(context->env, node); + + AXIOM_XPATH_CAST_SET_VALUE(axis2_bool_t, v); + + node->type = AXIOM_XPATH_TYPE_BOOLEAN; +} + +void +axiom_xpath_cast_number( + axiom_xpath_result_node_t *node, + axiom_xpath_context_t *context) +{ + double v = axiom_xpath_cast_node_to_number(context->env, node); + + AXIOM_XPATH_CAST_SET_VALUE(double, v); + + node->type = AXIOM_XPATH_TYPE_NUMBER; +} + +void +axiom_xpath_cast_string( + axiom_xpath_result_node_t *node, + axiom_xpath_context_t *context) +{ + node->value = axiom_xpath_cast_node_to_string(context->env, node); + + node->type = AXIOM_XPATH_TYPE_TEXT; +} + +/* Evaluate whether two results are equal + + If either node is a boolean other is casted to a boolean; + Otherwise, if either node is a number other is casted to a number; + Otherwise, both nodes are casted to strings.*/ +axis2_bool_t +axiom_xpath_compare_equal( + axiom_xpath_result_node_t *node1, + axiom_xpath_result_node_t *node2, + axiom_xpath_context_t *context) +{ + if(node1->type == AXIOM_XPATH_TYPE_BOOLEAN || node2->type == AXIOM_XPATH_TYPE_BOOLEAN) + { + axiom_xpath_cast_boolean(node1, context); + axiom_xpath_cast_boolean(node2, context); + + if(*(axis2_bool_t*)(node1->value) == *(axis2_bool_t*)(node2->value)) + { + return AXIS2_TRUE; + } + else + { + return AXIS2_FALSE; + } + } + + if(node1->type == AXIOM_XPATH_TYPE_NUMBER || node2->type == AXIOM_XPATH_TYPE_NUMBER) + { + axiom_xpath_cast_number(node1, context); + axiom_xpath_cast_number(node2, context); + + if(*(double *)(node1->value) == *(double *)(node2->value)) + { + return AXIS2_TRUE; + } + else + { + return AXIS2_FALSE; + } + } + + axiom_xpath_cast_string(node1, context); + axiom_xpath_cast_string(node2, context); + + if(axutil_strcmp((axis2_char_t *)(node1->value), (axis2_char_t *)(node2->value)) == 0) + { + return AXIS2_TRUE; + } + else + { + return AXIS2_FALSE; + } +} + +/* Convert a node set to boolean */ +axis2_bool_t +axiom_xpath_convert_to_boolean( + axutil_array_list_t *node_set, + axiom_xpath_context_t *context) +{ + if(axutil_array_list_size(node_set, context->env) == 0) + { + return AXIS2_FALSE; + } + else if(axutil_array_list_size(node_set, context->env) >= 2) + { + return AXIS2_TRUE; + } + else + { + axiom_xpath_result_node_t *node = axutil_array_list_get(node_set, context->env, 0); + axiom_xpath_cast_boolean(node, context); + + return *(axis2_bool_t *)node->value; + } +} + +/* Operators */ + +/* Literal */ +int +axiom_xpath_literal_operator( + axiom_xpath_context_t *context, + axiom_xpath_operation_t * op) +{ + axiom_xpath_result_node_t *node; + + node = AXIS2_MALLOC(context->env->allocator, sizeof(axiom_xpath_result_node_t)); + + /* Set the context node to NULL */ + /* This is not required; it gives some problems */ + /* context->node = NULL;*/ + + node->value = op->par1; + node->type = AXIOM_XPATH_TYPE_TEXT; + + axutil_stack_push(context->stack, context->env, node); + + return 1; +} + +/* Number */ +int +axiom_xpath_number_operator( + axiom_xpath_context_t *context, + axiom_xpath_operation_t * op) +{ + axiom_xpath_result_node_t *node; + + node = AXIS2_MALLOC(context->env->allocator, sizeof(axiom_xpath_result_node_t)); + + /* Set the context node to NULL */ + /* This is not required; it gives some problems */ + /* context->node = NULL;*/ + + node->value = op->par1; + node->type = AXIOM_XPATH_TYPE_NUMBER; + + axutil_stack_push(context->stack, context->env, node); + + return 1; +} + +/* Path Expression */ +int +axiom_xpath_path_expression_operator( + axiom_xpath_context_t *context, + axiom_xpath_operation_t * op) +{ + int filter_res_n, n_nodes = 0; + axiom_xpath_operation_t *rel_loc_op; + axiom_xpath_operator_t rel_loc_func; + axutil_array_list_t *arr; + axiom_xpath_result_node_t *res_node; + int i; + + /* Filter operation */ + if(op->op1 == AXIOM_XPATH_PARSE_END) + { + return 0; + } + + filter_res_n = axiom_xpath_evaluate_operation(context, op->op1); + + /* Relative location path */ + if(op->op2 == AXIOM_XPATH_PARSE_END) + { + return filter_res_n; + } + + rel_loc_op = AXIOM_XPATH_OPR_GET(op->op2); + rel_loc_func = axiom_xpath_get_operator(rel_loc_op); + + /* Array list to add all results from the filter expression */ + arr = axutil_array_list_create(context->env, 0); + + for(i = 0; i < filter_res_n; i++) + { + axutil_array_list_add(arr, context->env, axutil_stack_pop(context->stack, context->env)); + } + + /* Evaluate relative location path for all results from the + filter expression */ + for(i = 0; i < axutil_array_list_size(arr, context->env); i++) + { + res_node = (axiom_xpath_result_node_t *)axutil_array_list_get(arr, context->env, i); + + if(res_node->type == AXIOM_XPATH_TYPE_NODE) + { + context->node = (axiom_node_t *)res_node->value; + context->position = i + 1; + context->size = filter_res_n; + + n_nodes += rel_loc_func(context, rel_loc_op); + } + + AXIS2_FREE(context->env->allocator, res_node); + } + + axutil_array_list_free(arr, context->env); + + return n_nodes; +} + +/* Or Expression */ +int +axiom_xpath_orexpr_operator( + axiom_xpath_context_t *context, + axiom_xpath_operation_t * op) +{ + axiom_xpath_result_node_t *node; + axiom_xpath_result_node_t *res_node; + int n_nodes[2]; + int i, j; + int op12[2]; + axutil_array_list_t *arr[2]; + + op12[0] = op->op1; + op12[1] = op->op2; + + /* Evaluate both operands and get number of results */ + for(i = 0; i < 2; i++) + { + if(op12[i] == AXIOM_XPATH_PARSE_END) + { + continue; + } + + n_nodes[i] = axiom_xpath_evaluate_operation(context, op12[i]); + } + + for(i = 1; i >= 0; i--) + { + arr[i] = axutil_array_list_create(context->env, 0); + + for(j = 0; j < n_nodes[i]; j++) + { + axutil_array_list_add(arr[i], context->env, axutil_stack_pop(context->stack, + context->env)); + } + } + + node = AXIS2_MALLOC(context->env->allocator, sizeof(axiom_xpath_result_node_t)); + + node->type = AXIOM_XPATH_TYPE_BOOLEAN; + node->value = NULL; + + /* Checking equality + - If any node from the first set is equal to any node from the second set + the result is true */ + if(axiom_xpath_convert_to_boolean(arr[0], context) || axiom_xpath_convert_to_boolean(arr[1], + context)) + { + AXIOM_XPATH_CAST_SET_VALUE(axis2_bool_t, AXIS2_TRUE); + + axutil_stack_push(context->stack, context->env, node); + } + else + { + AXIOM_XPATH_CAST_SET_VALUE(axis2_bool_t, AXIS2_FALSE); + + axutil_stack_push(context->stack, context->env, node); + } + + for (i = 1; i >= 0; i--) + { + for (j = 0; j < n_nodes[i]; j++) + { + res_node = (axiom_xpath_result_node_t *)axutil_array_list_get(arr[i], context->env, j); + AXIS2_FREE(context->env->allocator, res_node); + } + + axutil_array_list_free(arr[i], context->env); + } + + return 1; +} + +/* And Expression */ +int +axiom_xpath_andexpr_operator( + axiom_xpath_context_t *context, + axiom_xpath_operation_t * op) +{ + axiom_xpath_result_node_t *node; + axiom_xpath_result_node_t *res_node; + int n_nodes[2]; + int i, j; + int op12[2]; + axutil_array_list_t *arr[2]; + + op12[0] = op->op1; + op12[1] = op->op2; + + /* Evaluate both operands and get number of results */ + for(i = 0; i < 2; i++) + { + if(op12[i] == AXIOM_XPATH_PARSE_END) + { + continue; + } + + n_nodes[i] = axiom_xpath_evaluate_operation(context, op12[i]); + } + + for(i = 1; i >= 0; i--) + { + arr[i] = axutil_array_list_create(context->env, 0); + + for(j = 0; j < n_nodes[i]; j++) + { + axutil_array_list_add(arr[i], context->env, axutil_stack_pop(context->stack, + context->env)); + } + } + + node = AXIS2_MALLOC(context->env->allocator, sizeof(axiom_xpath_result_node_t)); + + node->type = AXIOM_XPATH_TYPE_BOOLEAN; + node->value = NULL; + + /* Checking equality + - If any node from the first set is equal to any node from the second set + the result is true */ + if(axiom_xpath_convert_to_boolean(arr[0], context) && axiom_xpath_convert_to_boolean(arr[1], + context)) + { + AXIOM_XPATH_CAST_SET_VALUE(axis2_bool_t, AXIS2_TRUE); + + axutil_stack_push(context->stack, context->env, node); + } + else + { + AXIOM_XPATH_CAST_SET_VALUE(axis2_bool_t, AXIS2_FALSE); + + axutil_stack_push(context->stack, context->env, node); + } + + for (i = 1; i >= 0; i--) + { + for (j = 0; j < n_nodes[i]; j++) + { + res_node = (axiom_xpath_result_node_t *)axutil_array_list_get(arr[i], context->env, j); + AXIS2_FREE(context->env->allocator, res_node); + } + + axutil_array_list_free(arr[i], context->env); + } + + return 1; +} + +/* Equal Expression */ +int +axiom_xpath_equalexpr_operator( + axiom_xpath_context_t *context, + axiom_xpath_operation_t * op) +{ + axiom_xpath_result_node_t *node; + axiom_xpath_result_node_t *res_node; + int n_nodes[2]; + int i, j; + int op12[2]; + axutil_array_list_t *arr[2]; + + op12[0] = op->op1; + op12[1] = op->op2; + + /* Evaluate both operands and get number of results */ + for(i = 0; i < 2; i++) + { + if(op12[i] == AXIOM_XPATH_PARSE_END) + { + continue; + } + + n_nodes[i] = axiom_xpath_evaluate_operation(context, op12[i]); + } + + for(i = 1; i >= 0; i--) + { + arr[i] = axutil_array_list_create(context->env, 0); + + for(j = 0; j < n_nodes[i]; j++) + { + axutil_array_list_add(arr[i], context->env, axutil_stack_pop(context->stack, + context->env)); + } + } + + node = AXIS2_MALLOC(context->env->allocator, sizeof(axiom_xpath_result_node_t)); + + node->type = AXIOM_XPATH_TYPE_BOOLEAN; + node->value = NULL; + + /* Checking equality + - If any node from the first set is equal to any node from the second set + the result is true */ + for(i = 0; i < n_nodes[0]; i++) + { + for(j = 0; j < n_nodes[1]; j++) + { + if(axiom_xpath_compare_equal(axutil_array_list_get(arr[0], context->env, i), + axutil_array_list_get(arr[1], context->env, j), context)) + { + AXIOM_XPATH_CAST_SET_VALUE(axis2_bool_t, AXIS2_TRUE); + + axutil_stack_push(context->stack, context->env, node); + + break; + } + } + + if(j < n_nodes[1]) + { + break; + } + } + + if(!node->value) + { + AXIOM_XPATH_CAST_SET_VALUE(axis2_bool_t, AXIS2_FALSE); + + axutil_stack_push(context->stack, context->env, node); + } + + for (i = 1; i >= 0; i--) + { + for (j = 0; j < n_nodes[i]; j++) + { + res_node =(axiom_xpath_result_node_t *)axutil_array_list_get(arr[i], context->env, j); + AXIS2_FREE(context->env->allocator, res_node); + } + + axutil_array_list_free(arr[i], context->env); + } + + return 1; +} + +/* Union */ +int +axiom_xpath_union_operator( + axiom_xpath_context_t *context, + axiom_xpath_operation_t * op) +{ + int n_nodes = 0; + int i; + int op12[2]; + + op12[0] = op->op1; + op12[1] = op->op2; + + for(i = 0; i < 2; i++) + { + if(op12[i] == AXIOM_XPATH_PARSE_END) + { + continue; + } + + n_nodes += axiom_xpath_evaluate_operation(context, op12[i]); + } + + return n_nodes; +} + +/* Set context node depending on whether relative or absolute location path */ +int +axiom_xpath_start_node_operator( + axiom_xpath_context_t *context, + axiom_xpath_operation_t * op) +{ + int n_nodes = 0; + + if(op->op1 == AXIOM_XPATH_PARSE_END) + { + return 0; + } + + if(op->opr == AXIOM_XPATH_OPERATION_ROOT_NODE) + { + context->node = context->root_node; + n_nodes += axiom_xpath_evaluate_operation(context, op->op1); + } + else if(op->opr == AXIOM_XPATH_OPERATION_CONTEXT_NODE) + { + n_nodes += axiom_xpath_evaluate_operation(context, op->op1); + } + + return n_nodes; +} + +/* Step */ +int +axiom_xpath_step_operator( + axiom_xpath_context_t *context, + axiom_xpath_operation_t * op) +{ + axiom_xpath_operation_t * node_test_op; + axiom_xpath_iterator_t iter; + axiom_xpath_axis_t axis; + + if(op->op1 == AXIOM_XPATH_PARSE_END) + { +#ifdef AXIOM_XPATH_DEBUG + printf("Node test operator empty\n"); +#endif + + return AXIOM_XPATH_EVALUATION_ERROR; + } + + if(op->op2 == AXIOM_XPATH_PARSE_END) + { + return 0; + } + + /* Get the name */ + node_test_op = AXIOM_XPATH_OPR_GET(op->op1); + + /* Get the axis */ + if(!node_test_op->par2) + { +#ifdef AXIOM_XPATH_DEBUG + printf("axis is NULL in the step operator\n"); +#endif + return AXIOM_XPATH_EVALUATION_ERROR; + } + axis = *((axiom_xpath_axis_t *)node_test_op->par2); + + /* Get the iteration for the axis */ + iter = axiom_xpath_get_iterator(axis); + + return iter(context, op->op1 /* node test */, op->op2 /* next step */, node_test_op->op1 /* predicate */); +} + +/* Predicates */ +axis2_bool_t +axiom_xpath_evaluate_predicate_condition( + axiom_xpath_context_t *context, + int n_nodes) +{ + axiom_xpath_result_node_t *res; + int i; + + if(n_nodes <= 0) + { + return AXIS2_FALSE; + } + else if(n_nodes > 1) + { + for(i = 0; i < n_nodes; i++) + { + res = (axiom_xpath_result_node_t *)axutil_stack_pop(context->stack, context->env); + + if (res->type > AXIOM_XPATH_TYPE_NAMESPACE) + { + AXIS2_FREE(context->env->allocator, res->value); + } + + AXIS2_FREE(context->env->allocator, res); + } + + return AXIS2_TRUE; + } + else + { + res = (axiom_xpath_result_node_t *)axutil_stack_pop(context->stack, context->env); + + if(res->type == AXIOM_XPATH_TYPE_NUMBER) + { + if(*(double *)(res->value) == context->position) + { + AXIS2_FREE(context->env->allocator, res); + return AXIS2_TRUE; + } + else + { + AXIS2_FREE(context->env->allocator, res); + return AXIS2_FALSE; + } + } + else if(res->type == AXIOM_XPATH_TYPE_BOOLEAN) + { + if(*(axis2_bool_t *)(res->value)) + { + AXIS2_FREE(context->env->allocator, res); + return AXIS2_TRUE; + } + else + { + AXIS2_FREE(context->env->allocator, res); + return AXIS2_FALSE; + } + } + else + { + AXIS2_FREE(context->env->allocator, res); + return AXIS2_TRUE; + } + } +} + +/* Predicate */ +int +axiom_xpath_evaluate_predicate( + axiom_xpath_context_t *context, + int op_next, + int op_predicate) +{ + int n_res; + axis2_bool_t res; + + axiom_xpath_operation_t * pred_op; + axiom_node_t *context_node = context->node; + + if(op_predicate == AXIOM_XPATH_PARSE_END) + { + return axiom_xpath_evaluate_operation(context, op_next); + } + else + { + pred_op = AXIOM_XPATH_OPR_GET(op_predicate); + + pred_op->pos++; + + /* Evaluate the predicate */ + if(pred_op->op1 != AXIOM_XPATH_PARSE_END) + { + n_res = axiom_xpath_evaluate_operation(context, pred_op->op1); + context->position = pred_op->pos; + + res = axiom_xpath_evaluate_predicate_condition(context, n_res); + } + else + { + res = AXIS2_TRUE; + } + /* A PredicateExpr is evaluated by evaluating the Expr and + converting the result to a boolean. If the result is a number, + the result will be converted to true if the number is equal to the + context position and will be converted to false otherwise; if the + result is not a number, then the result will be converted as if + by a call to the boolean function. */ + + /* Transform the result to number or boolean ? */ + + if(res) + { + context->node = context_node; + + return axiom_xpath_evaluate_predicate(context, op_next, pred_op->op2); + } + } + + return 0; +} + +/* Node test match */ +axis2_bool_t +axiom_xpath_node_test_match( + axiom_xpath_context_t *context, + axiom_xpath_node_test_t *node_test) +{ + axiom_types_t type; + axiom_element_t *element = NULL; + axis2_char_t *name = NULL; + axiom_namespace_t *ns = NULL, *xpath_ns = NULL; + + if(!context->node && !context->attribute && !context->ns) + { +#ifdef AXIOM_XPATH_DEBUG + printf("Both context node and attribute are NULL."); + printf(" May be a literal or a number.\n"); +#endif + return AXIS2_FALSE; + } + else if(context->node) + { + /* Test if the node matches */ + type = axiom_node_get_node_type(context->node, context->env); + + if(type == AXIOM_ELEMENT) + { + element = axiom_node_get_data_element(context->node, context->env); + + name = axiom_element_get_localname(element, context->env); + + ns = axiom_element_get_namespace(element, context->env, context->node); + } + + if(node_test->type == AXIOM_XPATH_NODE_TEST_NONE) + { + return AXIS2_FALSE; + } + else + { + if(node_test->type == AXIOM_XPATH_NODE_TEST_ALL || node_test->type + == AXIOM_XPATH_NODE_TEST_STANDARD) + { + if(type != AXIOM_ELEMENT) + { + return AXIS2_FALSE; + } + + /* Check namespace */ + if(node_test->type == AXIOM_XPATH_NODE_TEST_ALL) + { + if(!ns && node_test->prefix) + { + return AXIS2_FALSE; + } + } + else + { + if((ns && !node_test->prefix) || (!ns && node_test->prefix)) + { + return AXIS2_FALSE; + } + } + + if(ns && node_test->prefix) + { + xpath_ns = axiom_xpath_get_namespace(context, node_test->prefix); + + if(!xpath_ns) + { + return AXIS2_FALSE; + } + + if(axutil_strcmp(axiom_namespace_get_uri(ns, context->env), + axiom_namespace_get_uri(xpath_ns, context->env))) + { + return AXIS2_FALSE; + } + } + + /* Check local name */ + if(node_test->type == AXIOM_XPATH_NODE_TEST_ALL) + { + return AXIS2_TRUE; + } + else if(node_test->type == AXIOM_XPATH_NODE_TEST_STANDARD) + { + if(name && axutil_strcmp(node_test->name, name) == 0) + { + return AXIS2_TRUE; + } + else + { + return AXIS2_FALSE; + } + } + } + else if(node_test->type == AXIOM_XPATH_NODE_TYPE_COMMENT) + { + if(type == AXIOM_COMMENT) + { + return AXIS2_TRUE; + } + else + { + return AXIS2_FALSE; + } + } + else if(node_test->type == AXIOM_XPATH_NODE_TYPE_PI) + { + if(type == AXIOM_PROCESSING_INSTRUCTION) + { + return AXIS2_TRUE; + } + else + { + return AXIS2_FALSE; + } + } + else if(node_test->type == AXIOM_XPATH_NODE_TYPE_NODE) + { + if(type == AXIOM_ELEMENT) + { + return AXIS2_TRUE; + } + else + { + return AXIS2_FALSE; + } + } + else if(node_test->type == AXIOM_XPATH_NODE_TYPE_TEXT) + { + if(type == AXIOM_TEXT) + { + return AXIS2_TRUE; + } + else + { + return AXIS2_FALSE; + } + } + } + } + /* Attributes */ + else if(context->attribute) + { + name = axiom_attribute_get_localname(context->attribute, context->env); + ns = axiom_attribute_get_namespace(context->attribute, context->env); + + if(node_test->type == AXIOM_XPATH_NODE_TEST_NONE) + { + return AXIS2_FALSE; + } + else + { + /* Check namespace */ + if(node_test->type == AXIOM_XPATH_NODE_TEST_ALL) + { + if(!ns && node_test->prefix) + { + return AXIS2_FALSE; + } + } + else + { + if((ns && !node_test->prefix) || (!ns && node_test->prefix)) + { + return AXIS2_FALSE; + } + } + + if(ns && node_test->prefix) + { + xpath_ns = axiom_xpath_get_namespace(context, node_test->prefix); + + if(!xpath_ns) + { + return AXIS2_FALSE; + } + + if(axutil_strcmp(axiom_namespace_get_uri(ns, context->env), + axiom_namespace_get_uri(xpath_ns, context->env))) + { + return AXIS2_FALSE; + } + } + + /* Check local name */ + if(node_test->type == AXIOM_XPATH_NODE_TEST_ALL) + { + return AXIS2_TRUE; + } + else if(node_test->type == AXIOM_XPATH_NODE_TEST_STANDARD) + { + if(name && axutil_strcmp(node_test->name, name) == 0) + { + return AXIS2_TRUE; + } + else + { + return AXIS2_FALSE; + } + } + } + } + + /* Namespace */ + else if(context->ns) + { + /* Prefix is checked ??? If changed to uri the cast + method in xpath.c needs to be changed as well */ + name = axiom_namespace_get_prefix(context->ns, context->env); + ns = NULL; + + if(node_test->type == AXIOM_XPATH_NODE_TEST_NONE) + { + return AXIS2_FALSE; + } + else + { + /* Check namespace */ + if(node_test->type == AXIOM_XPATH_NODE_TEST_ALL) + { + if(!ns && node_test->prefix) + { + return AXIS2_FALSE; + } + } + else + { + if((ns && !node_test->prefix) || (!ns && node_test->prefix)) + { + return AXIS2_FALSE; + } + } + + if(ns && node_test->prefix) + { + xpath_ns = axiom_xpath_get_namespace(context, node_test->prefix); + + if(!xpath_ns) + { + return AXIS2_FALSE; + } + + if(axutil_strcmp(axiom_namespace_get_uri(ns, context->env), + axiom_namespace_get_uri(xpath_ns, context->env))) + { + return AXIS2_FALSE; + } + } + + /* Check local name */ + if(node_test->type == AXIOM_XPATH_NODE_TEST_ALL) + { + return AXIS2_TRUE; + } + else if(node_test->type == AXIOM_XPATH_NODE_TEST_STANDARD) + { + if(name && axutil_strcmp(node_test->name, name) == 0) + { + return AXIS2_TRUE; + } + else + { + return AXIS2_FALSE; + } + } + } + } + + return AXIS2_FALSE; +} + +int +axiom_xpath_function_call_operator( + axiom_xpath_context_t *context, + axiom_xpath_operation_t * op) +{ + axiom_xpath_function_t func = axiom_xpath_get_function(context, op->par1); + int n_args = 0; + + if(!func) + { +#ifdef AXIOM_XPATH_DEBUG + printf("Function %s not found\n", (char *)op->par1); +#endif + + return AXIOM_XPATH_EVALUATION_ERROR; + } + + if(op->op1 != AXIOM_XPATH_PARSE_END) + { + n_args = axiom_xpath_evaluate_operation(context, op->op1); + } + + return func(context, n_args); +} + +int +axiom_xpath_argument_operator( + axiom_xpath_context_t *context, + axiom_xpath_operation_t * op) +{ + int n_args = 0; + + if(op->op1 != AXIOM_XPATH_PARSE_END) + { + n_args += axiom_xpath_evaluate_operation(context, op->op1); + } + + if(op->op2 != AXIOM_XPATH_PARSE_END) + { + n_args += axiom_xpath_evaluate_operation(context, op->op1); + } + + return n_args; +} + +/* Collect the current node to the results list */ +int +axiom_xpath_collect_operator( + axiom_xpath_context_t *context, + axiom_xpath_operation_t * op) +{ + axiom_xpath_result_node_t *node; + + node = AXIS2_MALLOC(context->env->allocator, sizeof(axiom_xpath_result_node_t)); + + if(context->node) + { + node->value = context->node; + node->type = AXIOM_XPATH_TYPE_NODE; + } + else if(context->attribute) + { + node->value = context->attribute; + node->type = AXIOM_XPATH_TYPE_ATTRIBUTE; + } + else if(context->ns) + { + node->value = context->ns; + node->type = AXIOM_XPATH_TYPE_NAMESPACE; + } + + axutil_stack_push(context->stack, context->env, node); + + return 1; +} + +/* Returns a pointer to the respective processing function */ +axiom_xpath_operator_t +axiom_xpath_get_operator( + axiom_xpath_operation_t * op) +{ + switch(op->opr) + { + case AXIOM_XPATH_OPERATION_STEP: + return axiom_xpath_step_operator; + + case AXIOM_XPATH_OPERATION_ROOT_NODE: + case AXIOM_XPATH_OPERATION_CONTEXT_NODE: + return axiom_xpath_start_node_operator; + + case AXIOM_XPATH_OPERATION_RESULT: + return axiom_xpath_collect_operator; + + case AXIOM_XPATH_OPERATION_UNION: + return axiom_xpath_union_operator; + + case AXIOM_XPATH_OPERATION_OR_EXPR: + return axiom_xpath_orexpr_operator; + + case AXIOM_XPATH_OPERATION_AND_EXPR: + return axiom_xpath_andexpr_operator; + + case AXIOM_XPATH_OPERATION_EQUAL_EXPR: + return axiom_xpath_equalexpr_operator; + + case AXIOM_XPATH_OPERATION_LITERAL: + return axiom_xpath_literal_operator; + + case AXIOM_XPATH_OPERATION_NUMBER: + return axiom_xpath_number_operator; + + case AXIOM_XPATH_OPERATION_PATH_EXPRESSION: + return axiom_xpath_path_expression_operator; + + case AXIOM_XPATH_OPERATION_FUNCTION_CALL: + return axiom_xpath_function_call_operator; + + case AXIOM_XPATH_OPERATION_ARGUMENT: + return axiom_xpath_argument_operator; + + default: +#ifdef AXIOM_XPATH_DEBUG + printf("Unidentified operation.\n"); +#endif + + return NULL; + } +} + +/* Returns a pointer to the respective processing function */ +axiom_xpath_iterator_t +axiom_xpath_get_iterator( + axiom_xpath_axis_t axis) +{ + switch(axis) + { + case AXIOM_XPATH_AXIS_CHILD: + return axiom_xpath_child_iterator; + + case AXIOM_XPATH_AXIS_DESCENDANT: + return axiom_xpath_descendant_iterator; + + case AXIOM_XPATH_AXIS_PARENT: + return axiom_xpath_parent_iterator; + + case AXIOM_XPATH_AXIS_ANCESTOR: + return axiom_xpath_ancestor_iterator; + + case AXIOM_XPATH_AXIS_FOLLOWING_SIBLING: + return axiom_xpath_following_sibling_iterator; + + case AXIOM_XPATH_AXIS_PRECEDING_SIBLING: + return axiom_xpath_preceding_sibling_iterator; + + case AXIOM_XPATH_AXIS_FOLLOWING: + return axiom_xpath_following_iterator; + + case AXIOM_XPATH_AXIS_PRECEDING: + return axiom_xpath_preceding_iterator; + + case AXIOM_XPATH_AXIS_ATTRIBUTE: + return axiom_xpath_attribute_iterator; + + case AXIOM_XPATH_AXIS_NAMESPACE: + return axiom_xpath_namespace_iterator; + + case AXIOM_XPATH_AXIS_SELF: + return axiom_xpath_self_iterator; + + case AXIOM_XPATH_AXIS_DESCENDANT_OR_SELF: + return axiom_xpath_descendant_self_iterator; + + case AXIOM_XPATH_AXIS_ANCESTOR_OR_SELF: + return axiom_xpath_ancestor_self_iterator; + + default: +#ifdef AXIOM_XPATH_DEBUG + printf("Unidentified axis.\n"); +#endif + + return NULL; + } +} + +int +axiom_xpath_evaluate_operation( + axiom_xpath_context_t *context, + int op) +{ + axiom_xpath_operation_t * operation; + axiom_xpath_operator_t function; + + /* Get a pointer to the operation */ + operation = AXIOM_XPATH_OPR_GET(op); + + /* Get the funciton which processes the operations */ + function = axiom_xpath_get_operator(operation); + + return function(context, operation); +} diff --git a/axiom/src/xpath/xpath_internals_engine.h b/axiom/src/xpath/xpath_internals_engine.h new file mode 100755 index 0000000..bffc8a7 --- /dev/null +++ b/axiom/src/xpath/xpath_internals_engine.h @@ -0,0 +1,265 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_XPATH_INTERNALS_ENGINE_H +#define AXIOM_XPATH_INTERNALS_ENGINE_H + +#include "xpath_internals.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_xpath_engine engine + * @ingroup axiom_xpath + * @{ + */ + + + /* Macros */ + + /** Set node->value to _value */ +#define AXIOM_XPATH_CAST_SET_VALUE(_type, _value) { \ + _type * _var; \ + if(node->value \ + && node->type != AXIOM_XPATH_TYPE_NODE \ + && node->type != AXIOM_XPATH_TYPE_ATTRIBUTE \ + && node->type != AXIOM_XPATH_TYPE_NAMESPACE) \ + { AXIS2_FREE(context->env->allocator, node->value); } \ + _var = AXIS2_MALLOC(context->env->allocator, sizeof(_type)); \ + *_var = _value; \ + node->value = (void *) _var; \ +} + + /* Functions */ + + /** + * Evaluate an XPath context, which containes a parsed expression + * + * @param context XPath context + * @return Result set + */ + axiom_xpath_result_t* axiom_xpath_run(axiom_xpath_context_t *context); + + /** + * Finds the operator function for a given operation + * + * @param op Operation + * @return Pointer to the function which process the given operation + */ + axiom_xpath_operator_t axiom_xpath_get_operator(axiom_xpath_operation_t * op); + + /** + * Get the iterotor for give axis + * + * @param axis XPath axis + * @return Pointer to the function which iterater through the given axis + */ + axiom_xpath_iterator_t axiom_xpath_get_iterator(axiom_xpath_axis_t axis); + + /* Operators */ + + /** + * Select the start node depending on whether it is an absolute or relative location path + * + * @param context XPath context + * @param op XPath operation + * @return Number of nodes added to the stack + */ + int axiom_xpath_start_node_operator(axiom_xpath_context_t *context, axiom_xpath_operation_t * op); + + /** + * Add the context node or attribute to the results stack + * + * @param context XPath context + * @param op XPath operation + * @return Number of nodes added to the stack + */ + int axiom_xpath_collect_operator(axiom_xpath_context_t *context, axiom_xpath_operation_t * op); + + /** + * Process union operator + * + * @param context XPath context + * @param op XPath operation + * @return Number of nodes added to the stack + */ + int axiom_xpath_union_operator(axiom_xpath_context_t *context, axiom_xpath_operation_t * op); + + /** + * Perform or operation + * + * @param context XPath context + * @param op XPath operation + * @return Number of nodes added to the stack; which is one + */ + int axiom_xpath_orexpr_operator(axiom_xpath_context_t *context, axiom_xpath_operation_t * op); + + /** + * Perform and operation + * + * @param context XPath context + * @param op XPath operation + * @return Number of nodes added to the stack; which is one + */ + int axiom_xpath_andexpr_operator(axiom_xpath_context_t *context, axiom_xpath_operation_t * op); + + /** + * Perform equality test operation + * + * @param context XPath context + * @param op XPath operation + * @return Number of nodes added to the stack; which is one + */ + int axiom_xpath_equalexpr_operator(axiom_xpath_context_t *context, axiom_xpath_operation_t * op); + + /** + * Evaluate function call operation + * + * @param context XPath context + * @param op XPath operation + * @return Number of nodes added to the stack; which is one + */ + int axiom_xpath_function_call_operator(axiom_xpath_context_t *context, axiom_xpath_operation_t * op); + + /** + * Evaluate argument operation + * + * @param context XPath context + * @param op XPath operation + * @return Number of nodes added to the stack; which is one + */ + int axiom_xpath_argument_operator(axiom_xpath_context_t *context, axiom_xpath_operation_t * op); + + /** + * Process a path expression + * + * @param context XPath context + * @param op XPath operation + * @return Number of nodes added to the stack + */ + int axiom_xpath_path_expression_operator(axiom_xpath_context_t *context, axiom_xpath_operation_t * op); + + /** + * Process a number; push the value to the stack + * + * @param context XPath context + * @param op XPath operation + * @return Number of nodes added to the stack; which is one + */ + int axiom_xpath_number_operator(axiom_xpath_context_t *context, axiom_xpath_operation_t * op); + + /** + * Process a literal; push the string to the stack + * + * @param context XPath context + * @param op XPath operation + * @return Number of nodes added to the stack; which is one + */ + int axiom_xpath_literal_operator(axiom_xpath_context_t *context, axiom_xpath_operation_t * op); + + + /** + * Converts an XPath result to a boolean result + * + * @param node Result + * @param context XPath context + */ + void axiom_xpath_cast_boolean(axiom_xpath_result_node_t *node, axiom_xpath_context_t *context); + + /** + * Converts an XPath result to a number + * + * @param node Result + * @param context XPath context + */ + void axiom_xpath_cast_number(axiom_xpath_result_node_t *node, axiom_xpath_context_t *context); + + /** + * Converts an XPath result to a string + * + * @param node Result + * @param context XPath context + */ + void axiom_xpath_cast_string(axiom_xpath_result_node_t *node, axiom_xpath_context_t *context); + + /* Convert a node set to boolean */ + /** + * Convert a XPath node set to boolean + * + * @param node_set Node set + * @return AXIS2_TRUE if true; AXIS2_FALSE otherwise + */ + axis2_bool_t axiom_xpath_convert_to_boolean(axutil_array_list_t *node_set, axiom_xpath_context_t *context); + + /** + * Test if two result nodes are equal + * + * @param node1 First node + * @param node2 Second node + * @param context XPath context + * @return AXIS2_TRUE if equal; AXIS2_FALSE otherwise + */ + axis2_bool_t axiom_xpath_compare_equal(axiom_xpath_result_node_t *node1, axiom_xpath_result_node_t *node2, axiom_xpath_context_t *context); + + /** + * Test if the axiom node matches node test + * + * @param context XPath context + * @param node_test Node test + * @return AXIS2_TRUE if matches; AXIS2_FALSE otherwise + */ + axis2_bool_t axiom_xpath_node_test_match(axiom_xpath_context_t *context, axiom_xpath_node_test_t *node_test); + + /** + * Evaluate if the predicate is true + * + * @param context XPath context + * @param n_nodes Number of results after evaluating the expression in the predicate + * @return AXIS2_TRUE if matches; AXIS2_FALSE otherwise + */ + axis2_bool_t axiom_xpath_evaluate_predicate_condition(axiom_xpath_context_t *context, int n_nodes); + + /** + * Evaluate if the predicate(s) is true using axiom_xpath_evaluate_predicate_condition and executes the operation op_next + * + * @param context XPath context + * @param op_next The operation to be executed if all predicates are true + * @param op_predicate Reference to predicate + * @return Number of nodes added to the stack + */ + int axiom_xpath_evaluate_predicate(axiom_xpath_context_t *context, int op_next, int op_predicate); + + /** + * Evaluate operation pointed by op + * + * @param context XPath context + * @param op The index of the operation in the operations list + * @return Number of nodes added to the stack + */ + int axiom_xpath_evaluate_operation(axiom_xpath_context_t *context, int op); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/axiom/src/xpath/xpath_internals_iterators.c b/axiom/src/xpath/xpath_internals_iterators.c new file mode 100644 index 0000000..225bea6 --- /dev/null +++ b/axiom/src/xpath/xpath_internals_iterators.c @@ -0,0 +1,588 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "xpath_internals.h" +#include "xpath_internals_engine.h" +#include "xpath_internals_iterators.h" + + +/* child */ +int +axiom_xpath_child_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes_tot = 0; + int n_nodes; + axiom_xpath_operation_t * node_test_op; + axiom_node_t *cur = NULL; + axiom_node_t *context_node = NULL; + /* For streaming */ + axiom_node_t *prev = NULL; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + cur = axiom_node_get_first_child(context->node, context->env); + + while(cur != NULL) + { + n_nodes = 0; + context->node = cur; + prev = cur; + cur = axiom_node_get_next_sibling(cur, context->env); + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes = axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + n_nodes_tot += n_nodes; + } + } + + /* Change the context node back to what it was */ + context->node = context_node; + + return n_nodes_tot; +} + +/* descendant */ +int +axiom_xpath_descendant_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes = 0; + axiom_xpath_operation_t * node_test_op; + axiom_node_t *child = NULL; + axiom_node_t *context_node = NULL; + axutil_stack_t *stack; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + + /* Setting up the stack */ + stack = axutil_stack_create(context->env); + + child = axiom_node_get_first_child(context->node, context->env); + while(child) + { + axutil_stack_push(stack, context->env, child); + child = axiom_node_get_first_child(child, context->env); + } + + /* Processing nodes */ + while(axutil_stack_size(stack, context->env) > 0) + { + child = (axiom_node_t *)axutil_stack_pop(stack, context->env); + + context->node = child; + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + + child = axiom_node_get_next_sibling(child, context->env); + while(child) + { + axutil_stack_push(stack, context->env, child); + child = axiom_node_get_first_child(child, context->env); + } + } + + context->node = context_node; + + axutil_stack_free(stack, context->env); + + return n_nodes; +} + +/* parent */ +int +axiom_xpath_parent_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes = 0; + axiom_xpath_operation_t * node_test_op; + axiom_node_t *parent = NULL; + axiom_node_t *context_node = NULL; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + + parent = axiom_node_get_parent(context->node, context->env); + + if(parent != NULL) + { + context->node = parent; + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes = axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + } + + /* Change the context node back to what it was */ + context->node = context_node; + + return n_nodes; +} + +/* ancestor axis */ +int +axiom_xpath_ancestor_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes = 0; + axiom_xpath_operation_t * node_test_op; + axiom_node_t *cur = NULL; + axiom_node_t *context_node = NULL; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + cur = axiom_node_get_parent(context->node, context->env); + + while(cur != NULL) + { + context->node = cur; + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + + cur = axiom_node_get_parent(cur, context->env); + } + + /* Change the context node back to what it was */ + context->node = context_node; + + return n_nodes; +} + +/* following-sibling axis */ +int +axiom_xpath_following_sibling_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes = 0; + axiom_xpath_operation_t * node_test_op; + axiom_node_t *cur = NULL; + axiom_node_t *context_node = NULL; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + cur = axiom_node_get_next_sibling(context->node, context->env); + + while(cur != NULL) + { + context->node = cur; + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + + cur = axiom_node_get_next_sibling(cur, context->env); + } + + /* Change the context node back to what it was */ + context->node = context_node; + + return n_nodes; +} + +/* preceding-sibling axis */ +int +axiom_xpath_preceding_sibling_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes = 0; + axiom_xpath_operation_t * node_test_op; + axiom_node_t *cur = NULL; + axiom_node_t *context_node = NULL; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + cur = axiom_node_get_previous_sibling(context->node, context->env); + + while(cur != NULL) + { + context->node = cur; + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + + cur = axiom_node_get_previous_sibling(cur, context->env); + } + + /* Change the context node back to what it was */ + context->node = context_node; + + return n_nodes; +} + +/* following */ +int +axiom_xpath_following_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes = 0; + axiom_xpath_operation_t * node_test_op; + axiom_node_t *child = NULL, *parent = NULL; + axiom_node_t *context_node = NULL; + axutil_stack_t *stack; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + + /* Setting up the stack */ + stack = axutil_stack_create(context->env); + axutil_stack_push(stack, context->env, context->node); + + parent = context->node; + + while(parent) + { + axutil_stack_push(stack, context->env, parent); + + while(axutil_stack_size(stack, context->env) > 0) + { + child = (axiom_node_t *)axutil_stack_pop(stack, context->env); + + child = axiom_node_get_next_sibling(child, context->env); + + while(child) + { + context->node = child; + if(axiom_xpath_node_test_match(context, + (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + + axutil_stack_push(stack, context->env, child); + child = axiom_node_get_first_child(child, context->env); + } + } + parent = axiom_node_get_parent(parent, context->env); + } + + /* Change the context node back to what it was */ + context->node = context_node; + + axutil_stack_free(stack, context->env); + + return n_nodes; +} + +/* preceding */ +int +axiom_xpath_preceding_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes = 0; + axiom_xpath_operation_t * node_test_op; + axiom_node_t *child = NULL, *parent = NULL; + axiom_node_t *context_node = NULL; + axutil_stack_t *stack; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + + /* Setting up the stack */ + stack = axutil_stack_create(context->env); + + parent = context->node; + + while(parent) + { + axutil_stack_push(stack, context->env, parent); + + while(axutil_stack_size(stack, context->env) > 0) + { + child = (axiom_node_t *)axutil_stack_pop(stack, context->env); + + child = axiom_node_get_previous_sibling(child, context->env); + + while(child) + { + context->node = child; + if(axiom_xpath_node_test_match(context, + (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + + axutil_stack_push(stack, context->env, child); + + child = axiom_node_get_last_child(child, context->env); + } + } + parent = axiom_node_get_parent(parent, context->env); + } + + /* Change the context node back to what it was */ + context->node = context_node; + + axutil_stack_free(stack, context->env); + + return n_nodes; +} + +/* attribute axis */ +int +axiom_xpath_attribute_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes = 0; + axiom_xpath_operation_t * node_test_op; + axiom_types_t type; + axiom_node_t *context_node = NULL; + axiom_element_t *element; + axutil_hash_t *ht; + axutil_hash_index_t *hi; + + /* void *key; + * axis2_ssize_t klen; + */ + void *attr; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + + type = axiom_node_get_node_type(context_node, context->env); + + if(type != AXIOM_ELEMENT) + { + return 0; + } + + element = axiom_node_get_data_element(context_node, context->env); + + context->node = NULL; + + ht = axiom_element_get_all_attributes(element, context->env); + + if(ht) + { + for(hi = axutil_hash_first(ht, context->env); hi; hi = axutil_hash_next(context->env, hi)) + { + attr = &context->attribute; + axutil_hash_this(hi, NULL, NULL, attr); + + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + } + } + + context->node = context_node; + context->attribute = NULL; + + return n_nodes; +} + +/* namespace axis */ +int +axiom_xpath_namespace_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes = 0; + axiom_xpath_operation_t * node_test_op; + axiom_types_t type; + axiom_node_t *context_node = NULL; + axiom_element_t *element; + axutil_hash_t *ht; + axutil_hash_index_t *hi; + + /* void *key; + * axis2_ssize_t klen; + */ + + void *ns; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + + type = axiom_node_get_node_type(context_node, context->env); + + if(type != AXIOM_ELEMENT) + { + return 0; + } + + element = axiom_node_get_data_element(context_node, context->env); + + context->node = NULL; + + ht = axiom_element_get_namespaces(element, context->env); + + if(ht) + { + for(hi = axutil_hash_first(ht, context->env); hi; hi = axutil_hash_next(context->env, hi)) + { + ns = &context->ns; + axutil_hash_this(hi, NULL, NULL, ns); + + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + } + } + + context->node = context_node; + context->ns = NULL; + + return n_nodes; +} + +/* self axis */ +int +axiom_xpath_self_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes = 0; + axiom_xpath_operation_t * node_test_op; + axiom_node_t *context_node = NULL; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + + context->node = context_node; + + return n_nodes; +} + +/* descendant-or-self axis */ +int +axiom_xpath_descendant_self_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes = 0; + axiom_xpath_operation_t * node_test_op; + axiom_node_t *child = NULL; + axiom_node_t *context_node = NULL; + axutil_stack_t *stack; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + + /* Setting up the stack */ + stack = axutil_stack_create(context->env); + + child = axiom_node_get_first_child(context->node, context->env); + while(child) + { + axutil_stack_push(stack, context->env, child); + child = axiom_node_get_first_child(child, context->env); + } + + /* Processing nodes */ + while(axutil_stack_size(stack, context->env) > 0) + { + child = (axiom_node_t *)axutil_stack_pop(stack, context->env); + + context->node = child; + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + + child = axiom_node_get_next_sibling(child, context->env); + while(child) + { + axutil_stack_push(stack, context->env, child); + child = axiom_node_get_first_child(child, context->env); + } + } + + /* Change the context node back to what it was */ + context->node = context_node; + + axutil_stack_free(stack, context->env); + + return n_nodes; +} + +/* ancestor-or-self axis */ +int +axiom_xpath_ancestor_self_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate) +{ + int n_nodes = 0; + axiom_xpath_operation_t * node_test_op; + axiom_node_t *parent = NULL; + axiom_node_t *context_node = NULL; + + AXIOM_XPATH_ITERATOR_INITIALIZE; + + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + + parent = axiom_node_get_parent(context->node, context->env); + + while(parent != NULL) + { + context->node = parent; + if(axiom_xpath_node_test_match(context, (axiom_xpath_node_test_t *)node_test_op->par1)) + { + n_nodes += axiom_xpath_evaluate_predicate(context, op_next, op_predicate); + } + + parent = axiom_node_get_parent(parent, context->env); + } + + /* Change the context node back to what it was */ + context->node = context_node; + + return n_nodes; +} diff --git a/axiom/src/xpath/xpath_internals_iterators.h b/axiom/src/xpath/xpath_internals_iterators.h new file mode 100755 index 0000000..67d06c4 --- /dev/null +++ b/axiom/src/xpath/xpath_internals_iterators.h @@ -0,0 +1,298 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_XPATH_INTERNALS_ITERATORS_H +#define AXIOM_XPATH_INTERNALS_ITERATORS_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_xpath_iterators iterators + * @ingroup axiom_xpath + * @{ + */ + + +#ifdef AXIOM_XPATH_DEBUG +#define AXIOM_XPATH_ITERATOR_INITIALIZE { \ + if(!context->node) { \ + printf("Context node NULL; cannot evaluate self or descendent axis.\n"); \ + return AXIOM_XPATH_EVALUATION_ERROR; } \ + node_test_op = AXIOM_XPATH_OPR_GET(op_node_test); \ + if(!node_test_op) { \ + printf("Node test not present.\n"); \ + return AXIOM_XPATH_EVALUATION_ERROR; } \ + context_node = context->node; \ +} +#else +#define AXIOM_XPATH_ITERATOR_INITIALIZE { \ + if(!context->node) { \ + return AXIOM_XPATH_EVALUATION_ERROR; } \ + node_test_op = AXIOM_XPATH_OPR_GET(op_node_test); \ + if(!node_test_op) { \ + return AXIOM_XPATH_EVALUATION_ERROR; } \ + context_node = context->node; \ +} +#endif + + /** + * Iterate through children + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_child_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * Iterate through descendents + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_descendant_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * Iterate through parent node. (Only one node) + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_parent_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * Iterate through ancestors + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_ancestor_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * Iterate through siblings following the context node + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_following_sibling_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * Iterate through sibling preceding the context node + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_preceding_sibling_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * Iterate through all nodes following the context node + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_following_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * Iterate through all nodes preceding the context node + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_preceding_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * Iterate through attributes + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_attribute_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * Iterate through namespaces defined in the context node + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_namespace_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * Iterate through self node (Only one node) + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_self_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * Iterate through descendents and context node + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_descendant_self_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** + * Iterate through ancestors and context node + * + * @param context XPath context + * @param op_node_test Reference to the node test operation + * in the parsed expression + * @param op_next Reference to the next step in the location path, + * in the parsed expression + * @param op_predicate Reference to the first predicate in the + * parsed expression + * @return Number of nodes added to the stack + */ + int axiom_xpath_ancestor_self_iterator( + axiom_xpath_context_t *context, + int op_node_test, + int op_next, + int op_predicate); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/axiom/src/xpath/xpath_internals_parser.c b/axiom/src/xpath/xpath_internals_parser.c new file mode 100755 index 0000000..a1ce79a --- /dev/null +++ b/axiom/src/xpath/xpath_internals_parser.c @@ -0,0 +1,1245 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "xpath_internals.h" +#include "xpath_internals_parser.h" +#include + +/* Compile an XPath expression */ +int +axiom_xpath_compile( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + if(!expr || !expr->expr_str) + { +#ifdef AXIOM_XPATH_DEBUG + printf("Expression in NULL.\n"); +#endif + + return AXIS2_FAILURE; + } + + expr->expr_len = (int)axutil_strlen(expr->expr_str); + + expr->operations = axutil_array_list_create(env, 0); + + expr->expr_ptr = 0; + + expr->start = axiom_xpath_compile_orexpr(env, expr); + + if(expr->start == AXIOM_XPATH_PARSE_ERROR) + { + axutil_array_list_free(expr->operations, env); + + return AXIOM_XPATH_PARSE_ERROR; + } + else + { +#ifdef AXIOM_XPATH_DEBUG + printf("Expression successfully parsed\n"); +#endif + + return AXIOM_XPATH_PARSE_SUCCESS; + } +} + +/* Parse Or Expression */ +int +axiom_xpath_compile_orexpr( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + int op1, op2; + + if(!AXIOM_XPATH_HAS_MORE) + { + return AXIOM_XPATH_PARSE_END; + } + + op1 = axiom_xpath_compile_andexpr(env, expr); + + if(op1 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: AndEpxr expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + AXIOM_XPATH_SKIP_WHITESPACES; + + while(AXIOM_XPATH_CURRENT == 'o' && AXIOM_XPATH_NEXT(1) == 'r') + { + AXIOM_XPATH_READ(2); + AXIOM_XPATH_SKIP_WHITESPACES; + + op2 = axiom_xpath_compile_andexpr(env, expr); + + if(op2 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: AndEpxr expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + op1 = AXIOM_XPATH_PUSH(AXIOM_XPATH_OPERATION_OR_EXPR, op1, op2); + + AXIOM_XPATH_SKIP_WHITESPACES; + } + + return op1; +} + +/* Parse And Expression */ +int +axiom_xpath_compile_andexpr( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + int op1, op2; + + if(!AXIOM_XPATH_HAS_MORE) + { + return AXIOM_XPATH_PARSE_END; + } + + op1 = axiom_xpath_compile_equalexpr(env, expr); + + if(op1 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: EqualityExpr expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + AXIOM_XPATH_SKIP_WHITESPACES; + + while(AXIOM_XPATH_CURRENT == 'a' && AXIOM_XPATH_NEXT(1) == 'n' && AXIOM_XPATH_NEXT(1) == 'd') + { + AXIOM_XPATH_READ(2); + AXIOM_XPATH_SKIP_WHITESPACES; + + op2 = axiom_xpath_compile_equalexpr(env, expr); + + if(op2 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: EqualityExpr expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + op1 = AXIOM_XPATH_PUSH(AXIOM_XPATH_OPERATION_AND_EXPR, op1, op2); + + AXIOM_XPATH_SKIP_WHITESPACES; + } + + return op1; +} + +/* Parse Equality Expression */ +int +axiom_xpath_compile_equalexpr( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + int op1, op2; + + if(!AXIOM_XPATH_HAS_MORE) + { + return AXIOM_XPATH_PARSE_END; + } + + op1 = axiom_xpath_compile_union(env, expr); + + if(op1 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: UnionExpr expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + while(AXIOM_XPATH_CURRENT == '=') + { + AXIOM_XPATH_SKIP_WHITESPACES; + AXIOM_XPATH_READ(1); + AXIOM_XPATH_SKIP_WHITESPACES; + + op2 = axiom_xpath_compile_union(env, expr); + + if(op2 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: UnionExpr expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + op1 = AXIOM_XPATH_PUSH(AXIOM_XPATH_OPERATION_EQUAL_EXPR, op1, op2); + + AXIOM_XPATH_SKIP_WHITESPACES; + } + + return op1; +} + +/* Parse Union */ +int +axiom_xpath_compile_union( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + int op1, op2; + + if(!AXIOM_XPATH_HAS_MORE) + { + return AXIOM_XPATH_PARSE_END; + } + + op1 = axiom_xpath_compile_path_expression(env, expr); + + if(op1 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: PathExpr expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + AXIOM_XPATH_SKIP_WHITESPACES; + + if(AXIOM_XPATH_CURRENT == '|') + { + AXIOM_XPATH_READ(1); + AXIOM_XPATH_SKIP_WHITESPACES; + op2 = axiom_xpath_compile_union(env, expr); + + if(op2 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: UnionExpr expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + return AXIOM_XPATH_PUSH(AXIOM_XPATH_OPERATION_UNION, op1, op2); + } + + /* Just a location path */ + return op1; +} + +/* Compile Filter expression */ +int +axiom_xpath_compile_filter( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + int op = AXIOM_XPATH_PARSE_END; + + if(AXIOM_XPATH_CURRENT == '(') + { + AXIOM_XPATH_READ(1); + op = axiom_xpath_compile_orexpr(env, expr); + AXIOM_XPATH_SKIP_WHITESPACES; + if(AXIOM_XPATH_CURRENT == ')') + { + AXIOM_XPATH_READ(1); + return op; + } + else + { + return AXIOM_XPATH_PARSE_ERROR; + } + } + else if(AXIOM_XPATH_CURRENT == '\'' || AXIOM_XPATH_CURRENT == '\"') + { + return AXIOM_XPATH_PUSH_PAR(AXIOM_XPATH_OPERATION_LITERAL, axiom_xpath_compile_literal(env, + expr), NULL, AXIOM_XPATH_PARSE_END); + } + else if(isdigit(AXIOM_XPATH_CURRENT) || (AXIOM_XPATH_CURRENT == '.' && isdigit( + AXIOM_XPATH_NEXT(1)))) + { + return AXIOM_XPATH_PUSH_PAR(AXIOM_XPATH_OPERATION_NUMBER, axiom_xpath_compile_number(env, + expr), NULL, AXIOM_XPATH_PARSE_END); + } + else if(AXIOM_XPATH_CURRENT == '$') + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: Variables are not supported, yet - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + } + else + { + return axiom_xpath_compile_function_call(env, expr); + } + +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: Invalid Filter expression - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + /* TODO: functions and variables */ +} + +/* Parse Path expression (not a location path) */ +int +axiom_xpath_path_compile_path_expression_filter( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + int op_filter, op_next; + + op_filter = axiom_xpath_compile_filter(env, expr); + + if(op_filter == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: FilterExpr expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + AXIOM_XPATH_SKIP_WHITESPACES; + + if(AXIOM_XPATH_NEXT(0) == '/' && AXIOM_XPATH_NEXT(1) == '/') + { + AXIOM_XPATH_READ(2); + + op_next = axiom_xpath_compile_relative_location(env, expr); + + if(op_next == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: RelativeLocation expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + op_next = AXIOM_XPATH_WRAP_SELF_DESCENDANT(op_next); + } + else if(AXIOM_XPATH_NEXT(0) == '/') + { + AXIOM_XPATH_READ(1); + + op_next = axiom_xpath_compile_relative_location(env, expr); + + if(op_next == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: RelativeLocation expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + } + else + { + op_next = AXIOM_XPATH_PARSE_END; + } + + return AXIOM_XPATH_PUSH(AXIOM_XPATH_OPERATION_PATH_EXPRESSION, op_filter, op_next); +} + +/* Parse Path expression */ +int +axiom_xpath_compile_path_expression( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + int temp_ptr = expr->expr_ptr; + axis2_char_t *name; + axis2_char_t *node_types[] = { "comment", "node", "processing-instruction", "text" }; + axis2_char_t filter_start[] = { '$', '\'', '\"', '(' }; + int i; + + /* if | FilterExpr + | FilterExpr '/' RelativeLocationPath + | FilterExpr '//' RelativeLocationPath */ + for(i = 0; i < 4; i++) + { + if(AXIOM_XPATH_CURRENT == filter_start[i]) + { + return axiom_xpath_path_compile_path_expression_filter(env, expr); + } + } + + if(isdigit(AXIOM_XPATH_CURRENT) || (AXIOM_XPATH_CURRENT == '.' && isdigit(AXIOM_XPATH_NEXT(1)))) + { + return axiom_xpath_path_compile_path_expression_filter(env, expr); + } + + /* Funciton calls */ + name = axiom_xpath_compile_ncname(env, expr); + AXIOM_XPATH_SKIP_WHITESPACES; + + if(name != NULL && AXIOM_XPATH_CURRENT == '(') + { + expr->expr_ptr = temp_ptr; + for(i = 0; i < 4; i++) + { + /* If node type */ + if(axutil_strcmp(name, node_types[i]) == 0) + { + return axiom_xpath_compile_location_path(env, expr); + } + } + + return axiom_xpath_path_compile_path_expression_filter(env, expr); + } + + expr->expr_ptr = temp_ptr; + + return axiom_xpath_compile_location_path(env, expr); +} + +/* Parses Location Path */ +int +axiom_xpath_compile_location_path( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + int op1; + axiom_xpath_operation_type_t opr; + + if(!AXIOM_XPATH_HAS_MORE) + { + return AXIOM_XPATH_PARSE_END; + } + + if(AXIOM_XPATH_CURRENT == '/') + { + /* Descendent */ + if(AXIOM_XPATH_NEXT(1) == '/') + { + opr = AXIOM_XPATH_OPERATION_CONTEXT_NODE; + AXIOM_XPATH_READ(2); + AXIOM_XPATH_SKIP_WHITESPACES; + + op1 = axiom_xpath_compile_relative_location(env, expr); + + if(op1 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: RelativeLocation expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + op1 = AXIOM_XPATH_WRAP_SELF_DESCENDANT(op1); + } + else + { + opr = AXIOM_XPATH_OPERATION_ROOT_NODE; + AXIOM_XPATH_READ(1); + + op1 = axiom_xpath_compile_relative_location(env, expr); + + if(op1 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: RelativeLocation expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + } + } + else + { + opr = AXIOM_XPATH_OPERATION_CONTEXT_NODE; + + op1 = axiom_xpath_compile_relative_location(env, expr); + + if(op1 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: RelativeLocation expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + } + + if(op1 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: RelativeLocation expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + return AXIOM_XPATH_PUSH(opr, op1, AXIOM_XPATH_PARSE_END); +} + +/* Parses Relative Location Path */ +int +axiom_xpath_compile_relative_location( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + int op_step, op_next; + + if(!AXIOM_XPATH_HAS_MORE) + { + return AXIOM_XPATH_PARSE_END; + } + + op_step = axiom_xpath_compile_step(env, expr); + op_next = AXIOM_XPATH_PARSE_END; /* Will change if there are more steps */ + + if(op_step == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: Step expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + AXIOM_XPATH_SKIP_WHITESPACES; + + if(AXIOM_XPATH_NEXT(0) == '/' && AXIOM_XPATH_NEXT(1) == '/') + { + AXIOM_XPATH_READ(2); + + op_next = axiom_xpath_compile_relative_location(env, expr); + + if(op_next == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: RelativeLocation expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + op_next = AXIOM_XPATH_WRAP_SELF_DESCENDANT(op_next); + } + else if(AXIOM_XPATH_NEXT(0) == '/') + { + AXIOM_XPATH_READ(1); + + op_next = axiom_xpath_compile_relative_location(env, expr); + + if(op_next == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: RelativeLocation expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + } + + /* End of the location path */ + if(op_next == AXIOM_XPATH_PARSE_END) + { + op_next = AXIOM_XPATH_PUSH(AXIOM_XPATH_OPERATION_RESULT, AXIOM_XPATH_PARSE_END, + AXIOM_XPATH_PARSE_END); + } + + return AXIOM_XPATH_PUSH(AXIOM_XPATH_OPERATION_STEP, op_step, op_next); +} + +/* Parses Step */ +int +axiom_xpath_compile_step( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + int op_predicate = AXIOM_XPATH_PARSE_END; + axiom_xpath_node_test_t *node_test; + int temp_ptr; + axis2_char_t *name = NULL; + axiom_xpath_axis_t axis = AXIOM_XPATH_AXIS_NONE; + + AXIOM_XPATH_SKIP_WHITESPACES; + + /* . and .. */ + if(AXIOM_XPATH_CURRENT == '.') + { + if(AXIOM_XPATH_NEXT(1) == '.') + { + AXIOM_XPATH_READ(2); + axis = AXIOM_XPATH_AXIS_PARENT; + } + else + { + AXIOM_XPATH_READ(1); + axis = AXIOM_XPATH_AXIS_SELF; + } + + return AXIOM_XPATH_PUSH_PAR(AXIOM_XPATH_OPERATION_NODE_TEST, + axiom_xpath_create_node_test_node(env), axiom_xpath_create_axis(env, axis), + op_predicate); + } + else if(AXIOM_XPATH_CURRENT == '@') + { + axis = AXIOM_XPATH_AXIS_ATTRIBUTE; + + AXIOM_XPATH_READ(1); + AXIOM_XPATH_SKIP_WHITESPACES; + } + else + { + temp_ptr = expr->expr_ptr; + + name = axiom_xpath_compile_ncname(env, expr); + + if(name) + { + AXIOM_XPATH_SKIP_WHITESPACES; + + /* An axis */ + if(AXIOM_XPATH_CURRENT == ':' && AXIOM_XPATH_NEXT(1) == ':') + { + axis = axiom_xpath_get_axis(env, name); + + if(axis == AXIOM_XPATH_AXIS_NONE) + { +#ifdef AXIOM_XPATH_DEBUG + printf("Parse error: Invalid axis - %s\n", name); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + AXIOM_XPATH_READ(2); + AXIOM_XPATH_SKIP_WHITESPACES; + } + else + { + axis = AXIOM_XPATH_AXIS_CHILD; + + expr->expr_ptr = temp_ptr; + } + } + else + { + axis = AXIOM_XPATH_AXIS_CHILD; + + expr->expr_ptr = temp_ptr; + } + } + + node_test = axiom_xpath_compile_node_test(env, expr); + + if(!node_test) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: NodeTest expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + op_predicate = axiom_xpath_compile_predicate(env, expr); + + if(op_predicate == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: Predicate expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + return AXIOM_XPATH_PUSH_PAR(AXIOM_XPATH_OPERATION_NODE_TEST, node_test, + axiom_xpath_create_axis(env, axis), op_predicate); +} + +axiom_xpath_node_test_t* +axiom_xpath_compile_node_test( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + axis2_char_t* name; + axiom_xpath_node_test_t *node_test; + + node_test = AXIS2_MALLOC(env->allocator, sizeof(axiom_xpath_node_test_t)); + node_test->type = AXIOM_XPATH_NODE_TEST_NONE; + node_test->prefix = NULL; + node_test->name = NULL; + node_test->lit = NULL; + + if(AXIOM_XPATH_CURRENT == '*') + { + AXIOM_XPATH_READ(1); + + node_test->type = AXIOM_XPATH_NODE_TEST_ALL; + + return node_test; + } + + name = axiom_xpath_compile_ncname(env, expr); + + if(!name) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: NCName expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + AXIS2_FREE(env->allocator, node_test); + + return NULL; + } + + /* Node type */ + + if(AXIOM_XPATH_CURRENT == '(') + { + AXIOM_XPATH_READ(1); + + if(axutil_strcmp(name, "comment") == 0) + { + node_test->type = AXIOM_XPATH_NODE_TYPE_COMMENT; + } + if(axutil_strcmp(name, "node") == 0) + { + node_test->type = AXIOM_XPATH_NODE_TYPE_NODE; + } + if(axutil_strcmp(name, "processing-instruction") == 0) + { + node_test->type = AXIOM_XPATH_NODE_TYPE_PI; + + node_test->lit = axiom_xpath_compile_literal(env, expr); + } + if(axutil_strcmp(name, "text") == 0) + { + node_test->type = AXIOM_XPATH_NODE_TYPE_TEXT; + } + + AXIOM_XPATH_SKIP_WHITESPACES; + + if(node_test->type == AXIOM_XPATH_NODE_TEST_NONE || AXIOM_XPATH_CURRENT != ')') + { +#ifdef AXIOM_XPATH_DEBUG + printf("Parse error: Invalid node type - %s\n", name); +#endif + + AXIS2_FREE(env->allocator, node_test); + + return NULL; + } + + AXIOM_XPATH_READ(1); + } + else + { + node_test->type = AXIOM_XPATH_NODE_TEST_STANDARD; + + if(AXIOM_XPATH_CURRENT == ':') + { + AXIOM_XPATH_READ(1); + + node_test->prefix = name; + + if(AXIOM_XPATH_CURRENT == '*') + { + AXIOM_XPATH_READ(1); + + node_test->type = AXIOM_XPATH_NODE_TEST_ALL; + + return node_test; + } + + node_test->name = axiom_xpath_compile_ncname(env, expr); + + if(!node_test->name) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: NCName expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + AXIS2_FREE(env->allocator, node_test); + + return NULL; + } + } + else + { + node_test->name = name; + } + } + + return node_test; +} + +int +axiom_xpath_compile_function_call( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + axis2_char_t *name; + int op1 = AXIOM_XPATH_PARSE_END; + + name = axiom_xpath_compile_ncname(env, expr); + + if(!name) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: NCName expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + if(AXIOM_XPATH_CURRENT != '(') + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: '(' expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + AXIOM_XPATH_READ(1); + + AXIOM_XPATH_SKIP_WHITESPACES; + + if(AXIOM_XPATH_CURRENT != ')') + { + op1 = axiom_xpath_compile_argument(env, expr); + } + + if(AXIOM_XPATH_CURRENT != ')') + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: ')' expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + AXIOM_XPATH_READ(1); + + return AXIOM_XPATH_PUSH_PAR(AXIOM_XPATH_OPERATION_FUNCTION_CALL, name, NULL, op1); +} + +int +axiom_xpath_compile_argument( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + int op1 = AXIOM_XPATH_PARSE_END; + int op2 = AXIOM_XPATH_PARSE_END; + + op1 = axiom_xpath_compile_orexpr(env, expr); + + AXIOM_XPATH_SKIP_WHITESPACES; + + if(AXIOM_XPATH_CURRENT == ',') + { + op2 = axiom_xpath_compile_argument(env, expr); + } + + return AXIOM_XPATH_PUSH(AXIOM_XPATH_OPERATION_ARGUMENT, op1, op2); +} + +axiom_xpath_node_test_t* +axiom_xpath_create_node_test_all( + const axutil_env_t *env) +{ + axiom_xpath_node_test_t *node_test; + + node_test = AXIS2_MALLOC(env->allocator, sizeof(axiom_xpath_node_test_t)); + node_test->type = AXIOM_XPATH_NODE_TEST_ALL; + node_test->prefix = NULL; + node_test->name = NULL; + node_test->lit = NULL; + + return node_test; +} + +axiom_xpath_node_test_t* +axiom_xpath_create_node_test_node( + const axutil_env_t *env) +{ + axiom_xpath_node_test_t *node_test; + + node_test = AXIS2_MALLOC(env->allocator, sizeof(axiom_xpath_node_test_t)); + node_test->type = AXIOM_XPATH_NODE_TYPE_NODE; + node_test->prefix = NULL; + node_test->name = NULL; + node_test->lit = NULL; + + return node_test; +} + +double* +axiom_xpath_compile_number( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + double *ret = AXIS2_MALLOC(env->allocator, sizeof(double)); + double res = 0, dec = 0.1; + axis2_bool_t dot = AXIS2_FALSE; + + *ret = 0; + + while(1) + { + if(isdigit(AXIOM_XPATH_CURRENT)) + { + if(!dot) + { + res = res * 10 + (AXIOM_XPATH_CURRENT - '0'); + } + else + { + res += dec * (AXIOM_XPATH_CURRENT - '0'); + dec /= 10; + } + } + else if(AXIOM_XPATH_CURRENT == '.') + { + if(dot) + { + return ret; + } + else + { + dot = AXIS2_TRUE; + dec = 0.1; + } + } + else + { + break; + } + + AXIOM_XPATH_READ(1); + } + + *ret = res; + return ret; +} + +axis2_char_t* +axiom_xpath_compile_literal( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + axis2_char_t lit[255]; + int i = 0; + axis2_char_t del; + + if(AXIOM_XPATH_CURRENT == '\"') + { + del = '\"'; + } + else if(AXIOM_XPATH_CURRENT == '\'') + { + del = '\''; + } + else + return NULL; + + AXIOM_XPATH_READ(1); + + while(AXIOM_XPATH_HAS_MORE && AXIOM_XPATH_CURRENT != del) + { + lit[i] = AXIOM_XPATH_CURRENT; + AXIOM_XPATH_READ(1); + ++i; + } + + if(AXIOM_XPATH_HAS_MORE) + { + AXIOM_XPATH_READ(1); + } + + lit[i] = '\0'; + + return axutil_strdup(env, lit); + +} + +/* Get axis for name */ +axiom_xpath_axis_t +axiom_xpath_get_axis( + const axutil_env_t *env, + axis2_char_t* name) +{ + if(axutil_strcmp(name, "child") == 0) + { + return AXIOM_XPATH_AXIS_CHILD; + } + else if(axutil_strcmp(name, "descendant") == 0) + { + return AXIOM_XPATH_AXIS_DESCENDANT; + } + else if(axutil_strcmp(name, "parent") == 0) + { + return AXIOM_XPATH_AXIS_PARENT; + } + else if(axutil_strcmp(name, "ancestor") == 0) + { + return AXIOM_XPATH_AXIS_ANCESTOR; + } + else if(axutil_strcmp(name, "following-sibling") == 0) + { + return AXIOM_XPATH_AXIS_FOLLOWING_SIBLING; + } + else if(axutil_strcmp(name, "preceding-sibling") == 0) + { + return AXIOM_XPATH_AXIS_PRECEDING_SIBLING; + } + else if(axutil_strcmp(name, "following") == 0) + { + return AXIOM_XPATH_AXIS_FOLLOWING; + } + else if(axutil_strcmp(name, "preceding") == 0) + { + return AXIOM_XPATH_AXIS_PRECEDING; + } + else if(axutil_strcmp(name, "attribute") == 0) + { + return AXIOM_XPATH_AXIS_ATTRIBUTE; + } + else if(axutil_strcmp(name, "namespace") == 0) + { + return AXIOM_XPATH_AXIS_NAMESPACE; + } + else if(axutil_strcmp(name, "self") == 0) + { + return AXIOM_XPATH_AXIS_SELF; + } + else if(axutil_strcmp(name, "descendant-or-self") == 0) + { + return AXIOM_XPATH_AXIS_DESCENDANT_OR_SELF; + } + else if(axutil_strcmp(name, "ancestor-or-self") == 0) + { + return AXIOM_XPATH_AXIS_ANCESTOR_OR_SELF; + } + else + { +#ifdef AXIOM_XPATH_DEBUG + printf("Unidentified axis name.\n"); +#endif + + return AXIOM_XPATH_AXIS_NONE; + } +} + +/* Parse Predicate */ +int +axiom_xpath_compile_predicate( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + int op1, op_next_predicate; + + AXIOM_XPATH_SKIP_WHITESPACES; + + if(!AXIOM_XPATH_HAS_MORE || AXIOM_XPATH_CURRENT != '[') + { + return AXIOM_XPATH_PARSE_END; + } + + AXIOM_XPATH_READ(1); + AXIOM_XPATH_SKIP_WHITESPACES; + + /* A PredicateExpr is evaluated by evaluating the Expr and converting the result to a boolean. + If the result is a number, the result will be converted to true if the number is equal to the + context position and will be converted to false otherwise; if the result is not a number, + then the result will be converted as if by a call to the boolean function. */ + + op1 = axiom_xpath_compile_orexpr(env, expr); + + if(op1 == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: EqualExpr expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + AXIOM_XPATH_SKIP_WHITESPACES; + + if(AXIOM_XPATH_CURRENT != ']') + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: ] expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + AXIOM_XPATH_READ(1); + + op_next_predicate = axiom_xpath_compile_predicate(env, expr); + + if(op_next_predicate == AXIOM_XPATH_PARSE_ERROR) + { +#ifdef AXIOM_XPATH_DEBUG + printf( + "Parse error: Predicate expected - %s\n", + expr->expr_str + expr->expr_ptr); +#endif + + return AXIOM_XPATH_PARSE_ERROR; + } + + return AXIOM_XPATH_PUSH(AXIOM_XPATH_OPERATION_PREDICATE, op1, op_next_predicate); +} + +/* Parse Node Test */ +axis2_char_t * +axiom_xpath_compile_ncname( + const axutil_env_t *env, + axiom_xpath_expression_t* expr) +{ + axis2_char_t name[255]; + int i = 0; + + if(!isalpha(AXIOM_XPATH_CURRENT) && AXIOM_XPATH_CURRENT != '_') + { + return NULL; + } + + /* TODO: Add CombiningChar and Extender + * Link http://www.w3.org/TR/REC-xml/#NT-NameChar */ + while(AXIOM_XPATH_HAS_MORE && (isalnum(AXIOM_XPATH_CURRENT) || AXIOM_XPATH_CURRENT == '_' + || AXIOM_XPATH_CURRENT == '.' || AXIOM_XPATH_CURRENT == '-')) + { + name[i] = AXIOM_XPATH_CURRENT; + AXIOM_XPATH_READ(1); + ++i; + } + + name[i] = '\0'; + + return axutil_strdup(env, name); +} + +/* Supporting functions */ +int +axiom_xpath_add_operation( + const axutil_env_t *env, + axiom_xpath_expression_t* expr, + axiom_xpath_operation_type_t op_type, + int op1, + int op2, + void *par1, + void *par2) +{ + axiom_xpath_operation_t *op; + + op = AXIS2_MALLOC(env->allocator, sizeof(axiom_xpath_operation_t)); + op->opr = op_type; + op->op1 = op1; + op->op2 = op2; + + op->pos = 0; + + op->par1 = par1; + op->par2 = par2; + + axutil_array_list_add(expr->operations, env, op); + + return axutil_array_list_size(expr->operations, env) - 1; +} + +axiom_xpath_axis_t * +axiom_xpath_create_axis( + const axutil_env_t *env, + axiom_xpath_axis_t axis) +{ + axiom_xpath_axis_t *axis_p = AXIS2_MALLOC(env->allocator, sizeof(axiom_xpath_axis_t)); + + *axis_p = axis; + return axis_p; +} diff --git a/axiom/src/xpath/xpath_internals_parser.h b/axiom/src/xpath/xpath_internals_parser.h new file mode 100755 index 0000000..7d1a2d0 --- /dev/null +++ b/axiom/src/xpath/xpath_internals_parser.h @@ -0,0 +1,421 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_XPATH_INTERNALS_PARSER_H +#define AXIOM_XPATH_INTERNALS_PARSER_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_xpath_parser parser + * @ingroup axiom_xpath + * @{ + */ + + + /* Macros */ + + /** Get the current character in the expression */ +#define AXIOM_XPATH_CURRENT (expr->expr_ptr < expr->expr_len ? \ + expr->expr_str[expr->expr_ptr] : -1) + + /** Get a character after the current */ +#define AXIOM_XPATH_NEXT(ind) (expr->expr_ptr + ind < expr->expr_len ? \ + expr->expr_str[expr->expr_ptr + ind] : -1) + + /** Increment the pointer to the expression */ +#define AXIOM_XPATH_READ(n) (expr->expr_ptr += n) + + /** Check if expression has finished parsing */ +#define AXIOM_XPATH_HAS_MORE (expr->expr_ptr < expr->expr_len) + + /** Skip white spaces */ +#define AXIOM_XPATH_SKIP_WHITESPACES \ + { while(AXIOM_XPATH_CURRENT == ' ') \ + AXIOM_XPATH_READ(1); \ + } + + /** Wrape an operation in a self_or_descendent step; used to handle '//' */ +#define AXIOM_XPATH_WRAP_SELF_DESCENDANT(_op2) \ + axiom_xpath_add_operation(env, expr, AXIOM_XPATH_OPERATION_STEP, \ + axiom_xpath_add_operation(env, expr, AXIOM_XPATH_OPERATION_NODE_TEST, \ + AXIOM_XPATH_PARSE_END, AXIOM_XPATH_PARSE_END, \ + axiom_xpath_create_node_test_node(env), \ + axiom_xpath_create_axis(env, AXIOM_XPATH_AXIS_DESCENDANT_OR_SELF)), \ + _op2, NULL, NULL) + + /** Adds an operation */ +#define AXIOM_XPATH_PUSH(_opr, _op1, _op2) axiom_xpath_add_operation( \ + env, expr, _opr, _op1, _op2, NULL, NULL) + + /** Adds an operation with parameters */ +#define AXIOM_XPATH_PUSH_PAR(_opr, _par1, _par2, _op1) axiom_xpath_add_operation( \ + env, expr, _opr, _op1, AXIOM_XPATH_PARSE_END, (void *)_par1, (void *)_par2) + + /* Functions */ + + /** + * Add an operation to the operations array + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @param op_type Type of the operation + * @param op1 First operand + * @param op2 Second operand + * @param par1 First parameter + * @param par2 Second parameter + * @return Index of the operation in the array + */ + int axiom_xpath_add_operation( + const axutil_env_t *env, + axiom_xpath_expression_t* expr, + axiom_xpath_operation_type_t op_type, + int op1, + int op2, + void *par1, + void *par2); + + /** + * Compile a XPath expression + * + * [14] Expr ::= OrExpr + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the main operation in the array + */ + int axiom_xpath_compile( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compile an equals expression + * + * ***Not completed*** + * [23] EqualityExpr ::= UnionExpr '=' UnionExpr + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_compile_equalexpr( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compile an union + * + * [18] UnionExpr ::= PathExpr + * | UnionExpr '|' PathExpr + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_compile_union( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compile a path expression + * + * [19] PathExpr ::= LocationPath + * | FilterExpr + * | FilterExpr '/' RelativeLocationPath + * | FilterExpr '//' RelativeLocationPath + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_compile_path_expression( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compile a path expression with a filter + * + * [19] PathExpr ::= FilterExpr + * | FilterExpr '/' RelativeLocationPath + * | FilterExpr '//' RelativeLocationPath + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_path_compile_path_expression_filter( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compile a filter expression + * + * 20] FilterExpr ::= PrimaryExpr + * | FilterExpr Predicate + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_compile_filter( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compile a location path + * + * [1] LocationPath ::= RelativeLocationPath + * | AbsoluteLocationPath + * [2] AbsoluteLocationPath ::= '/' RelativeLocationPath? + * | AbbreviatedAbsoluteLocationPath + * + * [10] AbbreviatedAbsoluteLocationPath ::= '//' RelativeLocationPath + * [11] AbbreviatedRelativeLocationPath ::= RelativeLocationPath '//' Step + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_compile_location_path( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compile a relative location + * + * [3] RelativeLocationPath ::= Step + * | RelativeLocationPath '/' Step + * | AbbreviatedRelativeLocationPath + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_compile_relative_location( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compile a step + * + * [4] Step ::= AxisSpecifier NodeTest Predicate* + * | AbbreviatedStep + * [5] AxisSpecifier ::= AxisName '::' + * | AbbreviatedAxisSpecifier + * + * [12] AbbreviatedStep ::= '.' | '..' + * [13] AbbreviatedAxisSpecifier ::= '@'? + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_compile_step( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compiles an OrExpr. + * + * [21] OrExpr ::= AndExpr + * | OrExpr 'or' AndExpr + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_compile_orexpr( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compiles an AndExpr. + * + * [22] AndExpr ::= EqualityExpr + * | AndExpr 'and' EqualityExpr + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_compile_andexpr( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + + /** + * Compiles a FunctionCall + * + * [16] FunctionCall ::= FunctionName '(' ( Argument ( ',' Argument )* )? ')' + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_compile_function_call( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compiles an Argument. + * + * [17] Argument ::= Expr + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_compile_argument( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compile a node test + * + * [7] NodeTest ::= NameTest + * | NodeType '(' ')' + * | 'processing-instruction' '(' Literal ')' + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + axiom_xpath_node_test_t* axiom_xpath_compile_node_test( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compile a predicate(s) + * + * [8] Predicate ::= '[' PredicateExpr ']' + * [9] PredicateExpr ::= Expr + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return Index of the operation in the array + */ + int axiom_xpath_compile_predicate( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + + + /** + * Compile a literal + * + * [29] Literal ::= '"' [^"]* '"' + * | "'" [^']* "'" + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return The literal parsed + */ + axis2_char_t* axiom_xpath_compile_literal( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compile a number + * + * [30] Number ::= Digits ('.' Digits?)? + * | '.' Digits + * [31] Digits ::= [0-9]+ + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return The number parsed + */ + double* axiom_xpath_compile_number( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + /** + * Compile a ncname + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @return The ncname parsed + */ + axis2_char_t* axiom_xpath_compile_ncname( + const axutil_env_t *env, + axiom_xpath_expression_t* expr); + + + + /** + * Get the XPath axis by axis name + * + * [6] AxisName ::= 'ancestor' + * | 'ancestor-or-self' + * | 'attribute' + * | 'child' + * | 'descendant' + * | 'descendant-or-self' + * | 'following' + * | 'following-sibling' + * | 'namespace' + * | 'parent' + * | 'preceding' + * | 'preceding-sibling' + * | 'self' + * + * @param env Environment must not be null + * @param name Name of the axis + * @return XPath axis; returns AXIOM_XPATH_AXIS_NONE if invalid name + */ + axiom_xpath_axis_t axiom_xpath_get_axis( + const axutil_env_t *env, + axis2_char_t* name); + + /** + * Create a node test which matches all nodes (*) + * + * @param env Environment must not be null + * @return Node test + */ + axiom_xpath_node_test_t* axiom_xpath_create_node_test_all( + const axutil_env_t *env); + + /** + * Create a node test which matches all nodes (nodes()) + * + * @param env Environment must not be null + * @return Node test + */ + axiom_xpath_node_test_t* axiom_xpath_create_node_test_node( + const axutil_env_t *env); + + /** + * Create a pointer to an axis; allocate memory using the allocator + * + * @param env Environment must not be null + * @param axis XPath axis + * @return Pointer to the axis created + */ + axiom_xpath_axis_t *axiom_xpath_create_axis( + const axutil_env_t *env, + axiom_xpath_axis_t axis); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/axiom/src/xpath/xpath_streaming.c b/axiom/src/xpath/xpath_streaming.c new file mode 100755 index 0000000..0488d5f --- /dev/null +++ b/axiom/src/xpath/xpath_streaming.c @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "xpath_streaming.h" +#include "xpath_internals.h" +#include "xpath_internals_engine.h" + +axiom_xpath_streaming_t +axiom_xpath_streaming_check_operation( + const axutil_env_t *env, + axiom_xpath_expression_t* expr, + int op_p) +{ + axiom_xpath_operation_t *op; + + if(op_p == AXIOM_XPATH_PARSE_END) + { + return AXIOM_XPATH_STREAMING_CONSTANT; + } + + op = AXIOM_XPATH_OPR_EXPR_GET(op_p); + + switch(op->opr) + { + case AXIOM_XPATH_OPERATION_CONTEXT_NODE: + case AXIOM_XPATH_OPERATION_ROOT_NODE: + return axiom_xpath_streaming_combine_dependent(AXIOM_XPATH_CHECK(op->op1), + AXIOM_XPATH_STREAMING_CONSTANT); + + case AXIOM_XPATH_OPERATION_STEP: + return axiom_xpath_streaming_combine_dependent(AXIOM_XPATH_CHECK(op->op1), + AXIOM_XPATH_CHECK(op->op2)); + + case AXIOM_XPATH_OPERATION_RESULT: + return AXIOM_XPATH_STREAMING_CONSTANT; + + case AXIOM_XPATH_OPERATION_UNION: + return axiom_xpath_streaming_combine_independent(AXIOM_XPATH_CHECK(op->op1), + AXIOM_XPATH_CHECK(op->op2)); + + case AXIOM_XPATH_OPERATION_EQUAL_EXPR: + return axiom_xpath_streaming_combine_independent(AXIOM_XPATH_CHECK(op->op1), + AXIOM_XPATH_CHECK(op->op2)); + + case AXIOM_XPATH_OPERATION_LITERAL: + return AXIOM_XPATH_STREAMING_CONSTANT; + + case AXIOM_XPATH_OPERATION_NUMBER: + return AXIOM_XPATH_STREAMING_CONSTANT; + + case AXIOM_XPATH_OPERATION_PATH_EXPRESSION: + return axiom_xpath_streaming_combine_dependent(AXIOM_XPATH_CHECK(op->op1), + AXIOM_XPATH_CHECK(op->op2)); + + case AXIOM_XPATH_OPERATION_NODE_TEST: + return axiom_xpath_streaming_check_node_test(env, expr, op); + + case AXIOM_XPATH_OPERATION_PREDICATE: + return axiom_xpath_streaming_check_predicate(env, expr, op_p); + + default: +#ifdef AXIOM_XPATH_DEBUG + printf("Unidentified operation.\n"); +#endif + + return AXIOM_XPATH_STREAMING_NOT_SUPPORTED; + } +} + +axiom_xpath_streaming_t +axiom_xpath_streaming_check_predicate( + const axutil_env_t *env, + axiom_xpath_expression_t* expr, + int op_p) +{ + axiom_xpath_operation_t *op; + + if(op_p == AXIOM_XPATH_PARSE_END) + { + return AXIOM_XPATH_STREAMING_CONSTANT; + } + + op = AXIOM_XPATH_OPR_EXPR_GET(op_p); + + return axiom_xpath_streaming_combine_dependent(AXIOM_XPATH_CHECK(op->op1), AXIOM_XPATH_CHECK( + op->op2)); +} + +axiom_xpath_streaming_t +axiom_xpath_streaming_check_node_test( + const axutil_env_t *env, + axiom_xpath_expression_t* expr, + axiom_xpath_operation_t *op) +{ + axiom_xpath_axis_t axis = AXIOM_XPATH_AXIS_NONE; + axiom_xpath_streaming_t r; + + if(!op->par2) + { +#ifdef AXIOM_XPATH_DEBUG + printf("axis is NULL in the step operator\n"); +#endif + return AXIOM_XPATH_STREAMING_NOT_SUPPORTED; + } + + axis = *((axiom_xpath_axis_t *)op->par2); + + switch(axis) + { + case AXIOM_XPATH_AXIS_ATTRIBUTE: + case AXIOM_XPATH_AXIS_CHILD: + break; + + default: + return AXIOM_XPATH_STREAMING_NOT_SUPPORTED; + } + + r = axiom_xpath_streaming_check_predicate(env, expr, op->op1); + + if(r != AXIOM_XPATH_STREAMING_ATTRIBUTE && r != AXIOM_XPATH_STREAMING_CONSTANT) + { + return AXIOM_XPATH_STREAMING_NOT_SUPPORTED; + } + + if(axis == AXIOM_XPATH_AXIS_ATTRIBUTE) + { + return AXIOM_XPATH_STREAMING_ATTRIBUTE; + } + else + { + return AXIOM_XPATH_STREAMING_SUPPORTED; + } +} + +axiom_xpath_streaming_t +axiom_xpath_streaming_combine_dependent( + axiom_xpath_streaming_t r1, + axiom_xpath_streaming_t r2) +{ + if(r1 == AXIOM_XPATH_STREAMING_NOT_SUPPORTED || r2 == AXIOM_XPATH_STREAMING_NOT_SUPPORTED) + { + return AXIOM_XPATH_STREAMING_NOT_SUPPORTED; + } + else if(r1 == AXIOM_XPATH_STREAMING_SUPPORTED || r2 == AXIOM_XPATH_STREAMING_SUPPORTED) + { + return AXIOM_XPATH_STREAMING_SUPPORTED; + } + else if(r1 == AXIOM_XPATH_STREAMING_ATTRIBUTE || r2 == AXIOM_XPATH_STREAMING_ATTRIBUTE) + { + return AXIOM_XPATH_STREAMING_ATTRIBUTE; + } + else + { + return AXIOM_XPATH_STREAMING_CONSTANT; + } +} + +axiom_xpath_streaming_t +axiom_xpath_streaming_combine_independent( + axiom_xpath_streaming_t r1, + axiom_xpath_streaming_t r2) +{ + if(r1 == AXIOM_XPATH_STREAMING_NOT_SUPPORTED || r2 == AXIOM_XPATH_STREAMING_NOT_SUPPORTED) + { + return AXIOM_XPATH_STREAMING_NOT_SUPPORTED; + } + else if(r1 == AXIOM_XPATH_STREAMING_CONSTANT || r2 == AXIOM_XPATH_STREAMING_CONSTANT) + { + if(r1 == AXIOM_XPATH_STREAMING_SUPPORTED || r2 == AXIOM_XPATH_STREAMING_SUPPORTED) + { + return AXIOM_XPATH_STREAMING_SUPPORTED; + } + else if(r1 == AXIOM_XPATH_STREAMING_ATTRIBUTE || r2 == AXIOM_XPATH_STREAMING_ATTRIBUTE) + { + return AXIOM_XPATH_STREAMING_ATTRIBUTE; + } + else + { + return AXIOM_XPATH_STREAMING_CONSTANT; + } + } + else if(r1 == AXIOM_XPATH_STREAMING_ATTRIBUTE || r2 == AXIOM_XPATH_STREAMING_ATTRIBUTE) + { + if(r1 == AXIOM_XPATH_STREAMING_SUPPORTED || r2 == AXIOM_XPATH_STREAMING_SUPPORTED) + { + return AXIOM_XPATH_STREAMING_SUPPORTED; + } + else + { + return AXIOM_XPATH_STREAMING_ATTRIBUTE; + } + } + else + { + return AXIOM_XPATH_STREAMING_NOT_SUPPORTED; + } +} + diff --git a/axiom/src/xpath/xpath_streaming.h b/axiom/src/xpath/xpath_streaming.h new file mode 100755 index 0000000..63b1ee5 --- /dev/null +++ b/axiom/src/xpath/xpath_streaming.h @@ -0,0 +1,126 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AXIOM_XPATH_STREAMING_H +#define AXIOM_XPATH_STREAMING_H + +#include "xpath_internals.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * @defgroup axiom_xpath_streaming streaming + * @ingroup axiom_xpath + * @{ + */ + + + /** + * XPath streaming support + */ + typedef enum axiom_xpath_streaming_t + { + AXIOM_XPATH_STREAMING_NOT_SUPPORTED = 0, + AXIOM_XPATH_STREAMING_SUPPORTED, + AXIOM_XPATH_STREAMING_CONSTANT, + AXIOM_XPATH_STREAMING_ATTRIBUTE + } axiom_xpath_streaming_t; + + /** Check whether the given expression is supported on streaming XML */ +#define AXIOM_XPATH_CHECK(op) axiom_xpath_streaming_check_operation(env, expr, op) + + /** Get an operation from the list of operations */ +#define AXIOM_XPATH_OPR_EXPR_GET(ind) (axiom_xpath_operation_t *) \ + axutil_array_list_get(expr->operations, env, ind) + + /** + * Checks whether the given expression is supported on streaming XML + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @param op_p Index of the operation in the list of operations + * @return Whether the given operation can be evaluated on streaming XML + */ + axiom_xpath_streaming_t axiom_xpath_streaming_check_operation( + const axutil_env_t *env, + axiom_xpath_expression_t* expr, + int op_p); + + /** + * Checks whether the predicate is supported on streaming XML. + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @param op_p Index of the operation in the list of operations + * @return Whether the given operation can be evaluated on streaming XML + */ + axiom_xpath_streaming_t axiom_xpath_streaming_check_predicate( + const axutil_env_t *env, + axiom_xpath_expression_t* expr, + int op_p); + + /** + * Checks whether the predicate is supported on streaming XML. + * + * @param env Environment must not be null + * @param expr A pointer to the XPath expression + * @param op Index of the operation in the list of operations + * @return Whether the given operation can be evaluated on streaming XML + */ + axiom_xpath_streaming_t axiom_xpath_streaming_check_node_test( + const axutil_env_t *env, + axiom_xpath_expression_t* expr, + axiom_xpath_operation_t* op); + + + /** + * Checks whether the two operations can be evaluated on streaming XML + * sequencially (one after the other), where the result of the first + * operation is the context of the next + * + * @param r1 Type of first operation + * @param r2 Type of second operation + * @return Whether the given operations can be evaluated on streaming XML + */ + axiom_xpath_streaming_t axiom_xpath_streaming_combine_dependent( + axiom_xpath_streaming_t r1, + axiom_xpath_streaming_t r2); + + + /** + * Checks whether the two operations can be evaluated on streaming XML + * simultaneousy + * + * @param r1 Type of first operation + * @param r2 Type of second operation + * @return Whether the given operations can be evaluated on streaming XML + */ + axiom_xpath_streaming_t axiom_xpath_streaming_combine_independent( + axiom_xpath_streaming_t r1, + axiom_xpath_streaming_t r2); + + /** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/axiom/test/Makefile.am b/axiom/test/Makefile.am new file mode 100644 index 0000000..5a5b493 --- /dev/null +++ b/axiom/test/Makefile.am @@ -0,0 +1,3 @@ +TESTS = +SUBDIRS = om soap util xpath +EXTRA_DIST = resources diff --git a/axiom/test/om/Makefile.am b/axiom/test/om/Makefile.am new file mode 100644 index 0000000..7736221 --- /dev/null +++ b/axiom/test/om/Makefile.am @@ -0,0 +1,13 @@ +TESTS = +noinst_PROGRAMS = test_om +check_PROGRAMS = test_om +SUBDIRS = +AM_CFLAGS = -g -O2 -pthread +test_om_SOURCES = test_om.c + +test_om_LDADD = ../../../util/src/libaxutil.la \ + $(top_builddir)/src/om/libaxis2_axiom.la + +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/src/parser \ + -I ../../../util/include diff --git a/axiom/test/om/test_om.c b/axiom/test/om/test_om.c new file mode 100644 index 0000000..c0d41b9 --- /dev/null +++ b/axiom/test/om/test_om.c @@ -0,0 +1,402 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + Define the environment related variables globally so that they are available + for both functions +*/ + +axutil_allocator_t *allocator = NULL; +axutil_env_t *environment = NULL; +axutil_stream_t *stream = NULL; +axutil_error_t *error = NULL; +axutil_log_t *axis_log = NULL; +FILE *f = NULL; + +/** a method that demonstrate creating a om model using an xml file */ + +int AXIS2_CALL +read_input( + char *buffer, + int size, + void *ctx) +{ + int len = 0; + char *pos = NULL; + len = fread(buffer, sizeof(char), size, f); + if (buffer) + pos = strstr(buffer, "---"); + if (pos) + { + len = pos - buffer; + *pos = '\0'; + } + return len; +} + +int +test_om_build( + const char *filename) +{ + axiom_element_t *ele1 = NULL, + *ele2 = NULL; + axiom_stax_builder_t *builder = NULL; + axiom_text_t *text = NULL; + axiom_document_t *document = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL; + axiom_node_t *node3 = NULL; + axiom_output_t *om_output = NULL; + axiom_namespace_t *ns = NULL; + axiom_xml_reader_t *reader = NULL; + axiom_xml_writer_t *writer = NULL; + + char *buffer = NULL; + axutil_hash_t* hash = NULL; + + printf("\nstart test_om_build\n"); + + f = fopen(filename, "r"); + if (!f) + return -1; + + /** create pull parser */ + reader = + axiom_xml_reader_create_for_io(environment, read_input, NULL, NULL, + NULL); + + if (!reader) + { + printf("ERROR CREATING PULLPARSER"); + return -1; + } + + /** create axiom_stax_builder by parsing pull_parser struct */ + + builder = axiom_stax_builder_create(environment, reader); + + if (!builder) + { + printf("ERROR CREATING PULL PARSER"); + return -1; + } + + /** + create an om document + document is the container of om model created using builder + */ + + document = axiom_stax_builder_get_document(builder, environment); + + /** + get root element , building starts hear + */ + if (!document) + return -1; + + node1 = axiom_document_get_root_element(document, environment); + if (!node1) + { + printf(" root element null "); + axiom_stax_builder_free(builder, environment); + return -1; + } + if (node1) + { + + /** print root node information */ + + ele1 = axiom_node_get_data_element(node1, environment); + if (ele1) + { + printf("root localname %s\n", + axiom_element_get_localname(ele1, environment)); + + hash = axiom_element_get_all_attributes(ele1,environment); + if(hash) + { + axutil_hash_index_t *hi; + const void *key= NULL; + void *val = NULL; + for (hi = axutil_hash_first(hash,environment); hi; hi = axutil_hash_next(environment, hi)) + { + axutil_hash_this(hi, &key, NULL,&val); + if(val) + { + printf(" Attribute name: %s", + axiom_attribute_get_localname((axiom_attribute_t *)val,environment)); + printf(" value: %s\n", + axiom_attribute_get_value((axiom_attribute_t *)val,environment)); + } + } + } + } + + ns = axiom_element_get_namespace(ele1, environment, node1); + + if (ns) + { + printf("root ns prefix %s\n", + axiom_namespace_get_prefix(ns, environment)); + printf("root ns uri %s\n", + axiom_namespace_get_uri(ns, environment)); + printf("============================================="); + + } + else + printf("============================================="); + + } + + /** build the document continuously untill all the xml file is built in to a om model */ + + node2 = axiom_document_build_next(document, environment); + do + { + + if (!node2) + break; + + switch (axiom_node_get_node_type(node2, environment)) + { + case AXIOM_ELEMENT: + ele2 = + (axiom_element_t *) axiom_node_get_data_element(node2, + environment); + printf("============================================="); + if (ele2 && axiom_element_get_localname(ele2, environment)) + { + printf("\n localname %s\n", + axiom_element_get_localname(ele2, environment)); + hash = axiom_element_get_all_attributes(ele2,environment); + if(hash) + { + axutil_hash_index_t *hi; + const void *key= NULL; + void *val = NULL; + for (hi = axutil_hash_first(hash,environment); hi; hi = axutil_hash_next(environment, hi)) + { + axutil_hash_this(hi, &key, NULL,&val); + if(val) + { + printf(" Attribute name: %s", + axiom_attribute_get_localname((axiom_attribute_t *)val,environment)); + printf(" value: %s\n", + axiom_attribute_get_value((axiom_attribute_t *)val,environment)); + } + } + } + + } + + + + if (!node3) + node3 = node2; + + break; + case AXIOM_TEXT: + + text = + (axiom_text_t *) axiom_node_get_data_element(node2, + environment); + if (text && axiom_text_get_value(text, environment)) + printf("\n text value %s \n", + axiom_text_get_value(text, environment)); + break; + + default: + break; + } + + node2 = axiom_document_build_next(document, environment); + } + while (node2); + printf("END: pull document\n"); + + printf("Serialize pulled document\n"); + + writer = + axiom_xml_writer_create_for_memory(environment, NULL, AXIS2_TRUE, 0, + AXIS2_XML_PARSER_TYPE_BUFFER); + om_output = axiom_output_create(environment, writer); + + axiom_node_serialize_sub_tree(node3, environment, om_output); + + buffer = (axis2_char_t *) axiom_xml_writer_get_xml(writer, environment); + + if (buffer) + printf("Sub Tree = %s\n", buffer); + + axiom_output_free(om_output, environment); + + axiom_stax_builder_free(builder, environment); + +/* if (buffer) */ + +/* AXIS2_FREE(environment->allocator, buffer); */ + printf("\nend test_om_build\n"); + fclose(f); + return 0; +} + +int +test_om_serialize( + ) +{ + + /* + + Axis2/C OM HOWTO + 1748491379 + + +

+ This is vey good book on OM! +

+
+
+ */ + int status; + axiom_element_t *ele1 = NULL, + *ele2 = NULL, + *ele3 = NULL, + *ele4 = NULL; + axiom_node_t *node1 = NULL, + *node2 = NULL, + *node3 = NULL, + *node4 = NULL, + *node5 = NULL, + *node6 = NULL; + axiom_data_source_t *data_source = NULL; + axutil_stream_t *stream = NULL; + axiom_attribute_t *attr1 = NULL, + *attr2 = NULL; + axiom_namespace_t *ns1 = NULL, + *ns2 = NULL; + axiom_text_t *text1 = NULL; + axiom_output_t *om_output = NULL; + axiom_xml_writer_t *writer = NULL; + axis2_char_t *output_buffer = NULL; + + printf("\nstart test_om_serialize\n"); + + ns1 = + axiom_namespace_create(environment, + "http://ws.apache.org/axis2/c/om", "axiom"); + ns2 = axiom_namespace_create(environment, "urn:ISBN:0-395-74341-6", "isbn"); + ele1 = axiom_element_create(environment, NULL, "book", ns1, &node1); + axiom_element_declare_namespace(ele1, environment, node1, ns2); + + ele2 = axiom_element_create(environment, node1, "title", ns1, &node2); + attr1 = axiom_attribute_create(environment, "title22", NULL, NULL); + + axiom_element_add_attribute(ele2, environment, attr1, node2); + + text1 = axiom_text_create(environment, node2, "Axis2/C OM HOWTO", &node3); + + ele3 = axiom_element_create(environment, node1, "number", ns2, &node4); + + text1 = axiom_text_create(environment, node4, "1748491379", &node5); + + ele4 = axiom_element_create(environment, node1, "author", ns1, &node6); + + attr1 = axiom_attribute_create(environment, "title", "Mr", ns1); + + axiom_element_add_attribute(ele4, environment, attr1, node6); + + attr2 = axiom_attribute_create(environment, "name", "Axitoc Oman", ns1); + + axiom_element_add_attribute(ele4, environment, attr2, node6); + + data_source = axiom_data_source_create(environment, node1, &node6); + stream = axiom_data_source_get_stream(data_source, environment); + if (stream) + { + axutil_stream_write(stream, environment, + "is a test", + axutil_strlen + ("is a test")); + } + + /* serializing stuff */ + writer = + axiom_xml_writer_create_for_memory(environment, NULL, AXIS2_TRUE, 0, + AXIS2_XML_PARSER_TYPE_BUFFER); + om_output = axiom_output_create(environment, writer); + + printf("Serialize built document\n"); + status = axiom_node_serialize(node1, environment, om_output); + if (status != AXIS2_SUCCESS) + { + printf("\naxiom_node_serialize failed\n"); + return status; + } + else + printf("\naxiom_node_serialize success\n"); + /* end serializing stuff */ + + axiom_node_free_tree(node1, environment); + output_buffer = + (axis2_char_t *) axiom_xml_writer_get_xml(writer, environment); + + axiom_output_free(om_output, environment); + /* if (output_buffer) */ + /* { */ + /* printf("%s", output_buffer); */ + /* AXIS2_FREE(environment->allocator, output_buffer); */ + /* } */ + + printf("\nend test_om_serialize\n"); + + return 0; +} + +int +main( + int argc, + char *argv[]) + { + const char *file_name = "../../resources/xml/om/test.xml"; + if (argc > 1) + file_name = argv[1]; + allocator = axutil_allocator_init(NULL); + axis_log = axutil_log_create(allocator, NULL, NULL); + error = axutil_error_create(allocator); + + environment = axutil_env_create_with_error_log(allocator, error, axis_log); + test_om_build(file_name); + test_om_serialize(); + + axutil_env_free(environment); + return 0; +} diff --git a/axiom/test/resources/wsdl/Attachment1.wsdl b/axiom/test/resources/wsdl/Attachment1.wsdl new file mode 100644 index 0000000..0fc52d0 --- /dev/null +++ b/axiom/test/resources/wsdl/Attachment1.wsdl @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/AttachmentService.wsdl b/axiom/test/resources/wsdl/AttachmentService.wsdl new file mode 100644 index 0000000..b94b757 --- /dev/null +++ b/axiom/test/resources/wsdl/AttachmentService.wsdl @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/AxisBench.wsdl b/axiom/test/resources/wsdl/AxisBench.wsdl new file mode 100644 index 0000000..3138179 --- /dev/null +++ b/axiom/test/resources/wsdl/AxisBench.wsdl @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/BasicAllTest.wsdl b/axiom/test/resources/wsdl/BasicAllTest.wsdl new file mode 100644 index 0000000..13e2a79 --- /dev/null +++ b/axiom/test/resources/wsdl/BasicAllTest.wsdl @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These operations implement DOC/LIT SOAP operations, for interop testing. Please email johnko@microsoft.com with any questions/coments. + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/wsdl/BasicChoice.wsdl b/axiom/test/resources/wsdl/BasicChoice.wsdl new file mode 100644 index 0000000..25c6123 --- /dev/null +++ b/axiom/test/resources/wsdl/BasicChoice.wsdl @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These operations implement DOC/LIT SOAP operations, for interop testing. Please email johnko@microsoft.com with any questions/coments. + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/wsdl/Calculator.wsdl b/axiom/test/resources/wsdl/Calculator.wsdl new file mode 100644 index 0000000..c7d1243 --- /dev/null +++ b/axiom/test/resources/wsdl/Calculator.wsdl @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/CalculatorDoc.wsdl b/axiom/test/resources/wsdl/CalculatorDoc.wsdl new file mode 100644 index 0000000..5600279 --- /dev/null +++ b/axiom/test/resources/wsdl/CalculatorDoc.wsdl @@ -0,0 +1,255 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/Choice.wsdl b/axiom/test/resources/wsdl/Choice.wsdl new file mode 100644 index 0000000..25c6123 --- /dev/null +++ b/axiom/test/resources/wsdl/Choice.wsdl @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These operations implement DOC/LIT SOAP operations, for interop testing. Please email johnko@microsoft.com with any questions/coments. + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/wsdl/CombinedAllTest.wsdl b/axiom/test/resources/wsdl/CombinedAllTest.wsdl new file mode 100644 index 0000000..640ea4a --- /dev/null +++ b/axiom/test/resources/wsdl/CombinedAllTest.wsdl @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These operations implement DOC/LIT SOAP operations, for interop testing. Please email johnko@microsoft.com with any questions/coments. + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/wsdl/CombinedChoice.wsdl b/axiom/test/resources/wsdl/CombinedChoice.wsdl new file mode 100644 index 0000000..d4f2541 --- /dev/null +++ b/axiom/test/resources/wsdl/CombinedChoice.wsdl @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These operations implement DOC/LIT SOAP operations, for interop testing. Please email johnko@microsoft.com with any questions/coments. + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/wsdl/ComplexLists.wsdl b/axiom/test/resources/wsdl/ComplexLists.wsdl new file mode 100644 index 0000000..21674dc --- /dev/null +++ b/axiom/test/resources/wsdl/ComplexLists.wsdl @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/ComplexTypeAll.wsdl b/axiom/test/resources/wsdl/ComplexTypeAll.wsdl new file mode 100644 index 0000000..2703344 --- /dev/null +++ b/axiom/test/resources/wsdl/ComplexTypeAll.wsdl @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/DIClientDoc.wsdl b/axiom/test/resources/wsdl/DIClientDoc.wsdl new file mode 100644 index 0000000..972e768 --- /dev/null +++ b/axiom/test/resources/wsdl/DIClientDoc.wsdl @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/DataHandlerService.wsdl b/axiom/test/resources/wsdl/DataHandlerService.wsdl new file mode 100644 index 0000000..41fcec4 --- /dev/null +++ b/axiom/test/resources/wsdl/DataHandlerService.wsdl @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/Enumeration.wsdl b/axiom/test/resources/wsdl/Enumeration.wsdl new file mode 100644 index 0000000..15f72ce --- /dev/null +++ b/axiom/test/resources/wsdl/Enumeration.wsdl @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/ExceptionTest.wsdl b/axiom/test/resources/wsdl/ExceptionTest.wsdl new file mode 100644 index 0000000..557ed0f --- /dev/null +++ b/axiom/test/resources/wsdl/ExceptionTest.wsdl @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/ExceptionTestDoc.wsdl b/axiom/test/resources/wsdl/ExceptionTestDoc.wsdl new file mode 100644 index 0000000..e51b20f --- /dev/null +++ b/axiom/test/resources/wsdl/ExceptionTestDoc.wsdl @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/ExtensibilityQuery.wsdl b/axiom/test/resources/wsdl/ExtensibilityQuery.wsdl new file mode 100644 index 0000000..27a2738 --- /dev/null +++ b/axiom/test/resources/wsdl/ExtensibilityQuery.wsdl @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/FaultMapping.wsdl b/axiom/test/resources/wsdl/FaultMapping.wsdl new file mode 100644 index 0000000..557ed0f --- /dev/null +++ b/axiom/test/resources/wsdl/FaultMapping.wsdl @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/FaultMappingDoc.wsdl b/axiom/test/resources/wsdl/FaultMappingDoc.wsdl new file mode 100644 index 0000000..e51b20f --- /dev/null +++ b/axiom/test/resources/wsdl/FaultMappingDoc.wsdl @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/FourLevelTestDoc.wsdl b/axiom/test/resources/wsdl/FourLevelTestDoc.wsdl new file mode 100644 index 0000000..7c82a05 --- /dev/null +++ b/axiom/test/resources/wsdl/FourLevelTestDoc.wsdl @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/InOut.wsdl b/axiom/test/resources/wsdl/InOut.wsdl new file mode 100644 index 0000000..11f6afa --- /dev/null +++ b/axiom/test/resources/wsdl/InOut.wsdl @@ -0,0 +1,429 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/InteropTestRound1.wsdl b/axiom/test/resources/wsdl/InteropTestRound1.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/InteropTestRound1.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/InteropTestRound1Doc.wsdl b/axiom/test/resources/wsdl/InteropTestRound1Doc.wsdl new file mode 100644 index 0000000..be1d09b --- /dev/null +++ b/axiom/test/resources/wsdl/InteropTestRound1Doc.wsdl @@ -0,0 +1,774 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/LargeReturningString.wsdl b/axiom/test/resources/wsdl/LargeReturningString.wsdl new file mode 100644 index 0000000..9b031da --- /dev/null +++ b/axiom/test/resources/wsdl/LargeReturningString.wsdl @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/LimitedAllTest.wsdl b/axiom/test/resources/wsdl/LimitedAllTest.wsdl new file mode 100644 index 0000000..81522f6 --- /dev/null +++ b/axiom/test/resources/wsdl/LimitedAllTest.wsdl @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These operations implement DOC/LIT SOAP operations, for interop testing. Please email johnko@microsoft.com with any questions/coments. + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/wsdl/ManyTypeRefRoot.wsdl b/axiom/test/resources/wsdl/ManyTypeRefRoot.wsdl new file mode 100644 index 0000000..13dec3d --- /dev/null +++ b/axiom/test/resources/wsdl/ManyTypeRefRoot.wsdl @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/MathOps.wsdl b/axiom/test/resources/wsdl/MathOps.wsdl new file mode 100644 index 0000000..f7f810f --- /dev/null +++ b/axiom/test/resources/wsdl/MathOps.wsdl @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/MathOpsDoc.wsdl b/axiom/test/resources/wsdl/MathOpsDoc.wsdl new file mode 100644 index 0000000..e85ae96 --- /dev/null +++ b/axiom/test/resources/wsdl/MathOpsDoc.wsdl @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/MinOccurTest.wsdl b/axiom/test/resources/wsdl/MinOccurTest.wsdl new file mode 100644 index 0000000..2fe8308 --- /dev/null +++ b/axiom/test/resources/wsdl/MinOccurTest.wsdl @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These operations implement DOC/LIT SOAP operations, for interop testing. Please email johnko@microsoft.com with any questions/coments. + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/wsdl/MultiOut.wsdl b/axiom/test/resources/wsdl/MultiOut.wsdl new file mode 100644 index 0000000..9590b29 --- /dev/null +++ b/axiom/test/resources/wsdl/MultiOut.wsdl @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/NestedArrays.wsdl b/axiom/test/resources/wsdl/NestedArrays.wsdl new file mode 100644 index 0000000..17760b7 --- /dev/null +++ b/axiom/test/resources/wsdl/NestedArrays.wsdl @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/NestedComplex.wsdl b/axiom/test/resources/wsdl/NestedComplex.wsdl new file mode 100644 index 0000000..6384ce1 --- /dev/null +++ b/axiom/test/resources/wsdl/NestedComplex.wsdl @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/NillableArrays.wsdl b/axiom/test/resources/wsdl/NillableArrays.wsdl new file mode 100644 index 0000000..42028f0 --- /dev/null +++ b/axiom/test/resources/wsdl/NillableArrays.wsdl @@ -0,0 +1,266 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/OtherFaultException.wsdl b/axiom/test/resources/wsdl/OtherFaultException.wsdl new file mode 100644 index 0000000..56b66d1 --- /dev/null +++ b/axiom/test/resources/wsdl/OtherFaultException.wsdl @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/PlainTextAttachment.wsdl b/axiom/test/resources/wsdl/PlainTextAttachment.wsdl new file mode 100644 index 0000000..d0a9c8d --- /dev/null +++ b/axiom/test/resources/wsdl/PlainTextAttachment.wsdl @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/PrimitiveAndArray.wsdl b/axiom/test/resources/wsdl/PrimitiveAndArray.wsdl new file mode 100644 index 0000000..083cbca --- /dev/null +++ b/axiom/test/resources/wsdl/PrimitiveAndArray.wsdl @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RPCAllTest.wsdl b/axiom/test/resources/wsdl/RPCAllTest.wsdl new file mode 100644 index 0000000..1a86d52 --- /dev/null +++ b/axiom/test/resources/wsdl/RPCAllTest.wsdl @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RecurseTypes.wsdl b/axiom/test/resources/wsdl/RecurseTypes.wsdl new file mode 100644 index 0000000..4c3546a --- /dev/null +++ b/axiom/test/resources/wsdl/RecurseTypes.wsdl @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcHttpHeaderTest1.wsdl b/axiom/test/resources/wsdl/RpcHttpHeaderTest1.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcHttpHeaderTest1.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcHttpHeaderTest2.wsdl b/axiom/test/resources/wsdl/RpcHttpHeaderTest2.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcHttpHeaderTest2.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcHttpHeaderTest3.wsdl b/axiom/test/resources/wsdl/RpcHttpHeaderTest3.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcHttpHeaderTest3.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcHttpHeaderTest4.wsdl b/axiom/test/resources/wsdl/RpcHttpHeaderTest4.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcHttpHeaderTest4.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcHttpHeaderTest5.wsdl b/axiom/test/resources/wsdl/RpcHttpHeaderTest5.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcHttpHeaderTest5.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcHttpHeaderTest7.wsdl b/axiom/test/resources/wsdl/RpcHttpHeaderTest7.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcHttpHeaderTest7.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcHttpHeaderTest8.wsdl b/axiom/test/resources/wsdl/RpcHttpHeaderTest8.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcHttpHeaderTest8.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcSoapHeaderTest1.wsdl b/axiom/test/resources/wsdl/RpcSoapHeaderTest1.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcSoapHeaderTest1.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcSoapHeaderTest10.wsdl b/axiom/test/resources/wsdl/RpcSoapHeaderTest10.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcSoapHeaderTest10.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcSoapHeaderTest2.wsdl b/axiom/test/resources/wsdl/RpcSoapHeaderTest2.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcSoapHeaderTest2.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcSoapHeaderTest3.wsdl b/axiom/test/resources/wsdl/RpcSoapHeaderTest3.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcSoapHeaderTest3.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcSoapHeaderTest4.wsdl b/axiom/test/resources/wsdl/RpcSoapHeaderTest4.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcSoapHeaderTest4.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcSoapHeaderTest6.wsdl b/axiom/test/resources/wsdl/RpcSoapHeaderTest6.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcSoapHeaderTest6.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcSoapHeaderTest8.wsdl b/axiom/test/resources/wsdl/RpcSoapHeaderTest8.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcSoapHeaderTest8.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/RpcSoapHeaderTest9.wsdl b/axiom/test/resources/wsdl/RpcSoapHeaderTest9.wsdl new file mode 100644 index 0000000..f7d1945 --- /dev/null +++ b/axiom/test/resources/wsdl/RpcSoapHeaderTest9.wsdl @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/SimpleArray.wsdl b/axiom/test/resources/wsdl/SimpleArray.wsdl new file mode 100644 index 0000000..ef42ca1 --- /dev/null +++ b/axiom/test/resources/wsdl/SimpleArray.wsdl @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/SimpleArrayDoc.wsdl b/axiom/test/resources/wsdl/SimpleArrayDoc.wsdl new file mode 100644 index 0000000..d079513 --- /dev/null +++ b/axiom/test/resources/wsdl/SimpleArrayDoc.wsdl @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/SimpleArrays.wsdl b/axiom/test/resources/wsdl/SimpleArrays.wsdl new file mode 100644 index 0000000..ae60352 --- /dev/null +++ b/axiom/test/resources/wsdl/SimpleArrays.wsdl @@ -0,0 +1,299 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/SimpleChoice.wsdl b/axiom/test/resources/wsdl/SimpleChoice.wsdl new file mode 100644 index 0000000..b2b357f --- /dev/null +++ b/axiom/test/resources/wsdl/SimpleChoice.wsdl @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These operations implement DOC/LIT SOAP operations, for interop testing. Please email johnko@microsoft.com with any questions/coments. + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/wsdl/SimpleRef.wsdl b/axiom/test/resources/wsdl/SimpleRef.wsdl new file mode 100644 index 0000000..58e2a99 --- /dev/null +++ b/axiom/test/resources/wsdl/SimpleRef.wsdl @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/SimpleRefDoc.wsdl b/axiom/test/resources/wsdl/SimpleRefDoc.wsdl new file mode 100644 index 0000000..543a472 --- /dev/null +++ b/axiom/test/resources/wsdl/SimpleRefDoc.wsdl @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/SimpleTypeArray.wsdl b/axiom/test/resources/wsdl/SimpleTypeArray.wsdl new file mode 100644 index 0000000..410ec86 --- /dev/null +++ b/axiom/test/resources/wsdl/SimpleTypeArray.wsdl @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/SimpleTypeInnerUnbounded.wsdl b/axiom/test/resources/wsdl/SimpleTypeInnerUnbounded.wsdl new file mode 100644 index 0000000..15e4eba --- /dev/null +++ b/axiom/test/resources/wsdl/SimpleTypeInnerUnbounded.wsdl @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/SimpleTypeInnerUnboundedInOutput.wsdl b/axiom/test/resources/wsdl/SimpleTypeInnerUnboundedInOutput.wsdl new file mode 100644 index 0000000..3aceb9f --- /dev/null +++ b/axiom/test/resources/wsdl/SimpleTypeInnerUnboundedInOutput.wsdl @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/StockQuotes.wsdl b/axiom/test/resources/wsdl/StockQuotes.wsdl new file mode 100644 index 0000000..a5be851 --- /dev/null +++ b/axiom/test/resources/wsdl/StockQuotes.wsdl @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + net.xmethods.services.stockquote.StockQuote web service + + + + + diff --git a/axiom/test/resources/wsdl/TestTransportTimeout.wsdl b/axiom/test/resources/wsdl/TestTransportTimeout.wsdl new file mode 100644 index 0000000..9a469d6 --- /dev/null +++ b/axiom/test/resources/wsdl/TestTransportTimeout.wsdl @@ -0,0 +1,255 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/UDDI.wsdl b/axiom/test/resources/wsdl/UDDI.wsdl new file mode 100644 index 0000000..6d3c738 --- /dev/null +++ b/axiom/test/resources/wsdl/UDDI.wsdl @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/UnboundedChoice.wsdl b/axiom/test/resources/wsdl/UnboundedChoice.wsdl new file mode 100644 index 0000000..3becac9 --- /dev/null +++ b/axiom/test/resources/wsdl/UnboundedChoice.wsdl @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These operations implement DOC/LIT SOAP operations, for interop testing. Please email johnko@microsoft.com with any questions/coments. + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/wsdl/UnboundedStringChoice.wsdl b/axiom/test/resources/wsdl/UnboundedStringChoice.wsdl new file mode 100644 index 0000000..f752eca --- /dev/null +++ b/axiom/test/resources/wsdl/UnboundedStringChoice.wsdl @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + These operations implement DOC/LIT SOAP operations, for interop testing. Please email johnko@microsoft.com with any questions/coments. + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/wsdl/XSDAttribute.wsdl b/axiom/test/resources/wsdl/XSDAttribute.wsdl new file mode 100644 index 0000000..2c3f44f --- /dev/null +++ b/axiom/test/resources/wsdl/XSDAttribute.wsdl @@ -0,0 +1,1046 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSDElement.wsdl b/axiom/test/resources/wsdl/XSDElement.wsdl new file mode 100644 index 0000000..13309e6 --- /dev/null +++ b/axiom/test/resources/wsdl/XSDElement.wsdl @@ -0,0 +1,1422 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSDElementNil.wsdl b/axiom/test/resources/wsdl/XSDElementNil.wsdl new file mode 100644 index 0000000..153530b --- /dev/null +++ b/axiom/test/resources/wsdl/XSDElementNil.wsdl @@ -0,0 +1,1414 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_ENTITIES.wsdl b/axiom/test/resources/wsdl/XSD_ENTITIES.wsdl new file mode 100644 index 0000000..56628fb --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_ENTITIES.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_ENTITY.wsdl b/axiom/test/resources/wsdl/XSD_ENTITY.wsdl new file mode 100644 index 0000000..e18be29 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_ENTITY.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_ID.wsdl b/axiom/test/resources/wsdl/XSD_ID.wsdl new file mode 100644 index 0000000..06f931b --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_ID.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_IDREF.wsdl b/axiom/test/resources/wsdl/XSD_IDREF.wsdl new file mode 100644 index 0000000..8306b44 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_IDREF.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_IDREFS.wsdl b/axiom/test/resources/wsdl/XSD_IDREFS.wsdl new file mode 100644 index 0000000..cdec7fb --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_IDREFS.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_NCName.wsdl b/axiom/test/resources/wsdl/XSD_NCName.wsdl new file mode 100644 index 0000000..b65e656 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_NCName.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_NMTOKEN.wsdl b/axiom/test/resources/wsdl/XSD_NMTOKEN.wsdl new file mode 100644 index 0000000..184d47c --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_NMTOKEN.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_NMTOKENS.wsdl b/axiom/test/resources/wsdl/XSD_NMTOKENS.wsdl new file mode 100644 index 0000000..6100b1a --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_NMTOKENS.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_NOTATION.wsdl b/axiom/test/resources/wsdl/XSD_NOTATION.wsdl new file mode 100644 index 0000000..564985c --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_NOTATION.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_Name.wsdl b/axiom/test/resources/wsdl/XSD_Name.wsdl new file mode 100644 index 0000000..5198b1c --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_Name.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_QName.wsdl b/axiom/test/resources/wsdl/XSD_QName.wsdl new file mode 100644 index 0000000..7fca9ff --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_QName.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_anyURI.wsdl b/axiom/test/resources/wsdl/XSD_anyURI.wsdl new file mode 100644 index 0000000..73410d8 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_anyURI.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_base64Binary.wsdl b/axiom/test/resources/wsdl/XSD_base64Binary.wsdl new file mode 100644 index 0000000..e7b1ae8 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_base64Binary.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_boolean.wsdl b/axiom/test/resources/wsdl/XSD_boolean.wsdl new file mode 100644 index 0000000..906ba02 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_boolean.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_byte.wsdl b/axiom/test/resources/wsdl/XSD_byte.wsdl new file mode 100644 index 0000000..52aa1d3 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_byte.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_date.wsdl b/axiom/test/resources/wsdl/XSD_date.wsdl new file mode 100644 index 0000000..013a3f9 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_date.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_dateTime.wsdl b/axiom/test/resources/wsdl/XSD_dateTime.wsdl new file mode 100644 index 0000000..5031ca6 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_dateTime.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_decimal.wsdl b/axiom/test/resources/wsdl/XSD_decimal.wsdl new file mode 100644 index 0000000..587107a --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_decimal.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_double.wsdl b/axiom/test/resources/wsdl/XSD_double.wsdl new file mode 100644 index 0000000..51eb810 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_double.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_duration.wsdl b/axiom/test/resources/wsdl/XSD_duration.wsdl new file mode 100644 index 0000000..31a8b18 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_duration.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_float.wsdl b/axiom/test/resources/wsdl/XSD_float.wsdl new file mode 100644 index 0000000..dcc7464 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_float.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_gDay.wsdl b/axiom/test/resources/wsdl/XSD_gDay.wsdl new file mode 100644 index 0000000..2508f5d --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_gDay.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_gMonth.wsdl b/axiom/test/resources/wsdl/XSD_gMonth.wsdl new file mode 100644 index 0000000..1d05d42 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_gMonth.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_gMonthDay.wsdl b/axiom/test/resources/wsdl/XSD_gMonthDay.wsdl new file mode 100644 index 0000000..6d06f45 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_gMonthDay.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_gYear.wsdl b/axiom/test/resources/wsdl/XSD_gYear.wsdl new file mode 100644 index 0000000..0135260 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_gYear.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_gYearMonth.wsdl b/axiom/test/resources/wsdl/XSD_gYearMonth.wsdl new file mode 100644 index 0000000..d0bd3f1 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_gYearMonth.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_hexBinary.wsdl b/axiom/test/resources/wsdl/XSD_hexBinary.wsdl new file mode 100644 index 0000000..1ace268 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_hexBinary.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_int.wsdl b/axiom/test/resources/wsdl/XSD_int.wsdl new file mode 100644 index 0000000..897ba94 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_int.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_integer.wsdl b/axiom/test/resources/wsdl/XSD_integer.wsdl new file mode 100644 index 0000000..162cc94 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_integer.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_language.wsdl b/axiom/test/resources/wsdl/XSD_language.wsdl new file mode 100644 index 0000000..e69a08a --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_language.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_long.wsdl b/axiom/test/resources/wsdl/XSD_long.wsdl new file mode 100644 index 0000000..8d9b562 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_long.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_negativeInteger.wsdl b/axiom/test/resources/wsdl/XSD_negativeInteger.wsdl new file mode 100644 index 0000000..70abcda --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_negativeInteger.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_nonNegativeInteger.wsdl b/axiom/test/resources/wsdl/XSD_nonNegativeInteger.wsdl new file mode 100644 index 0000000..b3baf36 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_nonNegativeInteger.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_nonPositiveInteger.wsdl b/axiom/test/resources/wsdl/XSD_nonPositiveInteger.wsdl new file mode 100644 index 0000000..ab95c37 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_nonPositiveInteger.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_normalizedString.wsdl b/axiom/test/resources/wsdl/XSD_normalizedString.wsdl new file mode 100644 index 0000000..4e44c2e --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_normalizedString.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_positiveInteger.wsdl b/axiom/test/resources/wsdl/XSD_positiveInteger.wsdl new file mode 100644 index 0000000..ce5c1bb --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_positiveInteger.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_short.wsdl b/axiom/test/resources/wsdl/XSD_short.wsdl new file mode 100644 index 0000000..f707d77 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_short.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_string.wsdl b/axiom/test/resources/wsdl/XSD_string.wsdl new file mode 100644 index 0000000..f325e17 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_string.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_time.wsdl b/axiom/test/resources/wsdl/XSD_time.wsdl new file mode 100644 index 0000000..fc47d5a --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_time.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_token.wsdl b/axiom/test/resources/wsdl/XSD_token.wsdl new file mode 100644 index 0000000..6ff5990 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_token.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_unsignedByte.wsdl b/axiom/test/resources/wsdl/XSD_unsignedByte.wsdl new file mode 100644 index 0000000..4b13551 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_unsignedByte.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_unsignedInt.wsdl b/axiom/test/resources/wsdl/XSD_unsignedInt.wsdl new file mode 100644 index 0000000..2c60e37 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_unsignedInt.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_unsignedLong.wsdl b/axiom/test/resources/wsdl/XSD_unsignedLong.wsdl new file mode 100644 index 0000000..04de8dd --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_unsignedLong.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/XSD_unsignedShort.wsdl b/axiom/test/resources/wsdl/XSD_unsignedShort.wsdl new file mode 100644 index 0000000..9338c34 --- /dev/null +++ b/axiom/test/resources/wsdl/XSD_unsignedShort.wsdl @@ -0,0 +1,285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/inquire_v2.wsdl b/axiom/test/resources/wsdl/inquire_v2.wsdl new file mode 100644 index 0000000..50b7674 --- /dev/null +++ b/axiom/test/resources/wsdl/inquire_v2.wsdl @@ -0,0 +1,275 @@ + + + + + + + + + + + + + + + + + Copyright (c) 2000 - 2002 by Accenture, Ariba, Inc., Commerce One, Inc. + Fujitsu Limited, Hewlett-Packard Company, i2 Technologies, Inc., + Intel Corporation, International Business Machines Corporation, + Microsoft Corporation, Oracle Corporation, SAP AG, Sun Microsystems, Inc., + and VeriSign, Inc. All Rights Reserved. + + WSDL Service Interface for UDDI Inquiry API V2.0 + + This WSDL document defines the inquiry API calls for interacting with + the UDDI registry. The complete UDDI API specification is available + at http://www.uddi.org/specification.html. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This portType defines all of the UDDI inquiry operations. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This is the SOAP binding for the UDDI inquiry operations. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/nillableComplexType.wsdl b/axiom/test/resources/wsdl/nillableComplexType.wsdl new file mode 100644 index 0000000..ea224c2 --- /dev/null +++ b/axiom/test/resources/wsdl/nillableComplexType.wsdl @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/nillableComplexType.xsd b/axiom/test/resources/wsdl/nillableComplexType.xsd new file mode 100644 index 0000000..765be56 --- /dev/null +++ b/axiom/test/resources/wsdl/nillableComplexType.xsd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/wsdl/wsaTestService.wsdl b/axiom/test/resources/wsdl/wsaTestService.wsdl new file mode 100644 index 0000000..4ce8b12 --- /dev/null +++ b/axiom/test/resources/wsdl/wsaTestService.wsdl @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/xml/om/axis.xml b/axiom/test/resources/xml/om/axis.xml new file mode 100644 index 0000000..bc996c5 --- /dev/null +++ b/axiom/test/resources/xml/om/axis.xml @@ -0,0 +1,25 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/xml/om/basic.xml b/axiom/test/resources/xml/om/basic.xml new file mode 100644 index 0000000..88385fb --- /dev/null +++ b/axiom/test/resources/xml/om/basic.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/axiom/test/resources/xml/om/basicupdate.xml b/axiom/test/resources/xml/om/basicupdate.xml new file mode 100644 index 0000000..57d458c --- /dev/null +++ b/axiom/test/resources/xml/om/basicupdate.xml @@ -0,0 +1,47 @@ + + + + + + Goudse kaas + Rond + + + + + + + More cheese! + + + + + Even more cheese! + + + + + No sausages today + + + + + + + + + + + + + + + + + + diff --git a/axiom/test/resources/xml/om/contents.xml b/axiom/test/resources/xml/om/contents.xml new file mode 100644 index 0000000..35e3ac7 --- /dev/null +++ b/axiom/test/resources/xml/om/contents.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + Java and XML + + + Introduction + + What Is It? + + + How Do I Use It? + + + Why Should I Use It? + + + What's Next? + + + + + Creating XML + An XML Document + The Header + The Content + What's Next? + + + + Parsing XML + Getting Prepared + SAX Readers + Content Handlers + Error Handlers + + A Better Way to Load a Parser + + "Gotcha!" + What's Next? + + + + + + Web Publishing Frameworks + Selecting a Framework + Installation + + Using a Publishing Framework + + XSP + Cocoon 2.0 and Beyond + What's Next? + + + diff --git a/axiom/test/resources/xml/om/defaultNamespace.xml b/axiom/test/resources/xml/om/defaultNamespace.xml new file mode 100644 index 0000000..1e32981 --- /dev/null +++ b/axiom/test/resources/xml/om/defaultNamespace.xml @@ -0,0 +1,6 @@ + + + + Hello + + diff --git a/axiom/test/resources/xml/om/evaluate.xml b/axiom/test/resources/xml/om/evaluate.xml new file mode 100644 index 0000000..90d06bd --- /dev/null +++ b/axiom/test/resources/xml/om/evaluate.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + brown + + + moderate + + diff --git a/axiom/test/resources/xml/om/fibo.xml b/axiom/test/resources/xml/om/fibo.xml new file mode 100644 index 0000000..9b5d0ec --- /dev/null +++ b/axiom/test/resources/xml/om/fibo.xml @@ -0,0 +1,29 @@ + + + 0 + 1 + 1 + 2 + 3 + 5 + 8 + 13 + 21 + 34 + 55 + 89 + 144 + 233 + 377 + 610 + 987 + 1597 + 2584 + 4181 + 6765 + 10946 + 17711 + 28657 + 46368 + 75025 + diff --git a/axiom/test/resources/xml/om/id.xml b/axiom/test/resources/xml/om/id.xml new file mode 100644 index 0000000..749ab20 --- /dev/null +++ b/axiom/test/resources/xml/om/id.xml @@ -0,0 +1,21 @@ + + + + + + + + +]> + + + + baz + gouda + baz + cheddar + baz + + diff --git a/axiom/test/resources/xml/om/jaxen24.xml b/axiom/test/resources/xml/om/jaxen24.xml new file mode 100644 index 0000000..9b81996 --- /dev/null +++ b/axiom/test/resources/xml/om/jaxen24.xml @@ -0,0 +1,2 @@ + +

diff --git a/axiom/test/resources/xml/om/jaxen3.xml b/axiom/test/resources/xml/om/jaxen3.xml new file mode 100644 index 0000000..a87723a --- /dev/null +++ b/axiom/test/resources/xml/om/jaxen3.xml @@ -0,0 +1,15 @@ + + + + 2 + + CE-A + + + + 1 + + CE-B + + + diff --git a/axiom/test/resources/xml/om/lang.xml b/axiom/test/resources/xml/om/lang.xml new file mode 100644 index 0000000..49b45db --- /dev/null +++ b/axiom/test/resources/xml/om/lang.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/xml/om/message.xml b/axiom/test/resources/xml/om/message.xml new file mode 100644 index 0000000..3b81df2 --- /dev/null +++ b/axiom/test/resources/xml/om/message.xml @@ -0,0 +1,27 @@ + + +
+ lookupformservice + 9 + stammdaten + new +
+ + + + + iteminfo + ELE + + + parentinfo + Pruefgebiete + + + id + 1 + + + + +
diff --git a/axiom/test/resources/xml/om/moreover.xml b/axiom/test/resources/xml/om/moreover.xml new file mode 100644 index 0000000..38d4c4f --- /dev/null +++ b/axiom/test/resources/xml/om/moreover.xml @@ -0,0 +1,244 @@ + + +
+ http://c.moreover.com/click/here.pl?x13563273 + e-Commerce Operators Present Version 1.0 of the XML Standard + StockAccess + text + moreover... + + http://www.stockaccess.com/index.html + Dec 24 2000 6:28AM + + +
+
+ http://c.moreover.com/click/here.pl?x13560995 + W3C Publishes XML Protocol Requirements Document + Xml + text + moreover... + + http://www.xml.com/ + Dec 24 2000 12:22AM + + +
+
+ http://c.moreover.com/click/here.pl?x13553521 + Prowler: Open Source XML-Based Content Management Framework + Xml + text + moreover... + + http://www.xml.com/ + Dec 23 2000 2:05PM + + +
+
+ http://c.moreover.com/click/here.pl?x13549013 + The Middleware Company Debuts Public Training Courses in Ejb, J2ee And Xml + Java Industry Connection + text + moreover... + + http://industry.java.sun.com/javanews/more/hotnews/ + Dec 23 2000 12:15PM + + +
+
+ http://c.moreover.com/click/here.pl?x13544467 + Revised Working Draft for the W3C XML Information Set + Xml + text + moreover... + + http://www.xml.com/ + Dec 23 2000 5:50AM + + +
+
+ http://c.moreover.com/click/here.pl?x13534836 + XML: Its The Great Peacemaker + ZDNet + text + moreover... + + http://www.zdnet.com/intweek/ + Dec 22 2000 9:05PM + + +
+
+ http://c.moreover.com/click/here.pl?x13533485 + Project eL - The XML Leningrad Codex Markup Project + Xml + text + moreover... + + http://www.xml.com/ + Dec 22 2000 8:34PM + + +
+
+ http://c.moreover.com/click/here.pl?x13533488 + XML Linking Language (XLink) and XML Base Specifications Issued as W3C Proposed Recommenda + Xml + text + moreover... + + http://www.xml.com/ + Dec 22 2000 8:34PM + + +
+
+ http://c.moreover.com/click/here.pl?x13533492 + W3C Releases XHTML Basic Specification as a W3C Recommendation + Xml + text + moreover... + + http://www.xml.com/ + Dec 22 2000 8:34PM + + +
+
+ http://c.moreover.com/click/here.pl?x13521827 + Java, Xml And Oracle9i(TM) Make A Great Team + Java Industry Connection + text + moreover... + + http://industry.java.sun.com/javanews/more/hotnews/ + Dec 22 2000 3:21PM + + +
+
+ http://c.moreover.com/click/here.pl?x13511233 + Competing initiatives to vie for security standard + ZDNet + text + moreover... + + http://www.zdnet.com/eweek/filters/news/ + Dec 22 2000 10:54AM + + +
+
+ http://c.moreover.com/click/here.pl?x13492397 + Oracle Provides Developers with Great Xml Reading This Holiday Season + Java Industry Connection + text + moreover... + + http://industry.java.sun.com/javanews/more/hotnews/ + Dec 21 2000 8:08PM + + +
+
+ http://c.moreover.com/click/here.pl?x13491292 + XML as the great peacemaker - Extensible Markup Language Accomplished The Seemingly Impossible This Year: It B + Hospitality Net + text + moreover... + + http://www.hospitalitynet.org/news/list.htm?c=2000 + Dec 21 2000 7:45PM + + +
+
+ http://c.moreover.com/click/here.pl?x13484758 + XML as the great peacemaker + CNET + text + moreover... + + http://news.cnet.com/news/0-1003.html?tag=st.ne.1002.dir.1003 + Dec 21 2000 4:41PM + + +
+
+ http://c.moreover.com/click/here.pl?x13480896 + COOP Switzerland Selects Mercator as Integration Platform + Stockhouse Canada + text + moreover... + + http://www.stockhouse.ca/news/ + Dec 21 2000 1:55PM + + +
+
+ http://c.moreover.com/click/here.pl?x13471023 + Competing XML Specs Move Toward a Union + Internet World + text + moreover... + + http://www.internetworld.com/ + Dec 21 2000 11:14AM + + +
+
+ http://c.moreover.com/click/here.pl?x13452280 + Next-generation XHTML stripped down for handhelds + CNET + text + moreover... + + http://news.cnet.com/news/0-1005.html?tag=st.ne.1002.dir.1005 + Dec 20 2000 9:11PM + + +
+
+ http://c.moreover.com/click/here.pl?x13451789 + Xml Powers Oracle9i(TM) Dynamic Services + Java Industry Connection + text + moreover... + + http://industry.java.sun.com/javanews/more/hotnews/ + Dec 20 2000 9:05PM + + +
+
+ http://c.moreover.com/click/here.pl?x13442097 + XML DOM reference guide + ASPWire + text + moreover... + + http://aspwire.com/ + Dec 20 2000 6:26PM + + +
+
+ http://c.moreover.com/click/here.pl?x13424117 + Repeat/Xqsite And Bowstreet Team to Deliver Integrated Xml Solutions + Java Industry Connection + text + moreover... + + http://industry.java.sun.com/javanews/more/hotnews/ + Dec 20 2000 9:04AM + + +
+
+ diff --git a/axiom/test/resources/xml/om/much_ado.xml b/axiom/test/resources/xml/om/much_ado.xml new file mode 100644 index 0000000..f008fad --- /dev/null +++ b/axiom/test/resources/xml/om/much_ado.xml @@ -0,0 +1,6850 @@ + + +Much Ado about Nothing + + +

Text placed in the public domain by Moby Lexical Tools, 1992.

+

SGML markup by Jon Bosak, 1992-1994.

+

XML version by Jon Bosak, 1996-1998.

+

This work may be freely copied and distributed worldwide.

+
+ + + +Dramatis Personae + +DON PEDRO, prince of Arragon. +DON JOHN, his bastard brother. +CLAUDIO, a young lord of Florence. +BENEDICK, a young lord of Padua. +LEONATO, governor of Messina. +ANTONIO, his brother. +BALTHASAR, attendant on Don Pedro. + + +CONRADE +BORACHIO +followers of Don John. + + +FRIAR FRANCIS +DOGBERRY, a constable. +VERGES, a headborough. +A Sexton. +A Boy. +HERO, daughter to Leonato. +BEATRICE, niece to Leonato. + + +MARGARET +URSULA +gentlewomen attending on Hero. + + +Messengers, Watch, Attendants, &c. + + +SCENE Messina. + +MUCH ADO ABOUT NOTHING + +ACT I + +SCENE I. Before LEONATO'S house. +Enter LEONATO, HERO, and BEATRICE, with a +Messenger + + +LEONATO +I learn in this letter that Don Peter of Arragon +comes this night to Messina. + + + +Messenger +He is very near by this: he was not three leagues off +when I left him. + + + +LEONATO +How many gentlemen have you lost in this action? + + + +Messenger +But few of any sort, and none of name. + + + +LEONATO +A victory is twice itself when the achiever brings +home full numbers. I find here that Don Peter hath +bestowed much honour on a young Florentine called Claudio. + + + +Messenger +Much deserved on his part and equally remembered by +Don Pedro: he hath borne himself beyond the +promise of his age, doing, in the figure of a lamb, +the feats of a lion: he hath indeed better +bettered expectation than you must expect of me to +tell you how. + + + +LEONATO +He hath an uncle here in Messina will be very much +glad of it. + + + +Messenger +I have already delivered him letters, and there +appears much joy in him; even so much that joy could +not show itself modest enough without a badge of +bitterness. + + + +LEONATO +Did he break out into tears? + + + +Messenger +In great measure. + + + +LEONATO +A kind overflow of kindness: there are no faces +truer than those that are so washed. How much +better is it to weep at joy than to joy at weeping! + + + +BEATRICE +I pray you, is Signior Mountanto returned from the +wars or no? + + + +Messenger +I know none of that name, lady: there was none such +in the army of any sort. + + + +LEONATO +What is he that you ask for, niece? + + + +HERO +My cousin means Signior Benedick of Padua. + + + +Messenger +O, he's returned; and as pleasant as ever he was. + + + +BEATRICE +He set up his bills here in Messina and challenged +Cupid at the flight; and my uncle's fool, reading +the challenge, subscribed for Cupid, and challenged +him at the bird-bolt. I pray you, how many hath he +killed and eaten in these wars? But how many hath +he killed? for indeed I promised to eat all of his killing. + + + +LEONATO +Faith, niece, you tax Signior Benedick too much; +but he'll be meet with you, I doubt it not. + + + +Messenger +He hath done good service, lady, in these wars. + + + +BEATRICE +You had musty victual, and he hath holp to eat it: +he is a very valiant trencherman; he hath an +excellent stomach. + + + +Messenger +And a good soldier too, lady. + + + +BEATRICE +And a good soldier to a lady: but what is he to a lord? + + + +Messenger +A lord to a lord, a man to a man; stuffed with all +honourable virtues. + + + +BEATRICE +It is so, indeed; he is no less than a stuffed man: +but for the stuffing,--well, we are all mortal. + + + +LEONATO +You must not, sir, mistake my niece. There is a +kind of merry war betwixt Signior Benedick and her: +they never meet but there's a skirmish of wit +between them. + + + +BEATRICE +Alas! he gets nothing by that. In our last +conflict four of his five wits went halting off, and +now is the whole man governed with one: so that if +he have wit enough to keep himself warm, let him +bear it for a difference between himself and his +horse; for it is all the wealth that he hath left, +to be known a reasonable creature. Who is his +companion now? He hath every month a new sworn brother. + + + +Messenger +Is't possible? + + + +BEATRICE +Very easily possible: he wears his faith but as +the fashion of his hat; it ever changes with the +next block. + + + +Messenger +I see, lady, the gentleman is not in your books. + + + +BEATRICE +No; an he were, I would burn my study. But, I pray +you, who is his companion? Is there no young +squarer now that will make a voyage with him to the devil? + + + +Messenger +He is most in the company of the right noble Claudio. + + + +BEATRICE +O Lord, he will hang upon him like a disease: he +is sooner caught than the pestilence, and the taker +runs presently mad. God help the noble Claudio! if +he have caught the Benedick, it will cost him a +thousand pound ere a' be cured. + + + +Messenger +I will hold friends with you, lady. + + + +BEATRICE +Do, good friend. + + + +LEONATO +You will never run mad, niece. + + + +BEATRICE +No, not till a hot January. + + + +Messenger +Don Pedro is approached. + + + +Enter DON PEDRO, DON JOHN, CLAUDIO, BENEDICK, +and BALTHASAR + + +DON PEDRO +Good Signior Leonato, you are come to meet your +trouble: the fashion of the world is to avoid +cost, and you encounter it. + + + +LEONATO +Never came trouble to my house in the likeness of +your grace: for trouble being gone, comfort should +remain; but when you depart from me, sorrow abides +and happiness takes his leave. + + + +DON PEDRO +You embrace your charge too willingly. I think this +is your daughter. + + + +LEONATO +Her mother hath many times told me so. + + + +BENEDICK +Were you in doubt, sir, that you asked her? + + + +LEONATO +Signior Benedick, no; for then were you a child. + + + +DON PEDRO +You have it full, Benedick: we may guess by this +what you are, being a man. Truly, the lady fathers +herself. Be happy, lady; for you are like an +honourable father. + + + +BENEDICK +If Signior Leonato be her father, she would not +have his head on her shoulders for all Messina, as +like him as she is. + + + +BEATRICE +I wonder that you will still be talking, Signior +Benedick: nobody marks you. + + + +BENEDICK +What, my dear Lady Disdain! are you yet living? + + + +BEATRICE +Is it possible disdain should die while she hath +such meet food to feed it as Signior Benedick? +Courtesy itself must convert to disdain, if you come +in her presence. + + + +BENEDICK +Then is courtesy a turncoat. But it is certain I +am loved of all ladies, only you excepted: and I +would I could find in my heart that I had not a hard +heart; for, truly, I love none. + + + +BEATRICE +A dear happiness to women: they would else have +been troubled with a pernicious suitor. I thank God +and my cold blood, I am of your humour for that: I +had rather hear my dog bark at a crow than a man +swear he loves me. + + + +BENEDICK +God keep your ladyship still in that mind! so some +gentleman or other shall 'scape a predestinate +scratched face. + + + +BEATRICE +Scratching could not make it worse, an 'twere such +a face as yours were. + + + +BENEDICK +Well, you are a rare parrot-teacher. + + + +BEATRICE +A bird of my tongue is better than a beast of yours. + + + +BENEDICK +I would my horse had the speed of your tongue, and +so good a continuer. But keep your way, i' God's +name; I have done. + + + +BEATRICE +You always end with a jade's trick: I know you of old. + + + +DON PEDRO +That is the sum of all, Leonato. Signior Claudio +and Signior Benedick, my dear friend Leonato hath +invited you all. I tell him we shall stay here at +the least a month; and he heartily prays some +occasion may detain us longer. I dare swear he is no +hypocrite, but prays from his heart. + + + +LEONATO +If you swear, my lord, you shall not be forsworn. +To DON JOHN +Let me bid you welcome, my lord: being reconciled to +the prince your brother, I owe you all duty. + + + +DON JOHN +I thank you: I am not of many words, but I thank +you. + + + +LEONATO +Please it your grace lead on? + + + +DON PEDRO +Your hand, Leonato; we will go together. + + + +Exeunt all except BENEDICK and CLAUDIO + + +CLAUDIO +Benedick, didst thou note the daughter of Signior Leonato? + + + +BENEDICK +I noted her not; but I looked on her. + + + +CLAUDIO +Is she not a modest young lady? + + + +BENEDICK +Do you question me, as an honest man should do, for +my simple true judgment; or would you have me speak +after my custom, as being a professed tyrant to their sex? + + + +CLAUDIO +No; I pray thee speak in sober judgment. + + + +BENEDICK +Why, i' faith, methinks she's too low for a high +praise, too brown for a fair praise and too little +for a great praise: only this commendation I can +afford her, that were she other than she is, she +were unhandsome; and being no other but as she is, I +do not like her. + + + +CLAUDIO +Thou thinkest I am in sport: I pray thee tell me +truly how thou likest her. + + + +BENEDICK +Would you buy her, that you inquire after her? + + + +CLAUDIO +Can the world buy such a jewel? + + + +BENEDICK +Yea, and a case to put it into. But speak you this +with a sad brow? or do you play the flouting Jack, +to tell us Cupid is a good hare-finder and Vulcan a +rare carpenter? Come, in what key shall a man take +you, to go in the song? + + + +CLAUDIO +In mine eye she is the sweetest lady that ever I +looked on. + + + +BENEDICK +I can see yet without spectacles and I see no such +matter: there's her cousin, an she were not +possessed with a fury, exceeds her as much in beauty +as the first of May doth the last of December. But I +hope you have no intent to turn husband, have you? + + + +CLAUDIO +I would scarce trust myself, though I had sworn the +contrary, if Hero would be my wife. + + + +BENEDICK +Is't come to this? In faith, hath not the world +one man but he will wear his cap with suspicion? +Shall I never see a bachelor of three-score again? +Go to, i' faith; an thou wilt needs thrust thy neck +into a yoke, wear the print of it and sigh away +Sundays. Look Don Pedro is returned to seek you. + + + +Re-enter DON PEDRO + + +DON PEDRO +What secret hath held you here, that you followed +not to Leonato's? + + + +BENEDICK +I would your grace would constrain me to tell. + + + +DON PEDRO +I charge thee on thy allegiance. + + + +BENEDICK +You hear, Count Claudio: I can be secret as a dumb +man; I would have you think so; but, on my +allegiance, mark you this, on my allegiance. He is +in love. With who? now that is your grace's part. +Mark how short his answer is;--With Hero, Leonato's +short daughter. + + + +CLAUDIO +If this were so, so were it uttered. + + + +BENEDICK +Like the old tale, my lord: 'it is not so, nor +'twas not so, but, indeed, God forbid it should be +so.' + + + +CLAUDIO +If my passion change not shortly, God forbid it +should be otherwise. + + + +DON PEDRO +Amen, if you love her; for the lady is very well worthy. + + + +CLAUDIO +You speak this to fetch me in, my lord. + + + +DON PEDRO +By my troth, I speak my thought. + + + +CLAUDIO +And, in faith, my lord, I spoke mine. + + + +BENEDICK +And, by my two faiths and troths, my lord, I spoke mine. + + + +CLAUDIO +That I love her, I feel. + + + +DON PEDRO +That she is worthy, I know. + + + +BENEDICK +That I neither feel how she should be loved nor +know how she should be worthy, is the opinion that +fire cannot melt out of me: I will die in it at the stake. + + + +DON PEDRO +Thou wast ever an obstinate heretic in the despite +of beauty. + + + +CLAUDIO +And never could maintain his part but in the force +of his will. + + + +BENEDICK +That a woman conceived me, I thank her; that she +brought me up, I likewise give her most humble +thanks: but that I will have a recheat winded in my +forehead, or hang my bugle in an invisible baldrick, +all women shall pardon me. Because I will not do +them the wrong to mistrust any, I will do myself the +right to trust none; and the fine is, for the which +I may go the finer, I will live a bachelor. + + + +DON PEDRO +I shall see thee, ere I die, look pale with love. + + + +BENEDICK +With anger, with sickness, or with hunger, my lord, +not with love: prove that ever I lose more blood +with love than I will get again with drinking, pick +out mine eyes with a ballad-maker's pen and hang me +up at the door of a brothel-house for the sign of +blind Cupid. + + + +DON PEDRO +Well, if ever thou dost fall from this faith, thou +wilt prove a notable argument. + + + +BENEDICK +If I do, hang me in a bottle like a cat and shoot +at me; and he that hits me, let him be clapped on +the shoulder, and called Adam. + + + +DON PEDRO +Well, as time shall try: 'In time the savage bull +doth bear the yoke.' + + + +BENEDICK +The savage bull may; but if ever the sensible +Benedick bear it, pluck off the bull's horns and set +them in my forehead: and let me be vilely painted, +and in such great letters as they write 'Here is +good horse to hire,' let them signify under my sign +'Here you may see Benedick the married man.' + + + +CLAUDIO +If this should ever happen, thou wouldst be horn-mad. + + + +DON PEDRO +Nay, if Cupid have not spent all his quiver in +Venice, thou wilt quake for this shortly. + + + +BENEDICK +I look for an earthquake too, then. + + + +DON PEDRO +Well, you temporize with the hours. In the +meantime, good Signior Benedick, repair to +Leonato's: commend me to him and tell him I will +not fail him at supper; for indeed he hath made +great preparation. + + + +BENEDICK +I have almost matter enough in me for such an +embassage; and so I commit you-- + + + +CLAUDIO +To the tuition of God: From my house, if I had it,-- + + + +DON PEDRO +The sixth of July: Your loving friend, Benedick. + + + +BENEDICK +Nay, mock not, mock not. The body of your +discourse is sometime guarded with fragments, and +the guards are but slightly basted on neither: ere +you flout old ends any further, examine your +conscience: and so I leave you. + + + +Exit + + +CLAUDIO +My liege, your highness now may do me good. + + + +DON PEDRO +My love is thine to teach: teach it but how, +And thou shalt see how apt it is to learn +Any hard lesson that may do thee good. + + + +CLAUDIO +Hath Leonato any son, my lord? + + + +DON PEDRO +No child but Hero; she's his only heir. +Dost thou affect her, Claudio? + + + +CLAUDIO +O, my lord, +When you went onward on this ended action, +I look'd upon her with a soldier's eye, +That liked, but had a rougher task in hand +Than to drive liking to the name of love: +But now I am return'd and that war-thoughts +Have left their places vacant, in their rooms +Come thronging soft and delicate desires, +All prompting me how fair young Hero is, +Saying, I liked her ere I went to wars. + + + +DON PEDRO +Thou wilt be like a lover presently +And tire the hearer with a book of words. +If thou dost love fair Hero, cherish it, +And I will break with her and with her father, +And thou shalt have her. Was't not to this end +That thou began'st to twist so fine a story? + + + +CLAUDIO +How sweetly you do minister to love, +That know love's grief by his complexion! +But lest my liking might too sudden seem, +I would have salved it with a longer treatise. + + + +DON PEDRO +What need the bridge much broader than the flood? +The fairest grant is the necessity. +Look, what will serve is fit: 'tis once, thou lovest, +And I will fit thee with the remedy. +I know we shall have revelling to-night: +I will assume thy part in some disguise +And tell fair Hero I am Claudio, +And in her bosom I'll unclasp my heart +And take her hearing prisoner with the force +And strong encounter of my amorous tale: +Then after to her father will I break; +And the conclusion is, she shall be thine. +In practise let us put it presently. + + + +Exeunt + + +SCENE II. A room in LEONATO's house. +Enter LEONATO and ANTONIO, meeting + + +LEONATO +How now, brother! Where is my cousin, your son? +hath he provided this music? + + + +ANTONIO +He is very busy about it. But, brother, I can tell +you strange news that you yet dreamt not of. + + + +LEONATO +Are they good? + + + +ANTONIO +As the event stamps them: but they have a good +cover; they show well outward. The prince and Count +Claudio, walking in a thick-pleached alley in mine +orchard, were thus much overheard by a man of mine: +the prince discovered to Claudio that he loved my +niece your daughter and meant to acknowledge it +this night in a dance: and if he found her +accordant, he meant to take the present time by the +top and instantly break with you of it. + + + +LEONATO +Hath the fellow any wit that told you this? + + + +ANTONIO +A good sharp fellow: I will send for him; and +question him yourself. + + + +LEONATO +No, no; we will hold it as a dream till it appear +itself: but I will acquaint my daughter withal, +that she may be the better prepared for an answer, +if peradventure this be true. Go you and tell her of it. +Enter Attendants +Cousins, you know what you have to do. O, I cry you +mercy, friend; go you with me, and I will use your +skill. Good cousin, have a care this busy time. + + + +Exeunt + + +SCENE III. The same. +Enter DON JOHN and CONRADE + + +CONRADE +What the good-year, my lord! why are you thus out +of measure sad? + + + +DON JOHN +There is no measure in the occasion that breeds; +therefore the sadness is without limit. + + + +CONRADE +You should hear reason. + + + +DON JOHN +And when I have heard it, what blessing brings it? + + + +CONRADE +If not a present remedy, at least a patient +sufferance. + + + +DON JOHN +I wonder that thou, being, as thou sayest thou art, +born under Saturn, goest about to apply a moral +medicine to a mortifying mischief. I cannot hide +what I am: I must be sad when I have cause and smile +at no man's jests, eat when I have stomach and wait +for no man's leisure, sleep when I am drowsy and +tend on no man's business, laugh when I am merry and +claw no man in his humour. + + + +CONRADE +Yea, but you must not make the full show of this +till you may do it without controlment. You have of +late stood out against your brother, and he hath +ta'en you newly into his grace; where it is +impossible you should take true root but by the +fair weather that you make yourself: it is needful +that you frame the season for your own harvest. + + + +DON JOHN +I had rather be a canker in a hedge than a rose in +his grace, and it better fits my blood to be +disdained of all than to fashion a carriage to rob +love from any: in this, though I cannot be said to +be a flattering honest man, it must not be denied +but I am a plain-dealing villain. I am trusted with +a muzzle and enfranchised with a clog; therefore I +have decreed not to sing in my cage. If I had my +mouth, I would bite; if I had my liberty, I would do +my liking: in the meantime let me be that I am and +seek not to alter me. + + + +CONRADE +Can you make no use of your discontent? + + + +DON JOHN +I make all use of it, for I use it only. +Who comes here? +Enter BORACHIO +What news, Borachio? + + + +BORACHIO +I came yonder from a great supper: the prince your +brother is royally entertained by Leonato: and I +can give you intelligence of an intended marriage. + + + +DON JOHN +Will it serve for any model to build mischief on? +What is he for a fool that betroths himself to +unquietness? + + + +BORACHIO +Marry, it is your brother's right hand. + + + +DON JOHN +Who? the most exquisite Claudio? + + + +BORACHIO +Even he. + + + +DON JOHN +A proper squire! And who, and who? which way looks +he? + + + +BORACHIO +Marry, on Hero, the daughter and heir of Leonato. + + + +DON JOHN +A very forward March-chick! How came you to this? + + + +BORACHIO +Being entertained for a perfumer, as I was smoking a +musty room, comes me the prince and Claudio, hand +in hand in sad conference: I whipt me behind the +arras; and there heard it agreed upon that the +prince should woo Hero for himself, and having +obtained her, give her to Count Claudio. + + + +DON JOHN +Come, come, let us thither: this may prove food to +my displeasure. That young start-up hath all the +glory of my overthrow: if I can cross him any way, I +bless myself every way. You are both sure, and will assist me? + + + +CONRADE +To the death, my lord. + + + +DON JOHN +Let us to the great supper: their cheer is the +greater that I am subdued. Would the cook were of +my mind! Shall we go prove what's to be done? + + + +BORACHIO +We'll wait upon your lordship. + + + +Exeunt + + + + +ACT II + +SCENE I. A hall in LEONATO'S house. +Enter LEONATO, ANTONIO, HERO, BEATRICE, and others + + +LEONATO +Was not Count John here at supper? + + + +ANTONIO +I saw him not. + + + +BEATRICE +How tartly that gentleman looks! I never can see +him but I am heart-burned an hour after. + + + +HERO +He is of a very melancholy disposition. + + + +BEATRICE +He were an excellent man that were made just in the +midway between him and Benedick: the one is too +like an image and says nothing, and the other too +like my lady's eldest son, evermore tattling. + + + +LEONATO +Then half Signior Benedick's tongue in Count John's +mouth, and half Count John's melancholy in Signior +Benedick's face,-- + + + +BEATRICE +With a good leg and a good foot, uncle, and money +enough in his purse, such a man would win any woman +in the world, if a' could get her good-will. + + + +LEONATO +By my troth, niece, thou wilt never get thee a +husband, if thou be so shrewd of thy tongue. + + + +ANTONIO +In faith, she's too curst. + + + +BEATRICE +Too curst is more than curst: I shall lessen God's +sending that way; for it is said, 'God sends a curst +cow short horns;' but to a cow too curst he sends none. + + + +LEONATO +So, by being too curst, God will send you no horns. + + + +BEATRICE +Just, if he send me no husband; for the which +blessing I am at him upon my knees every morning and +evening. Lord, I could not endure a husband with a +beard on his face: I had rather lie in the woollen. + + + +LEONATO +You may light on a husband that hath no beard. + + + +BEATRICE +What should I do with him? dress him in my apparel +and make him my waiting-gentlewoman? He that hath a +beard is more than a youth, and he that hath no +beard is less than a man: and he that is more than +a youth is not for me, and he that is less than a +man, I am not for him: therefore, I will even take +sixpence in earnest of the bear-ward, and lead his +apes into hell. + + + +LEONATO +Well, then, go you into hell? + + + +BEATRICE +No, but to the gate; and there will the devil meet +me, like an old cuckold, with horns on his head, and +say 'Get you to heaven, Beatrice, get you to +heaven; here's no place for you maids:' so deliver +I up my apes, and away to Saint Peter for the +heavens; he shows me where the bachelors sit, and +there live we as merry as the day is long. + + + +ANTONIO +To HERO Well, niece, I trust you will be ruled +by your father. + + + +BEATRICE +Yes, faith; it is my cousin's duty to make curtsy +and say 'Father, as it please you.' But yet for all +that, cousin, let him be a handsome fellow, or else +make another curtsy and say 'Father, as it please +me.' + + + +LEONATO +Well, niece, I hope to see you one day fitted with a husband. + + + +BEATRICE +Not till God make men of some other metal than +earth. Would it not grieve a woman to be +overmastered with a pierce of valiant dust? to make +an account of her life to a clod of wayward marl? +No, uncle, I'll none: Adam's sons are my brethren; +and, truly, I hold it a sin to match in my kindred. + + + +LEONATO +Daughter, remember what I told you: if the prince +do solicit you in that kind, you know your answer. + + + +BEATRICE +The fault will be in the music, cousin, if you be +not wooed in good time: if the prince be too +important, tell him there is measure in every thing +and so dance out the answer. For, hear me, Hero: +wooing, wedding, and repenting, is as a Scotch jig, +a measure, and a cinque pace: the first suit is hot +and hasty, like a Scotch jig, and full as +fantastical; the wedding, mannerly-modest, as a +measure, full of state and ancientry; and then comes +repentance and, with his bad legs, falls into the +cinque pace faster and faster, till he sink into his grave. + + + +LEONATO +Cousin, you apprehend passing shrewdly. + + + +BEATRICE +I have a good eye, uncle; I can see a church by daylight. + + + +LEONATO +The revellers are entering, brother: make good room. + + +All put on their masks +Enter DON PEDRO, CLAUDIO, BENEDICK, BALTHASAR, +DON JOHN, BORACHIO, MARGARET, URSULA and others, masked + + +DON PEDRO +Lady, will you walk about with your friend? + + + +HERO +So you walk softly and look sweetly and say nothing, +I am yours for the walk; and especially when I walk away. + + + +DON PEDRO +With me in your company? + + + +HERO +I may say so, when I please. + + + +DON PEDRO +And when please you to say so? + + + +HERO +When I like your favour; for God defend the lute +should be like the case! + + + +DON PEDRO +My visor is Philemon's roof; within the house is Jove. + + + +HERO +Why, then, your visor should be thatched. + + + +DON PEDRO +Speak low, if you speak love. + + + +Drawing her aside + + +BALTHASAR +Well, I would you did like me. + + + +MARGARET +So would not I, for your own sake; for I have many +ill-qualities. + + + +BALTHASAR +Which is one? + + + +MARGARET +I say my prayers aloud. + + + +BALTHASAR +I love you the better: the hearers may cry, Amen. + + + +MARGARET +God match me with a good dancer! + + + +BALTHASAR +Amen. + + + +MARGARET +And God keep him out of my sight when the dance is +done! Answer, clerk. + + + +BALTHASAR +No more words: the clerk is answered. + + + +URSULA +I know you well enough; you are Signior Antonio. + + + +ANTONIO +At a word, I am not. + + + +URSULA +I know you by the waggling of your head. + + + +ANTONIO +To tell you true, I counterfeit him. + + + +URSULA +You could never do him so ill-well, unless you were +the very man. Here's his dry hand up and down: you +are he, you are he. + + + +ANTONIO +At a word, I am not. + + + +URSULA +Come, come, do you think I do not know you by your +excellent wit? can virtue hide itself? Go to, +mum, you are he: graces will appear, and there's an +end. + + + +BEATRICE +Will you not tell me who told you so? + + + +BENEDICK +No, you shall pardon me. + + + +BEATRICE +Nor will you not tell me who you are? + + + +BENEDICK +Not now. + + + +BEATRICE +That I was disdainful, and that I had my good wit +out of the 'Hundred Merry Tales:'--well this was +Signior Benedick that said so. + + + +BENEDICK +What's he? + + + +BEATRICE +I am sure you know him well enough. + + + +BENEDICK +Not I, believe me. + + + +BEATRICE +Did he never make you laugh? + + + +BENEDICK +I pray you, what is he? + + + +BEATRICE +Why, he is the prince's jester: a very dull fool; +only his gift is in devising impossible slanders: +none but libertines delight in him; and the +commendation is not in his wit, but in his villany; +for he both pleases men and angers them, and then +they laugh at him and beat him. I am sure he is in +the fleet: I would he had boarded me. + + + +BENEDICK +When I know the gentleman, I'll tell him what you say. + + + +BEATRICE +Do, do: he'll but break a comparison or two on me; +which, peradventure not marked or not laughed at, +strikes him into melancholy; and then there's a +partridge wing saved, for the fool will eat no +supper that night. +Music +We must follow the leaders. + + + +BENEDICK +In every good thing. + + + +BEATRICE +Nay, if they lead to any ill, I will leave them at +the next turning. + + + +Dance. Then exeunt all except DON JOHN, BORACHIO, +and CLAUDIO + + +DON JOHN +Sure my brother is amorous on Hero and hath +withdrawn her father to break with him about it. +The ladies follow her and but one visor remains. + + + +BORACHIO +And that is Claudio: I know him by his bearing. + + + +DON JOHN +Are not you Signior Benedick? + + + +CLAUDIO +You know me well; I am he. + + + +DON JOHN +Signior, you are very near my brother in his love: +he is enamoured on Hero; I pray you, dissuade him +from her: she is no equal for his birth: you may +do the part of an honest man in it. + + + +CLAUDIO +How know you he loves her? + + + +DON JOHN +I heard him swear his affection. + + + +BORACHIO +So did I too; and he swore he would marry her to-night. + + + +DON JOHN +Come, let us to the banquet. + + + +Exeunt DON JOHN and BORACHIO + + +CLAUDIO +Thus answer I in the name of Benedick, +But hear these ill news with the ears of Claudio. +'Tis certain so; the prince wooes for himself. +Friendship is constant in all other things +Save in the office and affairs of love: +Therefore, all hearts in love use their own tongues; +Let every eye negotiate for itself +And trust no agent; for beauty is a witch +Against whose charms faith melteth into blood. +This is an accident of hourly proof, +Which I mistrusted not. Farewell, therefore, Hero! + + + +Re-enter BENEDICK + + +BENEDICK +Count Claudio? + + + +CLAUDIO +Yea, the same. + + + +BENEDICK +Come, will you go with me? + + + +CLAUDIO +Whither? + + + +BENEDICK +Even to the next willow, about your own business, +county. What fashion will you wear the garland of? +about your neck, like an usurer's chain? or under +your arm, like a lieutenant's scarf? You must wear +it one way, for the prince hath got your Hero. + + + +CLAUDIO +I wish him joy of her. + + + +BENEDICK +Why, that's spoken like an honest drovier: so they +sell bullocks. But did you think the prince would +have served you thus? + + + +CLAUDIO +I pray you, leave me. + + + +BENEDICK +Ho! now you strike like the blind man: 'twas the +boy that stole your meat, and you'll beat the post. + + + +CLAUDIO +If it will not be, I'll leave you. + + + +Exit + + +BENEDICK +Alas, poor hurt fowl! now will he creep into sedges. +But that my Lady Beatrice should know me, and not +know me! The prince's fool! Ha? It may be I go +under that title because I am merry. Yea, but so I +am apt to do myself wrong; I am not so reputed: it +is the base, though bitter, disposition of Beatrice +that puts the world into her person and so gives me +out. Well, I'll be revenged as I may. + + + +Re-enter DON PEDRO + + +DON PEDRO +Now, signior, where's the count? did you see him? + + + +BENEDICK +Troth, my lord, I have played the part of Lady Fame. +I found him here as melancholy as a lodge in a +warren: I told him, and I think I told him true, +that your grace had got the good will of this young +lady; and I offered him my company to a willow-tree, +either to make him a garland, as being forsaken, or +to bind him up a rod, as being worthy to be whipped. + + + +DON PEDRO +To be whipped! What's his fault? + + + +BENEDICK +The flat transgression of a schoolboy, who, being +overjoyed with finding a birds' nest, shows it his +companion, and he steals it. + + + +DON PEDRO +Wilt thou make a trust a transgression? The +transgression is in the stealer. + + + +BENEDICK +Yet it had not been amiss the rod had been made, +and the garland too; for the garland he might have +worn himself, and the rod he might have bestowed on +you, who, as I take it, have stolen his birds' nest. + + + +DON PEDRO +I will but teach them to sing, and restore them to +the owner. + + + +BENEDICK +If their singing answer your saying, by my faith, +you say honestly. + + + +DON PEDRO +The Lady Beatrice hath a quarrel to you: the +gentleman that danced with her told her she is much +wronged by you. + + + +BENEDICK +O, she misused me past the endurance of a block! +an oak but with one green leaf on it would have +answered her; my very visor began to assume life and +scold with her. She told me, not thinking I had been +myself, that I was the prince's jester, that I was +duller than a great thaw; huddling jest upon jest +with such impossible conveyance upon me that I stood +like a man at a mark, with a whole army shooting at +me. She speaks poniards, and every word stabs: +if her breath were as terrible as her terminations, +there were no living near her; she would infect to +the north star. I would not marry her, though she +were endowed with all that Adam bad left him before +he transgressed: she would have made Hercules have +turned spit, yea, and have cleft his club to make +the fire too. Come, talk not of her: you shall find +her the infernal Ate in good apparel. I would to God +some scholar would conjure her; for certainly, while +she is here, a man may live as quiet in hell as in a +sanctuary; and people sin upon purpose, because they +would go thither; so, indeed, all disquiet, horror +and perturbation follows her. + + + +DON PEDRO +Look, here she comes. + + + +Enter CLAUDIO, BEATRICE, HERO, and LEONATO + + +BENEDICK +Will your grace command me any service to the +world's end? I will go on the slightest errand now +to the Antipodes that you can devise to send me on; +I will fetch you a tooth-picker now from the +furthest inch of Asia, bring you the length of +Prester John's foot, fetch you a hair off the great +Cham's beard, do you any embassage to the Pigmies, +rather than hold three words' conference with this +harpy. You have no employment for me? + + + +DON PEDRO +None, but to desire your good company. + + + +BENEDICK +O God, sir, here's a dish I love not: I cannot +endure my Lady Tongue. + + + +Exit + + +DON PEDRO +Come, lady, come; you have lost the heart of +Signior Benedick. + + + +BEATRICE +Indeed, my lord, he lent it me awhile; and I gave +him use for it, a double heart for his single one: +marry, once before he won it of me with false dice, +therefore your grace may well say I have lost it. + + + +DON PEDRO +You have put him down, lady, you have put him down. + + + +BEATRICE +So I would not he should do me, my lord, lest I +should prove the mother of fools. I have brought +Count Claudio, whom you sent me to seek. + + + +DON PEDRO +Why, how now, count! wherefore are you sad? + + + +CLAUDIO +Not sad, my lord. + + + +DON PEDRO +How then? sick? + + + +CLAUDIO +Neither, my lord. + + + +BEATRICE +The count is neither sad, nor sick, nor merry, nor +well; but civil count, civil as an orange, and +something of that jealous complexion. + + + +DON PEDRO +I' faith, lady, I think your blazon to be true; +though, I'll be sworn, if he be so, his conceit is +false. Here, Claudio, I have wooed in thy name, and +fair Hero is won: I have broke with her father, +and his good will obtained: name the day of +marriage, and God give thee joy! + + + +LEONATO +Count, take of me my daughter, and with her my +fortunes: his grace hath made the match, and an +grace say Amen to it. + + + +BEATRICE +Speak, count, 'tis your cue. + + + +CLAUDIO +Silence is the perfectest herald of joy: I were +but little happy, if I could say how much. Lady, as +you are mine, I am yours: I give away myself for +you and dote upon the exchange. + + + +BEATRICE +Speak, cousin; or, if you cannot, stop his mouth +with a kiss, and let not him speak neither. + + + +DON PEDRO +In faith, lady, you have a merry heart. + + + +BEATRICE +Yea, my lord; I thank it, poor fool, it keeps on +the windy side of care. My cousin tells him in his +ear that he is in her heart. + + + +CLAUDIO +And so she doth, cousin. + + + +BEATRICE +Good Lord, for alliance! Thus goes every one to the +world but I, and I am sunburnt; I may sit in a +corner and cry heigh-ho for a husband! + + + +DON PEDRO +Lady Beatrice, I will get you one. + + + +BEATRICE +I would rather have one of your father's getting. +Hath your grace ne'er a brother like you? Your +father got excellent husbands, if a maid could come by them. + + + +DON PEDRO +Will you have me, lady? + + + +BEATRICE +No, my lord, unless I might have another for +working-days: your grace is too costly to wear +every day. But, I beseech your grace, pardon me: I +was born to speak all mirth and no matter. + + + +DON PEDRO +Your silence most offends me, and to be merry best +becomes you; for, out of question, you were born in +a merry hour. + + + +BEATRICE +No, sure, my lord, my mother cried; but then there +was a star danced, and under that was I born. +Cousins, God give you joy! + + + +LEONATO +Niece, will you look to those things I told you of? + + + +BEATRICE +I cry you mercy, uncle. By your grace's pardon. + + + +Exit + + +DON PEDRO +By my troth, a pleasant-spirited lady. + + + +LEONATO +There's little of the melancholy element in her, my +lord: she is never sad but when she sleeps, and +not ever sad then; for I have heard my daughter say, +she hath often dreamed of unhappiness and waked +herself with laughing. + + + +DON PEDRO +She cannot endure to hear tell of a husband. + + + +LEONATO +O, by no means: she mocks all her wooers out of suit. + + + +DON PEDRO +She were an excellent wife for Benedict. + + + +LEONATO +O Lord, my lord, if they were but a week married, +they would talk themselves mad. + + + +DON PEDRO +County Claudio, when mean you to go to church? + + + +CLAUDIO +To-morrow, my lord: time goes on crutches till love +have all his rites. + + + +LEONATO +Not till Monday, my dear son, which is hence a just +seven-night; and a time too brief, too, to have all +things answer my mind. + + + +DON PEDRO +Come, you shake the head at so long a breathing: +but, I warrant thee, Claudio, the time shall not go +dully by us. I will in the interim undertake one of +Hercules' labours; which is, to bring Signior +Benedick and the Lady Beatrice into a mountain of +affection the one with the other. I would fain have +it a match, and I doubt not but to fashion it, if +you three will but minister such assistance as I +shall give you direction. + + + +LEONATO +My lord, I am for you, though it cost me ten +nights' watchings. + + + +CLAUDIO +And I, my lord. + + + +DON PEDRO +And you too, gentle Hero? + + + +HERO +I will do any modest office, my lord, to help my +cousin to a good husband. + + + +DON PEDRO +And Benedick is not the unhopefullest husband that +I know. Thus far can I praise him; he is of a noble +strain, of approved valour and confirmed honesty. I +will teach you how to humour your cousin, that she +shall fall in love with Benedick; and I, with your +two helps, will so practise on Benedick that, in +despite of his quick wit and his queasy stomach, he +shall fall in love with Beatrice. If we can do this, +Cupid is no longer an archer: his glory shall be +ours, for we are the only love-gods. Go in with me, +and I will tell you my drift. + + + +Exeunt + + +SCENE II. The same. +Enter DON JOHN and BORACHIO + + +DON JOHN +It is so; the Count Claudio shall marry the +daughter of Leonato. + + + +BORACHIO +Yea, my lord; but I can cross it. + + + +DON JOHN +Any bar, any cross, any impediment will be +medicinable to me: I am sick in displeasure to him, +and whatsoever comes athwart his affection ranges +evenly with mine. How canst thou cross this marriage? + + + +BORACHIO +Not honestly, my lord; but so covertly that no +dishonesty shall appear in me. + + + +DON JOHN +Show me briefly how. + + + +BORACHIO +I think I told your lordship a year since, how much +I am in the favour of Margaret, the waiting +gentlewoman to Hero. + + + +DON JOHN +I remember. + + + +BORACHIO +I can, at any unseasonable instant of the night, +appoint her to look out at her lady's chamber window. + + + +DON JOHN +What life is in that, to be the death of this marriage? + + + +BORACHIO +The poison of that lies in you to temper. Go you to +the prince your brother; spare not to tell him that +he hath wronged his honour in marrying the renowned +Claudio--whose estimation do you mightily hold +up--to a contaminated stale, such a one as Hero. + + + +DON JOHN +What proof shall I make of that? + + + +BORACHIO +Proof enough to misuse the prince, to vex Claudio, +to undo Hero and kill Leonato. Look you for any +other issue? + + + +DON JOHN +Only to despite them, I will endeavour any thing. + + + +BORACHIO +Go, then; find me a meet hour to draw Don Pedro and +the Count Claudio alone: tell them that you know +that Hero loves me; intend a kind of zeal both to the +prince and Claudio, as,--in love of your brother's +honour, who hath made this match, and his friend's +reputation, who is thus like to be cozened with the +semblance of a maid,--that you have discovered +thus. They will scarcely believe this without trial: +offer them instances; which shall bear no less +likelihood than to see me at her chamber-window, +hear me call Margaret Hero, hear Margaret term me +Claudio; and bring them to see this the very night +before the intended wedding,--for in the meantime I +will so fashion the matter that Hero shall be +absent,--and there shall appear such seeming truth +of Hero's disloyalty that jealousy shall be called +assurance and all the preparation overthrown. + + + +DON JOHN +Grow this to what adverse issue it can, I will put +it in practise. Be cunning in the working this, and +thy fee is a thousand ducats. + + + +BORACHIO +Be you constant in the accusation, and my cunning +shall not shame me. + + + +DON JOHN +I will presently go learn their day of marriage. + + + +Exeunt + + +SCENE III. LEONATO'S orchard. +Enter BENEDICK + + +BENEDICK +Boy! + + + +Enter Boy + + +Boy +Signior? + + + +BENEDICK +In my chamber-window lies a book: bring it hither +to me in the orchard. + + + +Boy +I am here already, sir. + + + +BENEDICK +I know that; but I would have thee hence, and here again. +Exit Boy +I do much wonder that one man, seeing how much +another man is a fool when he dedicates his +behaviors to love, will, after he hath laughed at +such shallow follies in others, become the argument +of his own scorn by failing in love: and such a man +is Claudio. I have known when there was no music +with him but the drum and the fife; and now had he +rather hear the tabour and the pipe: I have known +when he would have walked ten mile a-foot to see a +good armour; and now will he lie ten nights awake, +carving the fashion of a new doublet. He was wont to +speak plain and to the purpose, like an honest man +and a soldier; and now is he turned orthography; his +words are a very fantastical banquet, just so many +strange dishes. May I be so converted and see with +these eyes? I cannot tell; I think not: I will not +be sworn, but love may transform me to an oyster; but +I'll take my oath on it, till he have made an oyster +of me, he shall never make me such a fool. One woman +is fair, yet I am well; another is wise, yet I am +well; another virtuous, yet I am well; but till all +graces be in one woman, one woman shall not come in +my grace. Rich she shall be, that's certain; wise, +or I'll none; virtuous, or I'll never cheapen her; +fair, or I'll never look on her; mild, or come not +near me; noble, or not I for an angel; of good +discourse, an excellent musician, and her hair shall +be of what colour it please God. Ha! the prince and +Monsieur Love! I will hide me in the arbour. + + +Withdraws +Enter DON PEDRO, CLAUDIO, and LEONATO + + +DON PEDRO +Come, shall we hear this music? + + + +CLAUDIO +Yea, my good lord. How still the evening is, +As hush'd on purpose to grace harmony! + + + +DON PEDRO +See you where Benedick hath hid himself? + + + +CLAUDIO +O, very well, my lord: the music ended, +We'll fit the kid-fox with a pennyworth. + + + +Enter BALTHASAR with Music + + +DON PEDRO +Come, Balthasar, we'll hear that song again. + + + +BALTHASAR +O, good my lord, tax not so bad a voice +To slander music any more than once. + + + +DON PEDRO +It is the witness still of excellency +To put a strange face on his own perfection. +I pray thee, sing, and let me woo no more. + + + +BALTHASAR +Because you talk of wooing, I will sing; +Since many a wooer doth commence his suit +To her he thinks not worthy, yet he wooes, +Yet will he swear he loves. + + + +DON PEDRO +Now, pray thee, come; +Or, if thou wilt hold longer argument, +Do it in notes. + + + +BALTHASAR +Note this before my notes; +There's not a note of mine that's worth the noting. + + + +DON PEDRO +Why, these are very crotchets that he speaks; +Note, notes, forsooth, and nothing. + + + +Air + + +BENEDICK +Now, divine air! now is his soul ravished! Is it +not strange that sheeps' guts should hale souls out +of men's bodies? Well, a horn for my money, when +all's done. + + + +The Song + + +BALTHASAR +Sigh no more, ladies, sigh no more, +Men were deceivers ever, +One foot in sea and one on shore, +To one thing constant never: +Then sigh not so, but let them go, +And be you blithe and bonny, +Converting all your sounds of woe +Into Hey nonny, nonny. +Sing no more ditties, sing no moe, +Of dumps so dull and heavy; +The fraud of men was ever so, +Since summer first was leafy: +Then sigh not so, &c. + + + +DON PEDRO +By my troth, a good song. + + + +BALTHASAR +And an ill singer, my lord. + + + +DON PEDRO +Ha, no, no, faith; thou singest well enough for a shift. + + + +BENEDICK +An he had been a dog that should have howled thus, +they would have hanged him: and I pray God his bad +voice bode no mischief. I had as lief have heard the +night-raven, come what plague could have come after +it. + + + +DON PEDRO +Yea, marry, dost thou hear, Balthasar? I pray thee, +get us some excellent music; for to-morrow night we +would have it at the Lady Hero's chamber-window. + + + +BALTHASAR +The best I can, my lord. + + + +DON PEDRO +Do so: farewell. +Exit BALTHASAR +Come hither, Leonato. What was it you told me of +to-day, that your niece Beatrice was in love with +Signior Benedick? + + + +CLAUDIO +O, ay: stalk on. stalk on; the fowl sits. I did +never think that lady would have loved any man. + + + +LEONATO +No, nor I neither; but most wonderful that she +should so dote on Signior Benedick, whom she hath in +all outward behaviors seemed ever to abhor. + + + +BENEDICK +Is't possible? Sits the wind in that corner? + + + +LEONATO +By my troth, my lord, I cannot tell what to think +of it but that she loves him with an enraged +affection: it is past the infinite of thought. + + + +DON PEDRO +May be she doth but counterfeit. + + + +CLAUDIO +Faith, like enough. + + + +LEONATO +O God, counterfeit! There was never counterfeit of +passion came so near the life of passion as she +discovers it. + + + +DON PEDRO +Why, what effects of passion shows she? + + + +CLAUDIO +Bait the hook well; this fish will bite. + + + +LEONATO +What effects, my lord? She will sit you, you heard +my daughter tell you how. + + + +CLAUDIO +She did, indeed. + + + +DON PEDRO +How, how, pray you? You amaze me: I would have I +thought her spirit had been invincible against all +assaults of affection. + + + +LEONATO +I would have sworn it had, my lord; especially +against Benedick. + + + +BENEDICK +I should think this a gull, but that the +white-bearded fellow speaks it: knavery cannot, +sure, hide himself in such reverence. + + + +CLAUDIO +He hath ta'en the infection: hold it up. + + + +DON PEDRO +Hath she made her affection known to Benedick? + + + +LEONATO +No; and swears she never will: that's her torment. + + + +CLAUDIO +'Tis true, indeed; so your daughter says: 'Shall +I,' says she, 'that have so oft encountered him +with scorn, write to him that I love him?' + + + +LEONATO +This says she now when she is beginning to write to +him; for she'll be up twenty times a night, and +there will she sit in her smock till she have writ a +sheet of paper: my daughter tells us all. + + + +CLAUDIO +Now you talk of a sheet of paper, I remember a +pretty jest your daughter told us of. + + + +LEONATO +O, when she had writ it and was reading it over, she +found Benedick and Beatrice between the sheet? + + + +CLAUDIO +That. + + + +LEONATO +O, she tore the letter into a thousand halfpence; +railed at herself, that she should be so immodest +to write to one that she knew would flout her; 'I +measure him,' says she, 'by my own spirit; for I +should flout him, if he writ to me; yea, though I +love him, I should.' + + + +CLAUDIO +Then down upon her knees she falls, weeps, sobs, +beats her heart, tears her hair, prays, curses; 'O +sweet Benedick! God give me patience!' + + + +LEONATO +She doth indeed; my daughter says so: and the +ecstasy hath so much overborne her that my daughter +is sometime afeared she will do a desperate outrage +to herself: it is very true. + + + +DON PEDRO +It were good that Benedick knew of it by some +other, if she will not discover it. + + + +CLAUDIO +To what end? He would make but a sport of it and +torment the poor lady worse. + + + +DON PEDRO +An he should, it were an alms to hang him. She's an +excellent sweet lady; and, out of all suspicion, +she is virtuous. + + + +CLAUDIO +And she is exceeding wise. + + + +DON PEDRO +In every thing but in loving Benedick. + + + +LEONATO +O, my lord, wisdom and blood combating in so tender +a body, we have ten proofs to one that blood hath +the victory. I am sorry for her, as I have just +cause, being her uncle and her guardian. + + + +DON PEDRO +I would she had bestowed this dotage on me: I would +have daffed all other respects and made her half +myself. I pray you, tell Benedick of it, and hear +what a' will say. + + + +LEONATO +Were it good, think you? + + + +CLAUDIO +Hero thinks surely she will die; for she says she +will die, if he love her not, and she will die, ere +she make her love known, and she will die, if he woo +her, rather than she will bate one breath of her +accustomed crossness. + + + +DON PEDRO +She doth well: if she should make tender of her +love, 'tis very possible he'll scorn it; for the +man, as you know all, hath a contemptible spirit. + + + +CLAUDIO +He is a very proper man. + + + +DON PEDRO +He hath indeed a good outward happiness. + + + +CLAUDIO +Before God! and, in my mind, very wise. + + + +DON PEDRO +He doth indeed show some sparks that are like wit. + + + +CLAUDIO +And I take him to be valiant. + + + +DON PEDRO +As Hector, I assure you: and in the managing of +quarrels you may say he is wise; for either he +avoids them with great discretion, or undertakes +them with a most Christian-like fear. + + + +LEONATO +If he do fear God, a' must necessarily keep peace: +if he break the peace, he ought to enter into a +quarrel with fear and trembling. + + + +DON PEDRO +And so will he do; for the man doth fear God, +howsoever it seems not in him by some large jests +he will make. Well I am sorry for your niece. Shall +we go seek Benedick, and tell him of her love? + + + +CLAUDIO +Never tell him, my lord: let her wear it out with +good counsel. + + + +LEONATO +Nay, that's impossible: she may wear her heart out first. + + + +DON PEDRO +Well, we will hear further of it by your daughter: +let it cool the while. I love Benedick well; and I +could wish he would modestly examine himself, to see +how much he is unworthy so good a lady. + + + +LEONATO +My lord, will you walk? dinner is ready. + + + +CLAUDIO +If he do not dote on her upon this, I will never +trust my expectation. + + + +DON PEDRO +Let there be the same net spread for her; and that +must your daughter and her gentlewomen carry. The +sport will be, when they hold one an opinion of +another's dotage, and no such matter: that's the +scene that I would see, which will be merely a +dumb-show. Let us send her to call him in to dinner. + + + +Exeunt DON PEDRO, CLAUDIO, and LEONATO + + +BENEDICK +Coming forward This can be no trick: the +conference was sadly borne. They have the truth of +this from Hero. They seem to pity the lady: it +seems her affections have their full bent. Love me! +why, it must be requited. I hear how I am censured: +they say I will bear myself proudly, if I perceive +the love come from her; they say too that she will +rather die than give any sign of affection. I did +never think to marry: I must not seem proud: happy +are they that hear their detractions and can put +them to mending. They say the lady is fair; 'tis a +truth, I can bear them witness; and virtuous; 'tis +so, I cannot reprove it; and wise, but for loving +me; by my troth, it is no addition to her wit, nor +no great argument of her folly, for I will be +horribly in love with her. I may chance have some +odd quirks and remnants of wit broken on me, +because I have railed so long against marriage: but +doth not the appetite alter? a man loves the meat +in his youth that he cannot endure in his age. +Shall quips and sentences and these paper bullets of +the brain awe a man from the career of his humour? +No, the world must be peopled. When I said I would +die a bachelor, I did not think I should live till I +were married. Here comes Beatrice. By this day! +she's a fair lady: I do spy some marks of love in +her. + + + +Enter BEATRICE + + +BEATRICE +Against my will I am sent to bid you come in to dinner. + + + +BENEDICK +Fair Beatrice, I thank you for your pains. + + + +BEATRICE +I took no more pains for those thanks than you take +pains to thank me: if it had been painful, I would +not have come. + + + +BENEDICK +You take pleasure then in the message? + + + +BEATRICE +Yea, just so much as you may take upon a knife's +point and choke a daw withal. You have no stomach, +signior: fare you well. + + + +Exit + + +BENEDICK +Ha! 'Against my will I am sent to bid you come in +to dinner;' there's a double meaning in that 'I took +no more pains for those thanks than you took pains +to thank me.' that's as much as to say, Any pains +that I take for you is as easy as thanks. If I do +not take pity of her, I am a villain; if I do not +love her, I am a Jew. I will go get her picture. + + + +Exit + + + + +ACT III + +SCENE I. LEONATO'S garden. +Enter HERO, MARGARET, and URSULA + + +HERO +Good Margaret, run thee to the parlor; +There shalt thou find my cousin Beatrice +Proposing with the prince and Claudio: +Whisper her ear and tell her, I and Ursula +Walk in the orchard and our whole discourse +Is all of her; say that thou overheard'st us; +And bid her steal into the pleached bower, +Where honeysuckles, ripen'd by the sun, +Forbid the sun to enter, like favourites, +Made proud by princes, that advance their pride +Against that power that bred it: there will she hide her, +To listen our purpose. This is thy office; +Bear thee well in it and leave us alone. + + + +MARGARET +I'll make her come, I warrant you, presently. + + + +Exit + + +HERO +Now, Ursula, when Beatrice doth come, +As we do trace this alley up and down, +Our talk must only be of Benedick. +When I do name him, let it be thy part +To praise him more than ever man did merit: +My talk to thee must be how Benedick +Is sick in love with Beatrice. Of this matter +Is little Cupid's crafty arrow made, +That only wounds by hearsay. +Enter BEATRICE, behind +Now begin; +For look where Beatrice, like a lapwing, runs +Close by the ground, to hear our conference. + + + +URSULA +The pleasant'st angling is to see the fish +Cut with her golden oars the silver stream, +And greedily devour the treacherous bait: +So angle we for Beatrice; who even now +Is couched in the woodbine coverture. +Fear you not my part of the dialogue. + + + +HERO +Then go we near her, that her ear lose nothing +Of the false sweet bait that we lay for it. +Approaching the bower +No, truly, Ursula, she is too disdainful; +I know her spirits are as coy and wild +As haggerds of the rock. + + + +URSULA +But are you sure +That Benedick loves Beatrice so entirely? + + + +HERO +So says the prince and my new-trothed lord. + + + +URSULA +And did they bid you tell her of it, madam? + + + +HERO +They did entreat me to acquaint her of it; +But I persuaded them, if they loved Benedick, +To wish him wrestle with affection, +And never to let Beatrice know of it. + + + +URSULA +Why did you so? Doth not the gentleman +Deserve as full as fortunate a bed +As ever Beatrice shall couch upon? + + + +HERO +O god of love! I know he doth deserve +As much as may be yielded to a man: +But Nature never framed a woman's heart +Of prouder stuff than that of Beatrice; +Disdain and scorn ride sparkling in her eyes, +Misprising what they look on, and her wit +Values itself so highly that to her +All matter else seems weak: she cannot love, +Nor take no shape nor project of affection, +She is so self-endeared. + + + +URSULA +Sure, I think so; +And therefore certainly it were not good +She knew his love, lest she make sport at it. + + + +HERO +Why, you speak truth. I never yet saw man, +How wise, how noble, young, how rarely featured, +But she would spell him backward: if fair-faced, +She would swear the gentleman should be her sister; +If black, why, Nature, drawing of an antique, +Made a foul blot; if tall, a lance ill-headed; +If low, an agate very vilely cut; +If speaking, why, a vane blown with all winds; +If silent, why, a block moved with none. +So turns she every man the wrong side out +And never gives to truth and virtue that +Which simpleness and merit purchaseth. + + + +URSULA +Sure, sure, such carping is not commendable. + + + +HERO +No, not to be so odd and from all fashions +As Beatrice is, cannot be commendable: +But who dare tell her so? If I should speak, +She would mock me into air; O, she would laugh me +Out of myself, press me to death with wit. +Therefore let Benedick, like cover'd fire, +Consume away in sighs, waste inwardly: +It were a better death than die with mocks, +Which is as bad as die with tickling. + + + +URSULA +Yet tell her of it: hear what she will say. + + + +HERO +No; rather I will go to Benedick +And counsel him to fight against his passion. +And, truly, I'll devise some honest slanders +To stain my cousin with: one doth not know +How much an ill word may empoison liking. + + + +URSULA +O, do not do your cousin such a wrong. +She cannot be so much without true judgment-- +Having so swift and excellent a wit +As she is prized to have--as to refuse +So rare a gentleman as Signior Benedick. + + + +HERO +He is the only man of Italy. +Always excepted my dear Claudio. + + + +URSULA +I pray you, be not angry with me, madam, +Speaking my fancy: Signior Benedick, +For shape, for bearing, argument and valour, +Goes foremost in report through Italy. + + + +HERO +Indeed, he hath an excellent good name. + + + +URSULA +His excellence did earn it, ere he had it. +When are you married, madam? + + + +HERO +Why, every day, to-morrow. Come, go in: +I'll show thee some attires, and have thy counsel +Which is the best to furnish me to-morrow. + + + +URSULA +She's limed, I warrant you: we have caught her, madam. + + + +HERO +If it proves so, then loving goes by haps: +Some Cupid kills with arrows, some with traps. + + + +Exeunt HERO and URSULA + + +BEATRICE +Coming forward +What fire is in mine ears? Can this be true? +Stand I condemn'd for pride and scorn so much? +Contempt, farewell! and maiden pride, adieu! +No glory lives behind the back of such. +And, Benedick, love on; I will requite thee, +Taming my wild heart to thy loving hand: +If thou dost love, my kindness shall incite thee +To bind our loves up in a holy band; +For others say thou dost deserve, and I +Believe it better than reportingly. + + + +Exit + + +SCENE II. A room in LEONATO'S house +Enter DON PEDRO, CLAUDIO, BENEDICK, and LEONATO + + +DON PEDRO +I do but stay till your marriage be consummate, and +then go I toward Arragon. + + + +CLAUDIO +I'll bring you thither, my lord, if you'll +vouchsafe me. + + + +DON PEDRO +Nay, that would be as great a soil in the new gloss +of your marriage as to show a child his new coat +and forbid him to wear it. I will only be bold +with Benedick for his company; for, from the crown +of his head to the sole of his foot, he is all +mirth: he hath twice or thrice cut Cupid's +bow-string and the little hangman dare not shoot at +him; he hath a heart as sound as a bell and his +tongue is the clapper, for what his heart thinks his +tongue speaks. + + + +BENEDICK +Gallants, I am not as I have been. + + + +LEONATO +So say I methinks you are sadder. + + + +CLAUDIO +I hope he be in love. + + + +DON PEDRO +Hang him, truant! there's no true drop of blood in +him, to be truly touched with love: if he be sad, +he wants money. + + + +BENEDICK +I have the toothache. + + + +DON PEDRO +Draw it. + + + +BENEDICK +Hang it! + + + +CLAUDIO +You must hang it first, and draw it afterwards. + + + +DON PEDRO +What! sigh for the toothache? + + + +LEONATO +Where is but a humour or a worm. + + + +BENEDICK +Well, every one can master a grief but he that has +it. + + + +CLAUDIO +Yet say I, he is in love. + + + +DON PEDRO +There is no appearance of fancy in him, unless it be +a fancy that he hath to strange disguises; as, to be +a Dutchman today, a Frenchman to-morrow, or in the +shape of two countries at once, as, a German from +the waist downward, all slops, and a Spaniard from +the hip upward, no doublet. Unless he have a fancy +to this foolery, as it appears he hath, he is no +fool for fancy, as you would have it appear he is. + + + +CLAUDIO +If he be not in love with some woman, there is no +believing old signs: a' brushes his hat o' +mornings; what should that bode? + + + +DON PEDRO +Hath any man seen him at the barber's? + + + +CLAUDIO +No, but the barber's man hath been seen with him, +and the old ornament of his cheek hath already +stuffed tennis-balls. + + + +LEONATO +Indeed, he looks younger than he did, by the loss of a beard. + + + +DON PEDRO +Nay, a' rubs himself with civet: can you smell him +out by that? + + + +CLAUDIO +That's as much as to say, the sweet youth's in love. + + + +DON PEDRO +The greatest note of it is his melancholy. + + + +CLAUDIO +And when was he wont to wash his face? + + + +DON PEDRO +Yea, or to paint himself? for the which, I hear +what they say of him. + + + +CLAUDIO +Nay, but his jesting spirit; which is now crept into +a lute-string and now governed by stops. + + + +DON PEDRO +Indeed, that tells a heavy tale for him: conclude, +conclude he is in love. + + + +CLAUDIO +Nay, but I know who loves him. + + + +DON PEDRO +That would I know too: I warrant, one that knows him not. + + + +CLAUDIO +Yes, and his ill conditions; and, in despite of +all, dies for him. + + + +DON PEDRO +She shall be buried with her face upwards. + + + +BENEDICK +Yet is this no charm for the toothache. Old +signior, walk aside with me: I have studied eight +or nine wise words to speak to you, which these +hobby-horses must not hear. + + + +Exeunt BENEDICK and LEONATO + + +DON PEDRO +For my life, to break with him about Beatrice. + + + +CLAUDIO +'Tis even so. Hero and Margaret have by this +played their parts with Beatrice; and then the two +bears will not bite one another when they meet. + + + +Enter DON JOHN + + +DON JOHN +My lord and brother, God save you! + + + +DON PEDRO +Good den, brother. + + + +DON JOHN +If your leisure served, I would speak with you. + + + +DON PEDRO +In private? + + + +DON JOHN +If it please you: yet Count Claudio may hear; for +what I would speak of concerns him. + + + +DON PEDRO +What's the matter? + + + +DON JOHN +To CLAUDIO Means your lordship to be married +to-morrow? + + + +DON PEDRO +You know he does. + + + +DON JOHN +I know not that, when he knows what I know. + + + +CLAUDIO +If there be any impediment, I pray you discover it. + + + +DON JOHN +You may think I love you not: let that appear +hereafter, and aim better at me by that I now will +manifest. For my brother, I think he holds you +well, and in dearness of heart hath holp to effect +your ensuing marriage;--surely suit ill spent and +labour ill bestowed. + + + +DON PEDRO +Why, what's the matter? + + + +DON JOHN +I came hither to tell you; and, circumstances +shortened, for she has been too long a talking of, +the lady is disloyal. + + + +CLAUDIO +Who, Hero? + + + +DON PEDRO +Even she; Leonato's Hero, your Hero, every man's Hero: + + + +CLAUDIO +Disloyal? + + + +DON JOHN +The word is too good to paint out her wickedness; I +could say she were worse: think you of a worse +title, and I will fit her to it. Wonder not till +further warrant: go but with me to-night, you shall +see her chamber-window entered, even the night +before her wedding-day: if you love her then, +to-morrow wed her; but it would better fit your honour +to change your mind. + + + +CLAUDIO +May this be so? + + + +DON PEDRO +I will not think it. + + + +DON JOHN +If you dare not trust that you see, confess not +that you know: if you will follow me, I will show +you enough; and when you have seen more and heard +more, proceed accordingly. + + + +CLAUDIO +If I see any thing to-night why I should not marry +her to-morrow in the congregation, where I should +wed, there will I shame her. + + + +DON PEDRO +And, as I wooed for thee to obtain her, I will join +with thee to disgrace her. + + + +DON JOHN +I will disparage her no farther till you are my +witnesses: bear it coldly but till midnight, and +let the issue show itself. + + + +DON PEDRO +O day untowardly turned! + + + +CLAUDIO +O mischief strangely thwarting! + + + +DON JOHN +O plague right well prevented! so will you say when +you have seen the sequel. + + + +Exeunt + + +SCENE III. A street. +Enter DOGBERRY and VERGES with the Watch + + +DOGBERRY +Are you good men and true? + + + +VERGES +Yea, or else it were pity but they should suffer +salvation, body and soul. + + + +DOGBERRY +Nay, that were a punishment too good for them, if +they should have any allegiance in them, being +chosen for the prince's watch. + + + +VERGES +Well, give them their charge, neighbour Dogberry. + + + +DOGBERRY +First, who think you the most desertless man to be +constable? + + + +First Watchman +Hugh Otecake, sir, or George Seacole; for they can +write and read. + + + +DOGBERRY +Come hither, neighbour Seacole. God hath blessed +you with a good name: to be a well-favoured man is +the gift of fortune; but to write and read comes by nature. + + + +Second Watchman +Both which, master constable,-- + + + +DOGBERRY +You have: I knew it would be your answer. Well, +for your favour, sir, why, give God thanks, and make +no boast of it; and for your writing and reading, +let that appear when there is no need of such +vanity. You are thought here to be the most +senseless and fit man for the constable of the +watch; therefore bear you the lantern. This is your +charge: you shall comprehend all vagrom men; you are +to bid any man stand, in the prince's name. + + + +Second Watchman +How if a' will not stand? + + + +DOGBERRY +Why, then, take no note of him, but let him go; and +presently call the rest of the watch together and +thank God you are rid of a knave. + + + +VERGES +If he will not stand when he is bidden, he is none +of the prince's subjects. + + + +DOGBERRY +True, and they are to meddle with none but the +prince's subjects. You shall also make no noise in +the streets; for, for the watch to babble and to +talk is most tolerable and not to be endured. + + + +Watchman +We will rather sleep than talk: we know what +belongs to a watch. + + + +DOGBERRY +Why, you speak like an ancient and most quiet +watchman; for I cannot see how sleeping should +offend: only, have a care that your bills be not +stolen. Well, you are to call at all the +ale-houses, and bid those that are drunk get them to bed. + + + +Watchman +How if they will not? + + + +DOGBERRY +Why, then, let them alone till they are sober: if +they make you not then the better answer, you may +say they are not the men you took them for. + + + +Watchman +Well, sir. + + + +DOGBERRY +If you meet a thief, you may suspect him, by virtue +of your office, to be no true man; and, for such +kind of men, the less you meddle or make with them, +why the more is for your honesty. + + + +Watchman +If we know him to be a thief, shall we not lay +hands on him? + + + +DOGBERRY +Truly, by your office, you may; but I think they +that touch pitch will be defiled: the most peaceable +way for you, if you do take a thief, is to let him +show himself what he is and steal out of your company. + + + +VERGES +You have been always called a merciful man, partner. + + + +DOGBERRY +Truly, I would not hang a dog by my will, much more +a man who hath any honesty in him. + + + +VERGES +If you hear a child cry in the night, you must call +to the nurse and bid her still it. + + + +Watchman +How if the nurse be asleep and will not hear us? + + + +DOGBERRY +Why, then, depart in peace, and let the child wake +her with crying; for the ewe that will not hear her +lamb when it baes will never answer a calf when he bleats. + + + +VERGES +'Tis very true. + + + +DOGBERRY +This is the end of the charge:--you, constable, are +to present the prince's own person: if you meet the +prince in the night, you may stay him. + + + +VERGES +Nay, by'r our lady, that I think a' cannot. + + + +DOGBERRY +Five shillings to one on't, with any man that knows +the statutes, he may stay him: marry, not without +the prince be willing; for, indeed, the watch ought +to offend no man; and it is an offence to stay a +man against his will. + + + +VERGES +By'r lady, I think it be so. + + + +DOGBERRY +Ha, ha, ha! Well, masters, good night: an there be +any matter of weight chances, call up me: keep your +fellows' counsels and your own; and good night. +Come, neighbour. + + + +Watchman +Well, masters, we hear our charge: let us go sit here +upon the church-bench till two, and then all to bed. + + + +DOGBERRY +One word more, honest neighbours. I pray you watch +about Signior Leonato's door; for the wedding being +there to-morrow, there is a great coil to-night. +Adieu: be vigitant, I beseech you. + + +Exeunt DOGBERRY and VERGES +Enter BORACHIO and CONRADE + + +BORACHIO +What Conrade! + + + +Watchman +Aside Peace! stir not. + + + +BORACHIO +Conrade, I say! + + + +CONRADE +Here, man; I am at thy elbow. + + + +BORACHIO +Mass, and my elbow itched; I thought there would a +scab follow. + + + +CONRADE +I will owe thee an answer for that: and now forward +with thy tale. + + + +BORACHIO +Stand thee close, then, under this pent-house, for +it drizzles rain; and I will, like a true drunkard, +utter all to thee. + + + +Watchman +Aside Some treason, masters: yet stand close. + + + +BORACHIO +Therefore know I have earned of Don John a thousand ducats. + + + +CONRADE +Is it possible that any villany should be so dear? + + + +BORACHIO +Thou shouldst rather ask if it were possible any +villany should be so rich; for when rich villains +have need of poor ones, poor ones may make what +price they will. + + + +CONRADE +I wonder at it. + + + +BORACHIO +That shows thou art unconfirmed. Thou knowest that +the fashion of a doublet, or a hat, or a cloak, is +nothing to a man. + + + +CONRADE +Yes, it is apparel. + + + +BORACHIO +I mean, the fashion. + + + +CONRADE +Yes, the fashion is the fashion. + + + +BORACHIO +Tush! I may as well say the fool's the fool. But +seest thou not what a deformed thief this fashion +is? + + + +Watchman +Aside I know that Deformed; a' has been a vile +thief this seven year; a' goes up and down like a +gentleman: I remember his name. + + + +BORACHIO +Didst thou not hear somebody? + + + +CONRADE +No; 'twas the vane on the house. + + + +BORACHIO +Seest thou not, I say, what a deformed thief this +fashion is? how giddily a' turns about all the hot +bloods between fourteen and five-and-thirty? +sometimes fashioning them like Pharaoh's soldiers +in the reeky painting, sometime like god Bel's +priests in the old church-window, sometime like the +shaven Hercules in the smirched worm-eaten tapestry, +where his codpiece seems as massy as his club? + + + +CONRADE +All this I see; and I see that the fashion wears +out more apparel than the man. But art not thou +thyself giddy with the fashion too, that thou hast +shifted out of thy tale into telling me of the fashion? + + + +BORACHIO +Not so, neither: but know that I have to-night +wooed Margaret, the Lady Hero's gentlewoman, by the +name of Hero: she leans me out at her mistress' +chamber-window, bids me a thousand times good +night,--I tell this tale vilely:--I should first +tell thee how the prince, Claudio and my master, +planted and placed and possessed by my master Don +John, saw afar off in the orchard this amiable encounter. + + + +CONRADE +And thought they Margaret was Hero? + + + +BORACHIO +Two of them did, the prince and Claudio; but the +devil my master knew she was Margaret; and partly +by his oaths, which first possessed them, partly by +the dark night, which did deceive them, but chiefly +by my villany, which did confirm any slander that +Don John had made, away went Claudio enraged; swore +he would meet her, as he was appointed, next morning +at the temple, and there, before the whole +congregation, shame her with what he saw o'er night +and send her home again without a husband. + + + +First Watchman +We charge you, in the prince's name, stand! + + + +Second Watchman +Call up the right master constable. We have here +recovered the most dangerous piece of lechery that +ever was known in the commonwealth. + + + +First Watchman +And one Deformed is one of them: I know him; a' +wears a lock. + + + +CONRADE +Masters, masters,-- + + + +Second Watchman +You'll be made bring Deformed forth, I warrant you. + + + +CONRADE +Masters,-- + + + +First Watchman +Never speak: we charge you let us obey you to go with us. + + + +BORACHIO +We are like to prove a goodly commodity, being taken +up of these men's bills. + + + +CONRADE +A commodity in question, I warrant you. Come, we'll obey you. + + + +Exeunt + + +SCENE IV. HERO's apartment. +Enter HERO, MARGARET, and URSULA + + +HERO +Good Ursula, wake my cousin Beatrice, and desire +her to rise. + + + +URSULA +I will, lady. + + + +HERO +And bid her come hither. + + + +URSULA +Well. + + + +Exit + + +MARGARET +Troth, I think your other rabato were better. + + + +HERO +No, pray thee, good Meg, I'll wear this. + + + +MARGARET +By my troth, 's not so good; and I warrant your +cousin will say so. + + + +HERO +My cousin's a fool, and thou art another: I'll wear +none but this. + + + +MARGARET +I like the new tire within excellently, if the hair +were a thought browner; and your gown's a most rare +fashion, i' faith. I saw the Duchess of Milan's +gown that they praise so. + + + +HERO +O, that exceeds, they say. + + + +MARGARET +By my troth, 's but a night-gown in respect of +yours: cloth o' gold, and cuts, and laced with +silver, set with pearls, down sleeves, side sleeves, +and skirts, round underborne with a bluish tinsel: +but for a fine, quaint, graceful and excellent +fashion, yours is worth ten on 't. + + + +HERO +God give me joy to wear it! for my heart is +exceeding heavy. + + + +MARGARET +'Twill be heavier soon by the weight of a man. + + + +HERO +Fie upon thee! art not ashamed? + + + +MARGARET +Of what, lady? of speaking honourably? Is not +marriage honourable in a beggar? Is not your lord +honourable without marriage? I think you would have +me say, 'saving your reverence, a husband:' and bad +thinking do not wrest true speaking, I'll offend +nobody: is there any harm in 'the heavier for a +husband'? None, I think, and it be the right husband +and the right wife; otherwise 'tis light, and not +heavy: ask my Lady Beatrice else; here she comes. + + + +Enter BEATRICE + + +HERO +Good morrow, coz. + + + +BEATRICE +Good morrow, sweet Hero. + + + +HERO +Why how now? do you speak in the sick tune? + + + +BEATRICE +I am out of all other tune, methinks. + + + +MARGARET +Clap's into 'Light o' love;' that goes without a +burden: do you sing it, and I'll dance it. + + + +BEATRICE +Ye light o' love, with your heels! then, if your +husband have stables enough, you'll see he shall +lack no barns. + + + +MARGARET +O illegitimate construction! I scorn that with my heels. + + + +BEATRICE +'Tis almost five o'clock, cousin; tis time you were +ready. By my troth, I am exceeding ill: heigh-ho! + + + +MARGARET +For a hawk, a horse, or a husband? + + + +BEATRICE +For the letter that begins them all, H. + + + +MARGARET +Well, and you be not turned Turk, there's no more +sailing by the star. + + + +BEATRICE +What means the fool, trow? + + + +MARGARET +Nothing I; but God send every one their heart's desire! + + + +HERO +These gloves the count sent me; they are an +excellent perfume. + + + +BEATRICE +I am stuffed, cousin; I cannot smell. + + + +MARGARET +A maid, and stuffed! there's goodly catching of cold. + + + +BEATRICE +O, God help me! God help me! how long have you +professed apprehension? + + + +MARGARET +Even since you left it. Doth not my wit become me rarely? + + + +BEATRICE +It is not seen enough, you should wear it in your +cap. By my troth, I am sick. + + + +MARGARET +Get you some of this distilled Carduus Benedictus, +and lay it to your heart: it is the only thing for a qualm. + + + +HERO +There thou prickest her with a thistle. + + + +BEATRICE +Benedictus! why Benedictus? you have some moral in +this Benedictus. + + + +MARGARET +Moral! no, by my troth, I have no moral meaning; I +meant, plain holy-thistle. You may think perchance +that I think you are in love: nay, by'r lady, I am +not such a fool to think what I list, nor I list +not to think what I can, nor indeed I cannot think, +if I would think my heart out of thinking, that you +are in love or that you will be in love or that you +can be in love. Yet Benedick was such another, and +now is he become a man: he swore he would never +marry, and yet now, in despite of his heart, he eats +his meat without grudging: and how you may be +converted I know not, but methinks you look with +your eyes as other women do. + + + +BEATRICE +What pace is this that thy tongue keeps? + + + +MARGARET +Not a false gallop. + + + +Re-enter URSULA + + +URSULA +Madam, withdraw: the prince, the count, Signior +Benedick, Don John, and all the gallants of the +town, are come to fetch you to church. + + + +HERO +Help to dress me, good coz, good Meg, good Ursula. + + + +Exeunt + + +SCENE V. Another room in LEONATO'S house. +Enter LEONATO, with DOGBERRY and VERGES + + +LEONATO +What would you with me, honest neighbour? + + + +DOGBERRY +Marry, sir, I would have some confidence with you +that decerns you nearly. + + + +LEONATO +Brief, I pray you; for you see it is a busy time with me. + + + +DOGBERRY +Marry, this it is, sir. + + + +VERGES +Yes, in truth it is, sir. + + + +LEONATO +What is it, my good friends? + + + +DOGBERRY +Goodman Verges, sir, speaks a little off the +matter: an old man, sir, and his wits are not so +blunt as, God help, I would desire they were; but, +in faith, honest as the skin between his brows. + + + +VERGES +Yes, I thank God I am as honest as any man living +that is an old man and no honester than I. + + + +DOGBERRY +Comparisons are odorous: palabras, neighbour Verges. + + + +LEONATO +Neighbours, you are tedious. + + + +DOGBERRY +It pleases your worship to say so, but we are the +poor duke's officers; but truly, for mine own part, +if I were as tedious as a king, I could find it in +my heart to bestow it all of your worship. + + + +LEONATO +All thy tediousness on me, ah? + + + +DOGBERRY +Yea, an 'twere a thousand pound more than 'tis; for +I hear as good exclamation on your worship as of any +man in the city; and though I be but a poor man, I +am glad to hear it. + + + +VERGES +And so am I. + + + +LEONATO +I would fain know what you have to say. + + + +VERGES +Marry, sir, our watch to-night, excepting your +worship's presence, ha' ta'en a couple of as arrant +knaves as any in Messina. + + + +DOGBERRY +A good old man, sir; he will be talking: as they +say, when the age is in, the wit is out: God help +us! it is a world to see. Well said, i' faith, +neighbour Verges: well, God's a good man; an two men +ride of a horse, one must ride behind. An honest +soul, i' faith, sir; by my troth he is, as ever +broke bread; but God is to be worshipped; all men +are not alike; alas, good neighbour! + + + +LEONATO +Indeed, neighbour, he comes too short of you. + + + +DOGBERRY +Gifts that God gives. + + + +LEONATO +I must leave you. + + + +DOGBERRY +One word, sir: our watch, sir, have indeed +comprehended two aspicious persons, and we would +have them this morning examined before your worship. + + + +LEONATO +Take their examination yourself and bring it me: I +am now in great haste, as it may appear unto you. + + + +DOGBERRY +It shall be suffigance. + + + +LEONATO +Drink some wine ere you go: fare you well. + + + +Enter a Messenger + + +Messenger +My lord, they stay for you to give your daughter to +her husband. + + + +LEONATO +I'll wait upon them: I am ready. + + + +Exeunt LEONATO and Messenger + + +DOGBERRY +Go, good partner, go, get you to Francis Seacole; +bid him bring his pen and inkhorn to the gaol: we +are now to examination these men. + + + +VERGES +And we must do it wisely. + + + +DOGBERRY +We will spare for no wit, I warrant you; here's +that shall drive some of them to a non-come: only +get the learned writer to set down our +excommunication and meet me at the gaol. + + + +Exeunt + + + + +ACT IV + +SCENE I. A church. +Enter DON PEDRO, DON JOHN, LEONATO, FRIAR FRANCIS, +CLAUDIO, BENEDICK, HERO, BEATRICE, and Attendants + + +LEONATO +Come, Friar Francis, be brief; only to the plain +form of marriage, and you shall recount their +particular duties afterwards. + + + +FRIAR FRANCIS +You come hither, my lord, to marry this lady. + + + +CLAUDIO +No. + + + +LEONATO +To be married to her: friar, you come to marry her. + + + +FRIAR FRANCIS +Lady, you come hither to be married to this count. + + + +HERO +I do. + + + +FRIAR FRANCIS +If either of you know any inward impediment why you +should not be conjoined, charge you, on your souls, +to utter it. + + + +CLAUDIO +Know you any, Hero? + + + +HERO +None, my lord. + + + +FRIAR FRANCIS +Know you any, count? + + + +LEONATO +I dare make his answer, none. + + + +CLAUDIO +O, what men dare do! what men may do! what men daily +do, not knowing what they do! + + + +BENEDICK +How now! interjections? Why, then, some be of +laughing, as, ah, ha, he! + + + +CLAUDIO +Stand thee by, friar. Father, by your leave: +Will you with free and unconstrained soul +Give me this maid, your daughter? + + + +LEONATO +As freely, son, as God did give her me. + + + +CLAUDIO +And what have I to give you back, whose worth +May counterpoise this rich and precious gift? + + + +DON PEDRO +Nothing, unless you render her again. + + + +CLAUDIO +Sweet prince, you learn me noble thankfulness. +There, Leonato, take her back again: +Give not this rotten orange to your friend; +She's but the sign and semblance of her honour. +Behold how like a maid she blushes here! +O, what authority and show of truth +Can cunning sin cover itself withal! +Comes not that blood as modest evidence +To witness simple virtue? Would you not swear, +All you that see her, that she were a maid, +By these exterior shows? But she is none: +She knows the heat of a luxurious bed; +Her blush is guiltiness, not modesty. + + + +LEONATO +What do you mean, my lord? + + + +CLAUDIO +Not to be married, +Not to knit my soul to an approved wanton. + + + +LEONATO +Dear my lord, if you, in your own proof, +Have vanquish'd the resistance of her youth, +And made defeat of her virginity,-- + + + +CLAUDIO +I know what you would say: if I have known her, +You will say she did embrace me as a husband, +And so extenuate the 'forehand sin: +No, Leonato, +I never tempted her with word too large; +But, as a brother to his sister, show'd +Bashful sincerity and comely love. + + + +HERO +And seem'd I ever otherwise to you? + + + +CLAUDIO +Out on thee! Seeming! I will write against it: +You seem to me as Dian in her orb, +As chaste as is the bud ere it be blown; +But you are more intemperate in your blood +Than Venus, or those pamper'd animals +That rage in savage sensuality. + + + +HERO +Is my lord well, that he doth speak so wide? + + + +LEONATO +Sweet prince, why speak not you? + + + +DON PEDRO +What should I speak? +I stand dishonour'd, that have gone about +To link my dear friend to a common stale. + + + +LEONATO +Are these things spoken, or do I but dream? + + + +DON JOHN +Sir, they are spoken, and these things are true. + + + +BENEDICK +This looks not like a nuptial. + + + +HERO +True! O God! + + + +CLAUDIO +Leonato, stand I here? +Is this the prince? is this the prince's brother? +Is this face Hero's? are our eyes our own? + + + +LEONATO +All this is so: but what of this, my lord? + + + +CLAUDIO +Let me but move one question to your daughter; +And, by that fatherly and kindly power +That you have in her, bid her answer truly. + + + +LEONATO +I charge thee do so, as thou art my child. + + + +HERO +O, God defend me! how am I beset! +What kind of catechising call you this? + + + +CLAUDIO +To make you answer truly to your name. + + + +HERO +Is it not Hero? Who can blot that name +With any just reproach? + + + +CLAUDIO +Marry, that can Hero; +Hero itself can blot out Hero's virtue. +What man was he talk'd with you yesternight +Out at your window betwixt twelve and one? +Now, if you are a maid, answer to this. + + + +HERO +I talk'd with no man at that hour, my lord. + + + +DON PEDRO +Why, then are you no maiden. Leonato, +I am sorry you must hear: upon mine honour, +Myself, my brother and this grieved count +Did see her, hear her, at that hour last night +Talk with a ruffian at her chamber-window +Who hath indeed, most like a liberal villain, +Confess'd the vile encounters they have had +A thousand times in secret. + + + +DON JOHN +Fie, fie! they are not to be named, my lord, +Not to be spoke of; +There is not chastity enough in language +Without offence to utter them. Thus, pretty lady, +I am sorry for thy much misgovernment. + + + +CLAUDIO +O Hero, what a Hero hadst thou been, +If half thy outward graces had been placed +About thy thoughts and counsels of thy heart! +But fare thee well, most foul, most fair! farewell, +Thou pure impiety and impious purity! +For thee I'll lock up all the gates of love, +And on my eyelids shall conjecture hang, +To turn all beauty into thoughts of harm, +And never shall it more be gracious. + + + +LEONATO +Hath no man's dagger here a point for me? + + + +HERO swoons + + +BEATRICE +Why, how now, cousin! wherefore sink you down? + + + +DON JOHN +Come, let us go. These things, come thus to light, +Smother her spirits up. + + + +Exeunt DON PEDRO, DON JOHN, and CLAUDIO + + +BENEDICK +How doth the lady? + + + +BEATRICE +Dead, I think. Help, uncle! +Hero! why, Hero! Uncle! Signior Benedick! Friar! + + + +LEONATO +O Fate! take not away thy heavy hand. +Death is the fairest cover for her shame +That may be wish'd for. + + + +BEATRICE +How now, cousin Hero! + + + +FRIAR FRANCIS +Have comfort, lady. + + + +LEONATO +Dost thou look up? + + + +FRIAR FRANCIS +Yea, wherefore should she not? + + + +LEONATO +Wherefore! Why, doth not every earthly thing +Cry shame upon her? Could she here deny +The story that is printed in her blood? +Do not live, Hero; do not ope thine eyes: +For, did I think thou wouldst not quickly die, +Thought I thy spirits were stronger than thy shames, +Myself would, on the rearward of reproaches, +Strike at thy life. Grieved I, I had but one? +Chid I for that at frugal nature's frame? +O, one too much by thee! Why had I one? +Why ever wast thou lovely in my eyes? +Why had I not with charitable hand +Took up a beggar's issue at my gates, +Who smirch'd thus and mired with infamy, +I might have said 'No part of it is mine; +This shame derives itself from unknown loins'? +But mine and mine I loved and mine I praised +And mine that I was proud on, mine so much +That I myself was to myself not mine, +Valuing of her,--why, she, O, she is fallen +Into a pit of ink, that the wide sea +Hath drops too few to wash her clean again +And salt too little which may season give +To her foul-tainted flesh! + + + +BENEDICK +Sir, sir, be patient. +For my part, I am so attired in wonder, +I know not what to say. + + + +BEATRICE +O, on my soul, my cousin is belied! + + + +BENEDICK +Lady, were you her bedfellow last night? + + + +BEATRICE +No, truly not; although, until last night, +I have this twelvemonth been her bedfellow. + + + +LEONATO +Confirm'd, confirm'd! O, that is stronger made +Which was before barr'd up with ribs of iron! +Would the two princes lie, and Claudio lie, +Who loved her so, that, speaking of her foulness, +Wash'd it with tears? Hence from her! let her die. + + + +FRIAR FRANCIS +Hear me a little; for I have only been +Silent so long and given way unto +This course of fortune +By noting of the lady. I have mark'd +A thousand blushing apparitions +To start into her face, a thousand innocent shames +In angel whiteness beat away those blushes; +And in her eye there hath appear'd a fire, +To burn the errors that these princes hold +Against her maiden truth. Call me a fool; +Trust not my reading nor my observations, +Which with experimental seal doth warrant +The tenor of my book; trust not my age, +My reverence, calling, nor divinity, +If this sweet lady lie not guiltless here +Under some biting error. + + + +LEONATO +Friar, it cannot be. +Thou seest that all the grace that she hath left +Is that she will not add to her damnation +A sin of perjury; she not denies it: +Why seek'st thou then to cover with excuse +That which appears in proper nakedness? + + + +FRIAR FRANCIS +Lady, what man is he you are accused of? + + + +HERO +They know that do accuse me; I know none: +If I know more of any man alive +Than that which maiden modesty doth warrant, +Let all my sins lack mercy! O my father, +Prove you that any man with me conversed +At hours unmeet, or that I yesternight +Maintain'd the change of words with any creature, +Refuse me, hate me, torture me to death! + + + +FRIAR FRANCIS +There is some strange misprision in the princes. + + + +BENEDICK +Two of them have the very bent of honour; +And if their wisdoms be misled in this, +The practise of it lives in John the bastard, +Whose spirits toil in frame of villanies. + + + +LEONATO +I know not. If they speak but truth of her, +These hands shall tear her; if they wrong her honour, +The proudest of them shall well hear of it. +Time hath not yet so dried this blood of mine, +Nor age so eat up my invention, +Nor fortune made such havoc of my means, +Nor my bad life reft me so much of friends, +But they shall find, awaked in such a kind, +Both strength of limb and policy of mind, +Ability in means and choice of friends, +To quit me of them throughly. + + + +FRIAR FRANCIS +Pause awhile, +And let my counsel sway you in this case. +Your daughter here the princes left for dead: +Let her awhile be secretly kept in, +And publish it that she is dead indeed; +Maintain a mourning ostentation +And on your family's old monument +Hang mournful epitaphs and do all rites +That appertain unto a burial. + + + +LEONATO +What shall become of this? what will this do? + + + +FRIAR FRANCIS +Marry, this well carried shall on her behalf +Change slander to remorse; that is some good: +But not for that dream I on this strange course, +But on this travail look for greater birth. +She dying, as it must so be maintain'd, +Upon the instant that she was accused, +Shall be lamented, pitied and excused +Of every hearer: for it so falls out +That what we have we prize not to the worth +Whiles we enjoy it, but being lack'd and lost, +Why, then we rack the value, then we find +The virtue that possession would not show us +Whiles it was ours. So will it fare with Claudio: +When he shall hear she died upon his words, +The idea of her life shall sweetly creep +Into his study of imagination, +And every lovely organ of her life +Shall come apparell'd in more precious habit, +More moving-delicate and full of life, +Into the eye and prospect of his soul, +Than when she lived indeed; then shall he mourn, +If ever love had interest in his liver, +And wish he had not so accused her, +No, though he thought his accusation true. +Let this be so, and doubt not but success +Will fashion the event in better shape +Than I can lay it down in likelihood. +But if all aim but this be levell'd false, +The supposition of the lady's death +Will quench the wonder of her infamy: +And if it sort not well, you may conceal her, +As best befits her wounded reputation, +In some reclusive and religious life, +Out of all eyes, tongues, minds and injuries. + + + +BENEDICK +Signior Leonato, let the friar advise you: +And though you know my inwardness and love +Is very much unto the prince and Claudio, +Yet, by mine honour, I will deal in this +As secretly and justly as your soul +Should with your body. + + + +LEONATO +Being that I flow in grief, +The smallest twine may lead me. + + + +FRIAR FRANCIS +'Tis well consented: presently away; +For to strange sores strangely they strain the cure. +Come, lady, die to live: this wedding-day +Perhaps is but prolong'd: have patience and endure. + + + +Exeunt all but BENEDICK and BEATRICE + + +BENEDICK +Lady Beatrice, have you wept all this while? + + + +BEATRICE +Yea, and I will weep a while longer. + + + +BENEDICK +I will not desire that. + + + +BEATRICE +You have no reason; I do it freely. + + + +BENEDICK +Surely I do believe your fair cousin is wronged. + + + +BEATRICE +Ah, how much might the man deserve of me that would right her! + + + +BENEDICK +Is there any way to show such friendship? + + + +BEATRICE +A very even way, but no such friend. + + + +BENEDICK +May a man do it? + + + +BEATRICE +It is a man's office, but not yours. + + + +BENEDICK +I do love nothing in the world so well as you: is +not that strange? + + + +BEATRICE +As strange as the thing I know not. It were as +possible for me to say I loved nothing so well as +you: but believe me not; and yet I lie not; I +confess nothing, nor I deny nothing. I am sorry for my cousin. + + + +BENEDICK +By my sword, Beatrice, thou lovest me. + + + +BEATRICE +Do not swear, and eat it. + + + +BENEDICK +I will swear by it that you love me; and I will make +him eat it that says I love not you. + + + +BEATRICE +Will you not eat your word? + + + +BENEDICK +With no sauce that can be devised to it. I protest +I love thee. + + + +BEATRICE +Why, then, God forgive me! + + + +BENEDICK +What offence, sweet Beatrice? + + + +BEATRICE +You have stayed me in a happy hour: I was about to +protest I loved you. + + + +BENEDICK +And do it with all thy heart. + + + +BEATRICE +I love you with so much of my heart that none is +left to protest. + + + +BENEDICK +Come, bid me do any thing for thee. + + + +BEATRICE +Kill Claudio. + + + +BENEDICK +Ha! not for the wide world. + + + +BEATRICE +You kill me to deny it. Farewell. + + + +BENEDICK +Tarry, sweet Beatrice. + + + +BEATRICE +I am gone, though I am here: there is no love in +you: nay, I pray you, let me go. + + + +BENEDICK +Beatrice,-- + + + +BEATRICE +In faith, I will go. + + + +BENEDICK +We'll be friends first. + + + +BEATRICE +You dare easier be friends with me than fight with mine enemy. + + + +BENEDICK +Is Claudio thine enemy? + + + +BEATRICE +Is he not approved in the height a villain, that +hath slandered, scorned, dishonoured my kinswoman? O +that I were a man! What, bear her in hand until they +come to take hands; and then, with public +accusation, uncovered slander, unmitigated rancour, +--O God, that I were a man! I would eat his heart +in the market-place. + + + +BENEDICK +Hear me, Beatrice,-- + + + +BEATRICE +Talk with a man out at a window! A proper saying! + + + +BENEDICK +Nay, but, Beatrice,-- + + + +BEATRICE +Sweet Hero! She is wronged, she is slandered, she is undone. + + + +BENEDICK +Beat-- + + + +BEATRICE +Princes and counties! Surely, a princely testimony, +a goodly count, Count Comfect; a sweet gallant, +surely! O that I were a man for his sake! or that I +had any friend would be a man for my sake! But +manhood is melted into courtesies, valour into +compliment, and men are only turned into tongue, and +trim ones too: he is now as valiant as Hercules +that only tells a lie and swears it. I cannot be a +man with wishing, therefore I will die a woman with grieving. + + + +BENEDICK +Tarry, good Beatrice. By this hand, I love thee. + + + +BEATRICE +Use it for my love some other way than swearing by it. + + + +BENEDICK +Think you in your soul the Count Claudio hath wronged Hero? + + + +BEATRICE +Yea, as sure as I have a thought or a soul. + + + +BENEDICK +Enough, I am engaged; I will challenge him. I will +kiss your hand, and so I leave you. By this hand, +Claudio shall render me a dear account. As you +hear of me, so think of me. Go, comfort your +cousin: I must say she is dead: and so, farewell. + + + +Exeunt + + +SCENE II. A prison. +Enter DOGBERRY, VERGES, and Sexton, in gowns; and +the Watch, with CONRADE and BORACHIO + + +DOGBERRY +Is our whole dissembly appeared? + + + +VERGES +O, a stool and a cushion for the sexton. + + + +Sexton +Which be the malefactors? + + + +DOGBERRY +Marry, that am I and my partner. + + + +VERGES +Nay, that's certain; we have the exhibition to examine. + + + +Sexton +But which are the offenders that are to be +examined? let them come before master constable. + + + +DOGBERRY +Yea, marry, let them come before me. What is your +name, friend? + + + +BORACHIO +Borachio. + + + +DOGBERRY +Pray, write down, Borachio. Yours, sirrah? + + + +CONRADE +I am a gentleman, sir, and my name is Conrade. + + + +DOGBERRY +Write down, master gentleman Conrade. Masters, do +you serve God? + + + +CONRADE +BORACHIO +Yea, sir, we hope. + + + +DOGBERRY +Write down, that they hope they serve God: and +write God first; for God defend but God should go +before such villains! Masters, it is proved already +that you are little better than false knaves; and it +will go near to be thought so shortly. How answer +you for yourselves? + + + +CONRADE +Marry, sir, we say we are none. + + + +DOGBERRY +A marvellous witty fellow, I assure you: but I +will go about with him. Come you hither, sirrah; a +word in your ear: sir, I say to you, it is thought +you are false knaves. + + + +BORACHIO +Sir, I say to you we are none. + + + +DOGBERRY +Well, stand aside. 'Fore God, they are both in a +tale. Have you writ down, that they are none? + + + +Sexton +Master constable, you go not the way to examine: +you must call forth the watch that are their accusers. + + + +DOGBERRY +Yea, marry, that's the eftest way. Let the watch +come forth. Masters, I charge you, in the prince's +name, accuse these men. + + + +First Watchman +This man said, sir, that Don John, the prince's +brother, was a villain. + + + +DOGBERRY +Write down Prince John a villain. Why, this is flat +perjury, to call a prince's brother villain. + + + +BORACHIO +Master constable,-- + + + +DOGBERRY +Pray thee, fellow, peace: I do not like thy look, +I promise thee. + + + +Sexton +What heard you him say else? + + + +Second Watchman +Marry, that he had received a thousand ducats of +Don John for accusing the Lady Hero wrongfully. + + + +DOGBERRY +Flat burglary as ever was committed. + + + +VERGES +Yea, by mass, that it is. + + + +Sexton +What else, fellow? + + + +First Watchman +And that Count Claudio did mean, upon his words, to +disgrace Hero before the whole assembly. and not marry her. + + + +DOGBERRY +O villain! thou wilt be condemned into everlasting +redemption for this. + + + +Sexton +What else? + + + +Watchman +This is all. + + + +Sexton +And this is more, masters, than you can deny. +Prince John is this morning secretly stolen away; +Hero was in this manner accused, in this very manner +refused, and upon the grief of this suddenly died. +Master constable, let these men be bound, and +brought to Leonato's: I will go before and show +him their examination. + + + +Exit + + +DOGBERRY +Come, let them be opinioned. + + + +VERGES +Let them be in the hands-- + + + +CONRADE +Off, coxcomb! + + + +DOGBERRY +God's my life, where's the sexton? let him write +down the prince's officer coxcomb. Come, bind them. +Thou naughty varlet! + + + +CONRADE +Away! you are an ass, you are an ass. + + + +DOGBERRY +Dost thou not suspect my place? dost thou not +suspect my years? O that he were here to write me +down an ass! But, masters, remember that I am an +ass; though it be not written down, yet forget not +that I am an ass. No, thou villain, thou art full of +piety, as shall be proved upon thee by good witness. +I am a wise fellow, and, which is more, an officer, +and, which is more, a householder, and, which is +more, as pretty a piece of flesh as any is in +Messina, and one that knows the law, go to; and a +rich fellow enough, go to; and a fellow that hath +had losses, and one that hath two gowns and every +thing handsome about him. Bring him away. O that +I had been writ down an ass! + + + +Exeunt + + + + +ACT V + +SCENE I. Before LEONATO'S house. +Enter LEONATO and ANTONIO + + +ANTONIO +If you go on thus, you will kill yourself: +And 'tis not wisdom thus to second grief +Against yourself. + + + +LEONATO +I pray thee, cease thy counsel, +Which falls into mine ears as profitless +As water in a sieve: give not me counsel; +Nor let no comforter delight mine ear +But such a one whose wrongs do suit with mine. +Bring me a father that so loved his child, +Whose joy of her is overwhelm'd like mine, +And bid him speak of patience; +Measure his woe the length and breadth of mine +And let it answer every strain for strain, +As thus for thus and such a grief for such, +In every lineament, branch, shape, and form: +If such a one will smile and stroke his beard, +Bid sorrow wag, cry 'hem!' when he should groan, +Patch grief with proverbs, make misfortune drunk +With candle-wasters; bring him yet to me, +And I of him will gather patience. +But there is no such man: for, brother, men +Can counsel and speak comfort to that grief +Which they themselves not feel; but, tasting it, +Their counsel turns to passion, which before +Would give preceptial medicine to rage, +Fetter strong madness in a silken thread, +Charm ache with air and agony with words: +No, no; 'tis all men's office to speak patience +To those that wring under the load of sorrow, +But no man's virtue nor sufficiency +To be so moral when he shall endure +The like himself. Therefore give me no counsel: +My griefs cry louder than advertisement. + + + +ANTONIO +Therein do men from children nothing differ. + + + +LEONATO +I pray thee, peace. I will be flesh and blood; +For there was never yet philosopher +That could endure the toothache patiently, +However they have writ the style of gods +And made a push at chance and sufferance. + + + +ANTONIO +Yet bend not all the harm upon yourself; +Make those that do offend you suffer too. + + + +LEONATO +There thou speak'st reason: nay, I will do so. +My soul doth tell me Hero is belied; +And that shall Claudio know; so shall the prince +And all of them that thus dishonour her. + + + +ANTONIO +Here comes the prince and Claudio hastily. + + + +Enter DON PEDRO and CLAUDIO + + +DON PEDRO +Good den, good den. + + + +CLAUDIO +Good day to both of you. + + + +LEONATO +Hear you. my lords,-- + + + +DON PEDRO +We have some haste, Leonato. + + + +LEONATO +Some haste, my lord! well, fare you well, my lord: +Are you so hasty now? well, all is one. + + + +DON PEDRO +Nay, do not quarrel with us, good old man. + + + +ANTONIO +If he could right himself with quarreling, +Some of us would lie low. + + + +CLAUDIO +Who wrongs him? + + + +LEONATO +Marry, thou dost wrong me; thou dissembler, thou:-- +Nay, never lay thy hand upon thy sword; +I fear thee not. + + + +CLAUDIO +Marry, beshrew my hand, +If it should give your age such cause of fear: +In faith, my hand meant nothing to my sword. + + + +LEONATO +Tush, tush, man; never fleer and jest at me: +I speak not like a dotard nor a fool, +As under privilege of age to brag +What I have done being young, or what would do +Were I not old. Know, Claudio, to thy head, +Thou hast so wrong'd mine innocent child and me +That I am forced to lay my reverence by +And, with grey hairs and bruise of many days, +Do challenge thee to trial of a man. +I say thou hast belied mine innocent child; +Thy slander hath gone through and through her heart, +And she lies buried with her ancestors; +O, in a tomb where never scandal slept, +Save this of hers, framed by thy villany! + + + +CLAUDIO +My villany? + + + +LEONATO +Thine, Claudio; thine, I say. + + + +DON PEDRO +You say not right, old man. + + + +LEONATO +My lord, my lord, +I'll prove it on his body, if he dare, +Despite his nice fence and his active practise, +His May of youth and bloom of lustihood. + + + +CLAUDIO +Away! I will not have to do with you. + + + +LEONATO +Canst thou so daff me? Thou hast kill'd my child: +If thou kill'st me, boy, thou shalt kill a man. + + + +ANTONIO +He shall kill two of us, and men indeed: +But that's no matter; let him kill one first; +Win me and wear me; let him answer me. +Come, follow me, boy; come, sir boy, come, follow me: +Sir boy, I'll whip you from your foining fence; +Nay, as I am a gentleman, I will. + + + +LEONATO +Brother,-- + + + +ANTONIO +Content yourself. God knows I loved my niece; +And she is dead, slander'd to death by villains, +That dare as well answer a man indeed +As I dare take a serpent by the tongue: +Boys, apes, braggarts, Jacks, milksops! + + + +LEONATO +Brother Antony,-- + + + +ANTONIO +Hold you content. What, man! I know them, yea, +And what they weigh, even to the utmost scruple,-- +Scrambling, out-facing, fashion-monging boys, +That lie and cog and flout, deprave and slander, +Go anticly, show outward hideousness, +And speak off half a dozen dangerous words, +How they might hurt their enemies, if they durst; +And this is all. + + + +LEONATO +But, brother Antony,-- + + + +ANTONIO +Come, 'tis no matter: +Do not you meddle; let me deal in this. + + + +DON PEDRO +Gentlemen both, we will not wake your patience. +My heart is sorry for your daughter's death: +But, on my honour, she was charged with nothing +But what was true and very full of proof. + + + +LEONATO +My lord, my lord,-- + + + +DON PEDRO +I will not hear you. + + + +LEONATO +No? Come, brother; away! I will be heard. + + + +ANTONIO +And shall, or some of us will smart for it. + + + +Exeunt LEONATO and ANTONIO + + +DON PEDRO +See, see; here comes the man we went to seek. + + + +Enter BENEDICK + + +CLAUDIO +Now, signior, what news? + + + +BENEDICK +Good day, my lord. + + + +DON PEDRO +Welcome, signior: you are almost come to part +almost a fray. + + + +CLAUDIO +We had like to have had our two noses snapped off +with two old men without teeth. + + + +DON PEDRO +Leonato and his brother. What thinkest thou? Had +we fought, I doubt we should have been too young for them. + + + +BENEDICK +In a false quarrel there is no true valour. I came +to seek you both. + + + +CLAUDIO +We have been up and down to seek thee; for we are +high-proof melancholy and would fain have it beaten +away. Wilt thou use thy wit? + + + +BENEDICK +It is in my scabbard: shall I draw it? + + + +DON PEDRO +Dost thou wear thy wit by thy side? + + + +CLAUDIO +Never any did so, though very many have been beside +their wit. I will bid thee draw, as we do the +minstrels; draw, to pleasure us. + + + +DON PEDRO +As I am an honest man, he looks pale. Art thou +sick, or angry? + + + +CLAUDIO +What, courage, man! What though care killed a cat, +thou hast mettle enough in thee to kill care. + + + +BENEDICK +Sir, I shall meet your wit in the career, and you +charge it against me. I pray you choose another subject. + + + +CLAUDIO +Nay, then, give him another staff: this last was +broke cross. + + + +DON PEDRO +By this light, he changes more and more: I think +he be angry indeed. + + + +CLAUDIO +If he be, he knows how to turn his girdle. + + + +BENEDICK +Shall I speak a word in your ear? + + + +CLAUDIO +God bless me from a challenge! + + + +BENEDICK +Aside to CLAUDIO You are a villain; I jest not: +I will make it good how you dare, with what you +dare, and when you dare. Do me right, or I will +protest your cowardice. You have killed a sweet +lady, and her death shall fall heavy on you. Let me +hear from you. + + + +CLAUDIO +Well, I will meet you, so I may have good cheer. + + + +DON PEDRO +What, a feast, a feast? + + + +CLAUDIO +I' faith, I thank him; he hath bid me to a calf's +head and a capon; the which if I do not carve most +curiously, say my knife's naught. Shall I not find +a woodcock too? + + + +BENEDICK +Sir, your wit ambles well; it goes easily. + + + +DON PEDRO +I'll tell thee how Beatrice praised thy wit the +other day. I said, thou hadst a fine wit: 'True,' +said she, 'a fine little one.' 'No,' said I, 'a +great wit:' 'Right,' says she, 'a great gross one.' +'Nay,' said I, 'a good wit:' 'Just,' said she, 'it +hurts nobody.' 'Nay,' said I, 'the gentleman +is wise:' 'Certain,' said she, 'a wise gentleman.' +'Nay,' said I, 'he hath the tongues:' 'That I +believe,' said she, 'for he swore a thing to me on +Monday night, which he forswore on Tuesday morning; +there's a double tongue; there's two tongues.' Thus +did she, an hour together, transshape thy particular +virtues: yet at last she concluded with a sigh, thou +wast the properest man in Italy. + + + +CLAUDIO +For the which she wept heartily and said she cared +not. + + + +DON PEDRO +Yea, that she did: but yet, for all that, an if she +did not hate him deadly, she would love him dearly: +the old man's daughter told us all. + + + +CLAUDIO +All, all; and, moreover, God saw him when he was +hid in the garden. + + + +DON PEDRO +But when shall we set the savage bull's horns on +the sensible Benedick's head? + + + +CLAUDIO +Yea, and text underneath, 'Here dwells Benedick the +married man'? + + + +BENEDICK +Fare you well, boy: you know my mind. I will leave +you now to your gossip-like humour: you break jests +as braggarts do their blades, which God be thanked, +hurt not. My lord, for your many courtesies I thank +you: I must discontinue your company: your brother +the bastard is fled from Messina: you have among +you killed a sweet and innocent lady. For my Lord +Lackbeard there, he and I shall meet: and, till +then, peace be with him. + + + +Exit + + +DON PEDRO +He is in earnest. + + + +CLAUDIO +In most profound earnest; and, I'll warrant you, for +the love of Beatrice. + + + +DON PEDRO +And hath challenged thee. + + + +CLAUDIO +Most sincerely. + + + +DON PEDRO +What a pretty thing man is when he goes in his +doublet and hose and leaves off his wit! + + + +CLAUDIO +He is then a giant to an ape; but then is an ape a +doctor to such a man. + + + +DON PEDRO +But, soft you, let me be: pluck up, my heart, and +be sad. Did he not say, my brother was fled? + + + +Enter DOGBERRY, VERGES, and the Watch, with CONRADE +and BORACHIO + + +DOGBERRY +Come you, sir: if justice cannot tame you, she +shall ne'er weigh more reasons in her balance: nay, +an you be a cursing hypocrite once, you must be looked to. + + + +DON PEDRO +How now? two of my brother's men bound! Borachio +one! + + + +CLAUDIO +Hearken after their offence, my lord. + + + +DON PEDRO +Officers, what offence have these men done? + + + +DOGBERRY +Marry, sir, they have committed false report; +moreover, they have spoken untruths; secondarily, +they are slanders; sixth and lastly, they have +belied a lady; thirdly, they have verified unjust +things; and, to conclude, they are lying knaves. + + + +DON PEDRO +First, I ask thee what they have done; thirdly, I +ask thee what's their offence; sixth and lastly, why +they are committed; and, to conclude, what you lay +to their charge. + + + +CLAUDIO +Rightly reasoned, and in his own division: and, by +my troth, there's one meaning well suited. + + + +DON PEDRO +Who have you offended, masters, that you are thus +bound to your answer? this learned constable is +too cunning to be understood: what's your offence? + + + +BORACHIO +Sweet prince, let me go no farther to mine answer: +do you hear me, and let this count kill me. I have +deceived even your very eyes: what your wisdoms +could not discover, these shallow fools have brought +to light: who in the night overheard me confessing +to this man how Don John your brother incensed me +to slander the Lady Hero, how you were brought into +the orchard and saw me court Margaret in Hero's +garments, how you disgraced her, when you should +marry her: my villany they have upon record; which +I had rather seal with my death than repeat over +to my shame. The lady is dead upon mine and my +master's false accusation; and, briefly, I desire +nothing but the reward of a villain. + + + +DON PEDRO +Runs not this speech like iron through your blood? + + + +CLAUDIO +I have drunk poison whiles he utter'd it. + + + +DON PEDRO +But did my brother set thee on to this? + + + +BORACHIO +Yea, and paid me richly for the practise of it. + + + +DON PEDRO +He is composed and framed of treachery: +And fled he is upon this villany. + + + +CLAUDIO +Sweet Hero! now thy image doth appear +In the rare semblance that I loved it first. + + + +DOGBERRY +Come, bring away the plaintiffs: by this time our +sexton hath reformed Signior Leonato of the matter: +and, masters, do not forget to specify, when time +and place shall serve, that I am an ass. + + + +VERGES +Here, here comes master Signior Leonato, and the +Sexton too. + + + +Re-enter LEONATO and ANTONIO, with the Sexton + + +LEONATO +Which is the villain? let me see his eyes, +That, when I note another man like him, +I may avoid him: which of these is he? + + + +BORACHIO +If you would know your wronger, look on me. + + + +LEONATO +Art thou the slave that with thy breath hast kill'd +Mine innocent child? + + + +BORACHIO +Yea, even I alone. + + + +LEONATO +No, not so, villain; thou beliest thyself: +Here stand a pair of honourable men; +A third is fled, that had a hand in it. +I thank you, princes, for my daughter's death: +Record it with your high and worthy deeds: +'Twas bravely done, if you bethink you of it. + + + +CLAUDIO +I know not how to pray your patience; +Yet I must speak. Choose your revenge yourself; +Impose me to what penance your invention +Can lay upon my sin: yet sinn'd I not +But in mistaking. + + + +DON PEDRO +By my soul, nor I: +And yet, to satisfy this good old man, +I would bend under any heavy weight +That he'll enjoin me to. + + + +LEONATO +I cannot bid you bid my daughter live; +That were impossible: but, I pray you both, +Possess the people in Messina here +How innocent she died; and if your love +Can labour ought in sad invention, +Hang her an epitaph upon her tomb +And sing it to her bones, sing it to-night: +To-morrow morning come you to my house, +And since you could not be my son-in-law, +Be yet my nephew: my brother hath a daughter, +Almost the copy of my child that's dead, +And she alone is heir to both of us: +Give her the right you should have given her cousin, +And so dies my revenge. + + + +CLAUDIO +O noble sir, +Your over-kindness doth wring tears from me! +I do embrace your offer; and dispose +For henceforth of poor Claudio. + + + +LEONATO +To-morrow then I will expect your coming; +To-night I take my leave. This naughty man +Shall face to face be brought to Margaret, +Who I believe was pack'd in all this wrong, +Hired to it by your brother. + + + +BORACHIO +No, by my soul, she was not, +Nor knew not what she did when she spoke to me, +But always hath been just and virtuous +In any thing that I do know by her. + + + +DOGBERRY +Moreover, sir, which indeed is not under white and +black, this plaintiff here, the offender, did call +me ass: I beseech you, let it be remembered in his +punishment. And also, the watch heard them talk of +one Deformed: they say be wears a key in his ear and +a lock hanging by it, and borrows money in God's +name, the which he hath used so long and never paid +that now men grow hard-hearted and will lend nothing +for God's sake: pray you, examine him upon that point. + + + +LEONATO +I thank thee for thy care and honest pains. + + + +DOGBERRY +Your worship speaks like a most thankful and +reverend youth; and I praise God for you. + + + +LEONATO +There's for thy pains. + + + +DOGBERRY +God save the foundation! + + + +LEONATO +Go, I discharge thee of thy prisoner, and I thank thee. + + + +DOGBERRY +I leave an arrant knave with your worship; which I +beseech your worship to correct yourself, for the +example of others. God keep your worship! I wish +your worship well; God restore you to health! I +humbly give you leave to depart; and if a merry +meeting may be wished, God prohibit it! Come, neighbour. + + + +Exeunt DOGBERRY and VERGES + + +LEONATO +Until to-morrow morning, lords, farewell. + + + +ANTONIO +Farewell, my lords: we look for you to-morrow. + + + +DON PEDRO +We will not fail. + + + +CLAUDIO +To-night I'll mourn with Hero. + + + +LEONATO +To the Watch Bring you these fellows on. We'll +talk with Margaret, +How her acquaintance grew with this lewd fellow. + + + +Exeunt, severally + + +SCENE II. LEONATO'S garden. +Enter BENEDICK and MARGARET, meeting + + +BENEDICK +Pray thee, sweet Mistress Margaret, deserve well at +my hands by helping me to the speech of Beatrice. + + + +MARGARET +Will you then write me a sonnet in praise of my beauty? + + + +BENEDICK +In so high a style, Margaret, that no man living +shall come over it; for, in most comely truth, thou +deservest it. + + + +MARGARET +To have no man come over me! why, shall I always +keep below stairs? + + + +BENEDICK +Thy wit is as quick as the greyhound's mouth; it catches. + + + +MARGARET +And yours as blunt as the fencer's foils, which hit, +but hurt not. + + + +BENEDICK +A most manly wit, Margaret; it will not hurt a +woman: and so, I pray thee, call Beatrice: I give +thee the bucklers. + + + +MARGARET +Give us the swords; we have bucklers of our own. + + + +BENEDICK +If you use them, Margaret, you must put in the +pikes with a vice; and they are dangerous weapons for maids. + + + +MARGARET +Well, I will call Beatrice to you, who I think hath legs. + + + +BENEDICK +And therefore will come. +Exit MARGARET +Sings +The god of love, +That sits above, +And knows me, and knows me, +How pitiful I deserve,-- +I mean in singing; but in loving, Leander the good +swimmer, Troilus the first employer of panders, and +a whole bookful of these quondam carpet-mangers, +whose names yet run smoothly in the even road of a +blank verse, why, they were never so truly turned +over and over as my poor self in love. Marry, I +cannot show it in rhyme; I have tried: I can find +out no rhyme to 'lady' but 'baby,' an innocent +rhyme; for 'scorn,' 'horn,' a hard rhyme; for, +'school,' 'fool,' a babbling rhyme; very ominous +endings: no, I was not born under a rhyming planet, +nor I cannot woo in festival terms. +Enter BEATRICE +Sweet Beatrice, wouldst thou come when I called thee? + + + +BEATRICE +Yea, signior, and depart when you bid me. + + + +BENEDICK +O, stay but till then! + + + +BEATRICE +'Then' is spoken; fare you well now: and yet, ere +I go, let me go with that I came; which is, with +knowing what hath passed between you and Claudio. + + + +BENEDICK +Only foul words; and thereupon I will kiss thee. + + + +BEATRICE +Foul words is but foul wind, and foul wind is but +foul breath, and foul breath is noisome; therefore I +will depart unkissed. + + + +BENEDICK +Thou hast frighted the word out of his right sense, +so forcible is thy wit. But I must tell thee +plainly, Claudio undergoes my challenge; and either +I must shortly hear from him, or I will subscribe +him a coward. And, I pray thee now, tell me for +which of my bad parts didst thou first fall in love with me? + + + +BEATRICE +For them all together; which maintained so politic +a state of evil that they will not admit any good +part to intermingle with them. But for which of my +good parts did you first suffer love for me? + + + +BENEDICK +Suffer love! a good epithet! I do suffer love +indeed, for I love thee against my will. + + + +BEATRICE +In spite of your heart, I think; alas, poor heart! +If you spite it for my sake, I will spite it for +yours; for I will never love that which my friend hates. + + + +BENEDICK +Thou and I are too wise to woo peaceably. + + + +BEATRICE +It appears not in this confession: there's not one +wise man among twenty that will praise himself. + + + +BENEDICK +An old, an old instance, Beatrice, that lived in +the lime of good neighbours. If a man do not erect +in this age his own tomb ere he dies, he shall live +no longer in monument than the bell rings and the +widow weeps. + + + +BEATRICE +And how long is that, think you? + + + +BENEDICK +Question: why, an hour in clamour and a quarter in +rheum: therefore is it most expedient for the +wise, if Don Worm, his conscience, find no +impediment to the contrary, to be the trumpet of his +own virtues, as I am to myself. So much for +praising myself, who, I myself will bear witness, is +praiseworthy: and now tell me, how doth your cousin? + + + +BEATRICE +Very ill. + + + +BENEDICK +And how do you? + + + +BEATRICE +Very ill too. + + + +BENEDICK +Serve God, love me and mend. There will I leave +you too, for here comes one in haste. + + + +Enter URSULA + + +URSULA +Madam, you must come to your uncle. Yonder's old +coil at home: it is proved my Lady Hero hath been +falsely accused, the prince and Claudio mightily +abused; and Don John is the author of all, who is +fed and gone. Will you come presently? + + + +BEATRICE +Will you go hear this news, signior? + + + +BENEDICK +I will live in thy heart, die in thy lap, and be +buried in thy eyes; and moreover I will go with +thee to thy uncle's. + + + +Exeunt + + +SCENE III. A church. +Enter DON PEDRO, CLAUDIO, and three or four +with tapers + + +CLAUDIO +Is this the monument of Leonato? + + + +Lord +It is, my lord. + + + +CLAUDIO +Reading out of a scroll +Done to death by slanderous tongues +Was the Hero that here lies: +Death, in guerdon of her wrongs, +Gives her fame which never dies. +So the life that died with shame +Lives in death with glorious fame. +Hang thou there upon the tomb, +Praising her when I am dumb. +Now, music, sound, and sing your solemn hymn. +SONG. +Pardon, goddess of the night, +Those that slew thy virgin knight; +For the which, with songs of woe, +Round about her tomb they go. +Midnight, assist our moan; +Help us to sigh and groan, +Heavily, heavily: +Graves, yawn and yield your dead, +Till death be uttered, +Heavily, heavily. + + + +CLAUDIO +Now, unto thy bones good night! +Yearly will I do this rite. + + + +DON PEDRO +Good morrow, masters; put your torches out: +The wolves have prey'd; and look, the gentle day, +Before the wheels of Phoebus, round about +Dapples the drowsy east with spots of grey. +Thanks to you all, and leave us: fare you well. + + + +CLAUDIO +Good morrow, masters: each his several way. + + + +DON PEDRO +Come, let us hence, and put on other weeds; +And then to Leonato's we will go. + + + +CLAUDIO +And Hymen now with luckier issue speed's +Than this for whom we render'd up this woe. + + + +Exeunt + + +SCENE IV. A room in LEONATO'S house. +Enter LEONATO, ANTONIO, BENEDICK, BEATRICE, +MARGARET, URSULA, FRIAR FRANCIS, and HERO + + +FRIAR FRANCIS +Did I not tell you she was innocent? + + + +LEONATO +So are the prince and Claudio, who accused her +Upon the error that you heard debated: +But Margaret was in some fault for this, +Although against her will, as it appears +In the true course of all the question. + + + +ANTONIO +Well, I am glad that all things sort so well. + + + +BENEDICK +And so am I, being else by faith enforced +To call young Claudio to a reckoning for it. + + + +LEONATO +Well, daughter, and you gentle-women all, +Withdraw into a chamber by yourselves, +And when I send for you, come hither mask'd. +Exeunt Ladies +The prince and Claudio promised by this hour +To visit me. You know your office, brother: +You must be father to your brother's daughter +And give her to young Claudio. + + + +ANTONIO +Which I will do with confirm'd countenance. + + + +BENEDICK +Friar, I must entreat your pains, I think. + + + +FRIAR FRANCIS +To do what, signior? + + + +BENEDICK +To bind me, or undo me; one of them. +Signior Leonato, truth it is, good signior, +Your niece regards me with an eye of favour. + + + +LEONATO +That eye my daughter lent her: 'tis most true. + + + +BENEDICK +And I do with an eye of love requite her. + + + +LEONATO +The sight whereof I think you had from me, +From Claudio and the prince: but what's your will? + + + +BENEDICK +Your answer, sir, is enigmatical: +But, for my will, my will is your good will +May stand with ours, this day to be conjoin'd +In the state of honourable marriage: +In which, good friar, I shall desire your help. + + + +LEONATO +My heart is with your liking. + + + +FRIAR FRANCIS +And my help. +Here comes the prince and Claudio. + + + +Enter DON PEDRO and CLAUDIO, and two or +three others + + +DON PEDRO +Good morrow to this fair assembly. + + + +LEONATO +Good morrow, prince; good morrow, Claudio: +We here attend you. Are you yet determined +To-day to marry with my brother's daughter? + + + +CLAUDIO +I'll hold my mind, were she an Ethiope. + + + +LEONATO +Call her forth, brother; here's the friar ready. + + + +Exit ANTONIO + + +DON PEDRO +Good morrow, Benedick. Why, what's the matter, +That you have such a February face, +So full of frost, of storm and cloudiness? + + + +CLAUDIO +I think he thinks upon the savage bull. +Tush, fear not, man; we'll tip thy horns with gold +And all Europa shall rejoice at thee, +As once Europa did at lusty Jove, +When he would play the noble beast in love. + + + +BENEDICK +Bull Jove, sir, had an amiable low; +And some such strange bull leap'd your father's cow, +And got a calf in that same noble feat +Much like to you, for you have just his bleat. + + + +CLAUDIO +For this I owe you: here comes other reckonings. +Re-enter ANTONIO, with the Ladies masked +Which is the lady I must seize upon? + + + +ANTONIO +This same is she, and I do give you her. + + + +CLAUDIO +Why, then she's mine. Sweet, let me see your face. + + + +LEONATO +No, that you shall not, till you take her hand +Before this friar and swear to marry her. + + + +CLAUDIO +Give me your hand: before this holy friar, +I am your husband, if you like of me. + + + +HERO +And when I lived, I was your other wife: +Unmasking +And when you loved, you were my other husband. + + + +CLAUDIO +Another Hero! + + + +HERO +Nothing certainer: +One Hero died defiled, but I do live, +And surely as I live, I am a maid. + + + +DON PEDRO +The former Hero! Hero that is dead! + + + +LEONATO +She died, my lord, but whiles her slander lived. + + + +FRIAR FRANCIS +All this amazement can I qualify: +When after that the holy rites are ended, +I'll tell you largely of fair Hero's death: +Meantime let wonder seem familiar, +And to the chapel let us presently. + + + +BENEDICK +Soft and fair, friar. Which is Beatrice? + + + +BEATRICE +Unmasking I answer to that name. What is your will? + + + +BENEDICK +Do not you love me? + + + +BEATRICE +Why, no; no more than reason. + + + +BENEDICK +Why, then your uncle and the prince and Claudio +Have been deceived; they swore you did. + + + +BEATRICE +Do not you love me? + + + +BENEDICK +Troth, no; no more than reason. + + + +BEATRICE +Why, then my cousin Margaret and Ursula +Are much deceived; for they did swear you did. + + + +BENEDICK +They swore that you were almost sick for me. + + + +BEATRICE +They swore that you were well-nigh dead for me. + + + +BENEDICK +'Tis no such matter. Then you do not love me? + + + +BEATRICE +No, truly, but in friendly recompense. + + + +LEONATO +Come, cousin, I am sure you love the gentleman. + + + +CLAUDIO +And I'll be sworn upon't that he loves her; +For here's a paper written in his hand, +A halting sonnet of his own pure brain, +Fashion'd to Beatrice. + + + +HERO +And here's another +Writ in my cousin's hand, stolen from her pocket, +Containing her affection unto Benedick. + + + +BENEDICK +A miracle! here's our own hands against our hearts. +Come, I will have thee; but, by this light, I take +thee for pity. + + + +BEATRICE +I would not deny you; but, by this good day, I yield +upon great persuasion; and partly to save your life, +for I was told you were in a consumption. + + + +BENEDICK +Peace! I will stop your mouth. + + + +Kissing her + + +DON PEDRO +How dost thou, Benedick, the married man? + + + +BENEDICK +I'll tell thee what, prince; a college of +wit-crackers cannot flout me out of my humour. Dost +thou think I care for a satire or an epigram? No: +if a man will be beaten with brains, a' shall wear +nothing handsome about him. In brief, since I do +purpose to marry, I will think nothing to any +purpose that the world can say against it; and +therefore never flout at me for what I have said +against it; for man is a giddy thing, and this is my +conclusion. For thy part, Claudio, I did think to +have beaten thee, but in that thou art like to be my +kinsman, live unbruised and love my cousin. + + + +CLAUDIO +I had well hoped thou wouldst have denied Beatrice, +that I might have cudgelled thee out of thy single +life, to make thee a double-dealer; which, out of +question, thou wilt be, if my cousin do not look +exceedingly narrowly to thee. + + + +BENEDICK +Come, come, we are friends: let's have a dance ere +we are married, that we may lighten our own hearts +and our wives' heels. + + + +LEONATO +We'll have dancing afterward. + + + +BENEDICK +First, of my word; therefore play, music. Prince, +thou art sad; get thee a wife, get thee a wife: +there is no staff more reverend than one tipped with horn. + + + +Enter a Messenger + + +Messenger +My lord, your brother John is ta'en in flight, +And brought with armed men back to Messina. + + + +BENEDICK +Think not on him till to-morrow: +I'll devise thee brave punishments for him. +Strike up, pipers. + + +Dance +Exeunt + + +
diff --git a/axiom/test/resources/xml/om/namespaces.xml b/axiom/test/resources/xml/om/namespaces.xml new file mode 100644 index 0000000..e8e4df8 --- /dev/null +++ b/axiom/test/resources/xml/om/namespaces.xml @@ -0,0 +1,18 @@ + + + + Hello + + + + Hey + + + + Hey2 + + + + Hey3 + + diff --git a/axiom/test/resources/xml/om/nitf.xml b/axiom/test/resources/xml/om/nitf.xml new file mode 100644 index 0000000..269d99e --- /dev/null +++ b/axiom/test/resources/xml/om/nitf.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + Use of Napster Quadruples + + By PETER SVENSSON + AP Business Writer + + The Associated Press + + NEW YORK + + + + +

Despite the uncertain legality of the Napster online music-sharing service, the number of people +using it more than quadrupled in just five months, Media Metrix said Monday.

+

That made Napster the fastest-growing software application ever recorded by the Internet research +company.

+

From 1.1 million home users in the United States in February, the first month Media Metrix +tracked the application, Napster use rocketed to 4.9 million users in July.

+

That represents 6 percent of U.S. home PC users who have modems, said Media Metrix, which pays +people to install monitoring software on their computers.

+

It estimates total usage from a panel of about 50,000 people in the United States.

+

Napster was also used at work by 887,000 people in July, Media Metrix said.

+

Napster Inc. has been sued by the recording industry for allegedly enabling copyright +infringement. The federal government weighed in on the case Friday, saying the service is not protected +under a key copyright law, as the San Mateo, Calif., company claims.

+

Bruce Ryon, head of Media Metrix's New Media Group, said Napster was used by "the full spectrum of PC users, not just the youth with time on their hands and a passion for music."

+

The Napster program allows users to copy digital music files from the hard drives of other +users over the Internet.

+

Napster Inc. said last week that 28 million people had downloaded its program. It does not reveal +its own figures for how many people actually use the software.

+

Because the program connects to the company's computers over the Internet every time +it is run, Napster Inc. can track usage exactly.

+

__

+

On the Net:

+

+http://www.napster.com

+

+http://www.mediametrix.com

+
+
+ +
diff --git a/axiom/test/resources/xml/om/numbers.xml b/axiom/test/resources/xml/om/numbers.xml new file mode 100644 index 0000000..a1791cd --- /dev/null +++ b/axiom/test/resources/xml/om/numbers.xml @@ -0,0 +1,18 @@ + + + + + 3 + 24 + 55 + 11 + 2 + -3 + + + + + + + + diff --git a/axiom/test/resources/xml/om/pi.xml b/axiom/test/resources/xml/om/pi.xml new file mode 100644 index 0000000..980bbf9 --- /dev/null +++ b/axiom/test/resources/xml/om/pi.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/axiom/test/resources/xml/om/pi2.xml b/axiom/test/resources/xml/om/pi2.xml new file mode 100644 index 0000000..46bce45 --- /dev/null +++ b/axiom/test/resources/xml/om/pi2.xml @@ -0,0 +1,6 @@ + + + foo + + bar + diff --git a/axiom/test/resources/xml/om/simple.xml b/axiom/test/resources/xml/om/simple.xml new file mode 100644 index 0000000..3cff71a --- /dev/null +++ b/axiom/test/resources/xml/om/simple.xml @@ -0,0 +1,2 @@ + +abd diff --git a/axiom/test/resources/xml/om/spaces.xml b/axiom/test/resources/xml/om/spaces.xml new file mode 100644 index 0000000..4c46c63 --- /dev/null +++ b/axiom/test/resources/xml/om/spaces.xml @@ -0,0 +1,10 @@ + + + baz + + baz + + baz + + ]]> + \ No newline at end of file diff --git a/axiom/test/resources/xml/om/test.xml b/axiom/test/resources/xml/om/test.xml new file mode 100644 index 0000000..a222795 --- /dev/null +++ b/axiom/test/resources/xml/om/test.xml @@ -0,0 +1,12 @@ + + + Axis2C OM HOWTO1748491379 + 1748491379 + + + +

+ This is vey good book on OM! +

+
+
diff --git a/axiom/test/resources/xml/om/testNamespaces.xml b/axiom/test/resources/xml/om/testNamespaces.xml new file mode 100644 index 0000000..50f7c93 --- /dev/null +++ b/axiom/test/resources/xml/om/testNamespaces.xml @@ -0,0 +1,22 @@ + diff --git a/axiom/test/resources/xml/om/underscore.xml b/axiom/test/resources/xml/om/underscore.xml new file mode 100644 index 0000000..111446f --- /dev/null +++ b/axiom/test/resources/xml/om/underscore.xml @@ -0,0 +1,6 @@ + + + 1 + <_b>2 + + diff --git a/axiom/test/resources/xml/om/web.xml b/axiom/test/resources/xml/om/web.xml new file mode 100644 index 0000000..972cf5d --- /dev/null +++ b/axiom/test/resources/xml/om/web.xml @@ -0,0 +1,42 @@ + + + + snoop + SnoopServlet + + + file + ViewFile + + initial + + 1000 + + + The initial value for the counter + + + + + + mv + + + *.wm + + + + + + + + manager + + + director + + + president + + + diff --git a/axiom/test/resources/xml/om/web2.xml b/axiom/test/resources/xml/om/web2.xml new file mode 100644 index 0000000..7d479d3 --- /dev/null +++ b/axiom/test/resources/xml/om/web2.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/axiom/test/resources/xml/soap/OMElementTest.xml b/axiom/test/resources/xml/soap/OMElementTest.xml new file mode 100644 index 0000000..9cd474c --- /dev/null +++ b/axiom/test/resources/xml/soap/OMElementTest.xml @@ -0,0 +1,22 @@ + + + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+
+ + This is some text + 2 + Some Other Text + + +
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/badsoap/bodyNotQualified.xml b/axiom/test/resources/xml/soap/badsoap/bodyNotQualified.xml new file mode 100644 index 0000000..eef7895 --- /dev/null +++ b/axiom/test/resources/xml/soap/badsoap/bodyNotQualified.xml @@ -0,0 +1,19 @@ + + + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+
+ + + +
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/badsoap/envelopeMissing.xml b/axiom/test/resources/xml/soap/badsoap/envelopeMissing.xml new file mode 100644 index 0000000..4106495 --- /dev/null +++ b/axiom/test/resources/xml/soap/badsoap/envelopeMissing.xml @@ -0,0 +1,20 @@ + + + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+
+ + + + +
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/badsoap/haederBodyWrongOrder.xml b/axiom/test/resources/xml/soap/badsoap/haederBodyWrongOrder.xml new file mode 100644 index 0000000..e71c49a --- /dev/null +++ b/axiom/test/resources/xml/soap/badsoap/haederBodyWrongOrder.xml @@ -0,0 +1,20 @@ + + + + + + + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+
+
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/badsoap/notnamespaceQualified.xml b/axiom/test/resources/xml/soap/badsoap/notnamespaceQualified.xml new file mode 100644 index 0000000..dfc013c --- /dev/null +++ b/axiom/test/resources/xml/soap/badsoap/notnamespaceQualified.xml @@ -0,0 +1,15 @@ + +
+ uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+
+ + + +
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/badsoap/twoBodymessage.xml b/axiom/test/resources/xml/soap/badsoap/twoBodymessage.xml new file mode 100644 index 0000000..a96a401 --- /dev/null +++ b/axiom/test/resources/xml/soap/badsoap/twoBodymessage.xml @@ -0,0 +1,24 @@ + + + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+
+ + + + + + + + +
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/badsoap/twoheaders.xml b/axiom/test/resources/xml/soap/badsoap/twoheaders.xml new file mode 100644 index 0000000..3064771 --- /dev/null +++ b/axiom/test/resources/xml/soap/badsoap/twoheaders.xml @@ -0,0 +1,29 @@ + + + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+
+ + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+
+ + +
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/badsoap/wrongSoapNs.xml b/axiom/test/resources/xml/soap/badsoap/wrongSoapNs.xml new file mode 100644 index 0000000..7d84398 --- /dev/null +++ b/axiom/test/resources/xml/soap/badsoap/wrongSoapNs.xml @@ -0,0 +1,20 @@ + + + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+
+ + + + +
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/emtyBodymessage.xml b/axiom/test/resources/xml/soap/emtyBodymessage.xml new file mode 100644 index 0000000..ea20929 --- /dev/null +++ b/axiom/test/resources/xml/soap/emtyBodymessage.xml @@ -0,0 +1,18 @@ + + + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+
+ + +
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/invalidMustUnderstandSOAP12.xml b/axiom/test/resources/xml/soap/invalidMustUnderstandSOAP12.xml new file mode 100644 index 0000000..1b5183f --- /dev/null +++ b/axiom/test/resources/xml/soap/invalidMustUnderstandSOAP12.xml @@ -0,0 +1,13 @@ + + + + foo + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/xml/soap/minimalMessage.xml b/axiom/test/resources/xml/soap/minimalMessage.xml new file mode 100644 index 0000000..ea76d72 --- /dev/null +++ b/axiom/test/resources/xml/soap/minimalMessage.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/axiom/test/resources/xml/soap/reallyReallyBigMessage.xml b/axiom/test/resources/xml/soap/reallyReallyBigMessage.xml new file mode 100644 index 0000000..687ed22 --- /dev/null +++ b/axiom/test/resources/xml/soap/reallyReallyBigMessage.xml @@ -0,0 +1,2529 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/xml/soap/sample1.txt b/axiom/test/resources/xml/soap/sample1.txt new file mode 100644 index 0000000..a5f7560 --- /dev/null +++ b/axiom/test/resources/xml/soap/sample1.txt @@ -0,0 +1,12 @@ +POST /axis/services/EchoService HTTP/1.1 +Host: 127.0.0.1 +Content-Type: application/soap+xml; charset="utf-8" + + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/xml/soap/sample1.xml b/axiom/test/resources/xml/soap/sample1.xml new file mode 100644 index 0000000..9d74dfe --- /dev/null +++ b/axiom/test/resources/xml/soap/sample1.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/xml/soap/security2-soap.xml b/axiom/test/resources/xml/soap/security2-soap.xml new file mode 100644 index 0000000..4d6c272 --- /dev/null +++ b/axiom/test/resources/xml/soap/security2-soap.xml @@ -0,0 +1,54 @@ + + + + + http://fabrikam123.com/getQuote + http://fabrikam123.com/stocks + mailto:johnsmith@fabrikam123.com + uuid:84b9f5d0-33fb-4a81-b02b-5b760641c1d6 + + + + MIIEZzCCA9CgAwIBAgIQEmtJZc0rqrKh5i... + + + + + + + + + + + + EULddytSo1... + + + + BL8jdfToEb1l/vXcMZNNjPOV... + + + + + + + + + + + + QQQ + + + \ No newline at end of file diff --git a/axiom/test/resources/xml/soap/soap11/soap11fault.xml b/axiom/test/resources/xml/soap/soap11/soap11fault.xml new file mode 100644 index 0000000..c9acd34 --- /dev/null +++ b/axiom/test/resources/xml/soap/soap11/soap11fault.xml @@ -0,0 +1,16 @@ + + + Test + + + + SOAP-ENV:MustUnderstand + SOAP Must Understand Error + Actor + Detail text + Some Element Text + + + + \ No newline at end of file diff --git a/axiom/test/resources/xml/soap/soap11/soap11message.xml b/axiom/test/resources/xml/soap/soap11/soap11message.xml new file mode 100644 index 0000000..8a0b231 --- /dev/null +++ b/axiom/test/resources/xml/soap/soap11/soap11message.xml @@ -0,0 +1,46 @@ + + + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+ + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + + http://localhost:8081/axis/services/BankPort + +
+ + + + env:Sender + + Sender Timeout + + http://schemas.xmlsoap.org/soap/envelope/actor/ultimateReceiver + + + Details of error + + P5M + + + + P3M + + + + + +
+ diff --git a/axiom/test/resources/xml/soap/soap12message.xml b/axiom/test/resources/xml/soap/soap12message.xml new file mode 100644 index 0000000..5830e6c --- /dev/null +++ b/axiom/test/resources/xml/soap/soap12message.xml @@ -0,0 +1,58 @@ + + + + foo + + + foo + + + foo + + + + + + env:Sender + + m:MessageTimeout In First Subcode + + m:MessageTimeout In Second Subcode + + m:MessageTimeout In Third Subcode + + + + + + Sender Timeout + + + http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver + + + ultimateReceiver + + + Details of error + + P5M\n + + + + P3M\n + + + + + + \ No newline at end of file diff --git a/axiom/test/resources/xml/soap/soapmessage.txt b/axiom/test/resources/xml/soap/soapmessage.txt new file mode 100644 index 0000000..acae3b5 --- /dev/null +++ b/axiom/test/resources/xml/soap/soapmessage.txt @@ -0,0 +1,16 @@ +POST /axis/services/EchoService HTTP/1.1 +Host: 127.0.0.1 +Content-Type: application/soap+xml; charset="utf-8" + + + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + http://localhost:8081/axis/services/BankPort + +
http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous
+
+
+ + + +
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/soapmessage.xml b/axiom/test/resources/xml/soap/soapmessage.xml new file mode 100644 index 0000000..0f49778 --- /dev/null +++ b/axiom/test/resources/xml/soap/soapmessage.xml @@ -0,0 +1,20 @@ + + + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+
+ + + + +
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/soapmessage1.xml b/axiom/test/resources/xml/soap/soapmessage1.xml new file mode 100644 index 0000000..3d69585 --- /dev/null +++ b/axiom/test/resources/xml/soap/soapmessage1.xml @@ -0,0 +1,27 @@ + + + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+
+ + + + + 1001 + + +
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/test.xml b/axiom/test/resources/xml/soap/test.xml new file mode 100644 index 0000000..3a303d4 --- /dev/null +++ b/axiom/test/resources/xml/soap/test.xml @@ -0,0 +1,59 @@ + + + + foo + + + foo + + + foo + + + + + + env:Sender + + m:MessageTimeout In First Subcode + + m:MessageTimeout In Second Subcode + + m:MessageTimeout In Third Subcode + + + + + + Sender Timeout + + + http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver + + + ultimateReceiver + + + Details of error + + P5M\n + + + + P3M\n + + + + + + + diff --git a/axiom/test/resources/xml/soap/whitespacedMessage.xml b/axiom/test/resources/xml/soap/whitespacedMessage.xml new file mode 100644 index 0000000..0af632b --- /dev/null +++ b/axiom/test/resources/xml/soap/whitespacedMessage.xml @@ -0,0 +1,27 @@ + + + + + + + + uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5 + + http://localhost:8081/axis/services/BankPort + +
+ http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous +
+
+ +
+ + + + + + + + +
\ No newline at end of file diff --git a/axiom/test/resources/xml/soap/wrongEnvelopeNamespace.xml b/axiom/test/resources/xml/soap/wrongEnvelopeNamespace.xml new file mode 100644 index 0000000..ff81835 --- /dev/null +++ b/axiom/test/resources/xml/soap/wrongEnvelopeNamespace.xml @@ -0,0 +1,12 @@ + + + + + + IBM + + + + \ No newline at end of file diff --git a/axiom/test/soap/Makefile.am b/axiom/test/soap/Makefile.am new file mode 100644 index 0000000..fdf79a0 --- /dev/null +++ b/axiom/test/soap/Makefile.am @@ -0,0 +1,13 @@ +TESTS = test_soap +noinst_PROGRAMS = test_soap +check_PROGRAMS = test_soap +SUBDIRS = +AM_CFLAGS = -g -O2 -pthread +test_soap_SOURCES = test_soap.c + +test_soap_LDADD = ../../../util/src/libaxutil.la \ + $(top_builddir)/src/om/libaxis2_axiom.la + +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/src/parser \ + -I ../../../util/include diff --git a/axiom/test/soap/test_soap.c b/axiom/test/soap/test_soap.c new file mode 100644 index 0000000..13f90e6 --- /dev/null +++ b/axiom/test/soap/test_soap.c @@ -0,0 +1,550 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +FILE *f = NULL; +int +read_soap( + char *buffer, + int size, + void *ctx) +{ + int len = 0; + char *pos = NULL; + len = fread(buffer, sizeof(char), size, f); + if (buffer) + pos = strstr(buffer, "---"); + if (pos) + { + len = pos - buffer; + *pos = '\0'; + } + printf("buffer = %s\n", buffer); + return len; +} + +/*int read_soap(char *buffer, int size, void *ctx) +{ + return fread(buffer, sizeof(char), size, f); +}*/ + +int +close_soap( + void *ctx) +{ + fclose(f); + return AXIS2_TRUE; +} + +int +printnode( + axiom_node_t * om_node, + const axutil_env_t * env) +{ + axiom_element_t *om_ele = NULL; + axis2_char_t *localname = NULL; + axiom_namespace_t *om_ns = NULL; + axis2_char_t *uri = NULL; + axis2_char_t *prefix = NULL; + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + if (!om_node) + return AXIS2_FAILURE; + + if (axiom_node_get_node_type(om_node, env) == AXIOM_ELEMENT) + { + om_ele = (axiom_element_t *) axiom_node_get_data_element(om_node, env); + if (!om_ele) + return AXIS2_FAILURE; + + localname = axiom_element_get_localname(om_ele, env); + if (localname) + printf("\n %s \n", localname); + om_ns = axiom_element_get_namespace(om_ele, env, om_node); + + if (om_ns) + { + prefix = axiom_namespace_get_prefix(om_ns, env); + uri = axiom_namespace_get_uri(om_ns, env); + + printf("\n uri %s \n prefix %s \n", uri, prefix); + } + } + return 0; +} + +int +build_soap( + const axutil_env_t * env, + const char *filename, + const axis2_char_t * uri) +{ + axiom_stax_builder_t *om_builder = NULL; + + axiom_xml_reader_t *xml_reader = NULL; + + axiom_soap_builder_t *soap_builder = NULL; + axiom_soap_envelope_t *soap_envelope = NULL; + + axiom_node_t *om_node = NULL; + axis2_char_t *buffer = NULL; + + axiom_xml_writer_t *xml_writer = NULL; + axiom_output_t *om_output = NULL; + + axiom_soap_body_t *soap_body = NULL; + axiom_soap_header_t *soap_header = NULL; + axiom_children_qname_iterator_t *children_iter = NULL; + + int status = AXIS2_SUCCESS; + + if (!filename) + return -1; + f = fopen(filename, "r"); + if (!f) + return -1; + printf(" \n\n _________ Test SOAP BUILD ___________ \n\n "); + + xml_reader = + axiom_xml_reader_create_for_io(env, read_soap, close_soap, NULL, NULL); + if (!xml_reader) + { + printf("%s \n", axutil_error_get_message(env->error)); + return AXIS2_FAILURE; + } + + om_builder = axiom_stax_builder_create(env, xml_reader); + if (!om_builder) + { + axiom_xml_reader_free(xml_reader, env); + printf("%s \n", axutil_error_get_message(env->error)); + return AXIS2_FAILURE; + } + + soap_builder = axiom_soap_builder_create(env, om_builder, uri); + if (!soap_builder) + { + printf("%s \n", axutil_error_get_message(env->error)); + return AXIS2_FAILURE; + } + soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env); + if (!soap_envelope) + { + axiom_soap_builder_free(soap_builder, env); + printf("%s \n", axutil_error_get_message(env->error)); + return AXIS2_FAILURE; + } + + om_node = axiom_soap_envelope_get_base_node(soap_envelope, env); + + if (om_node) + printnode(om_node, env); + + soap_header = axiom_soap_envelope_get_header(soap_envelope, env); + if (soap_header) + { + om_node = axiom_soap_header_get_base_node(soap_header, env); + if (om_node) + printnode(om_node, env); + + children_iter = + axiom_soap_header_examine_all_header_blocks(soap_header, env); + if (children_iter) + { + /*while (axiom_children_iterator_has_next(children_iter, env)) + { + om_node = axiom_children_iterator_next(children_iter, env); + if (om_node) + printnode(om_node, env); + } */ + } + } + + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + if (soap_body) + { + if (axiom_soap_body_has_fault(soap_body, env)); + printf("axiom_soap_body_has_fault\n"); + om_node = axiom_soap_body_get_base_node(soap_body, env); + if (om_node) + printnode(om_node, env); + else + printf("\n\n soap body base node null \n\n"); + } + else + { + printf("%s \n", axutil_error_get_message(env->error)); + printf("\n\n ERROR soap_body NULL.\n\n"); + return AXIS2_FAILURE; + } + + if (axiom_soap_body_has_fault(soap_body, env)) + { + printf("\n\nsoap body has a fault element\n\n\n "); + } + + om_node = axiom_soap_body_get_base_node(soap_body, env); + if (om_node) + { + while (!(axiom_node_is_complete(om_node, env))) + { + status = axiom_soap_builder_next(soap_builder, env); + if (status == AXIS2_FAILURE) + { + printf("failure %s", axutil_error_get_message(env->error)); + return AXIS2_FAILURE; + } + } + } + + xml_writer = + axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE, + AXIS2_XML_PARSER_TYPE_BUFFER); + if (!xml_writer) + { + axiom_soap_builder_free(soap_builder, env); + return AXIS2_FAILURE; + } + + om_output = axiom_output_create(env, xml_writer); + if (!om_output) + { + axiom_soap_builder_free(soap_builder, env); + axiom_xml_writer_free(xml_writer, env); + return AXIS2_FAILURE; + } + + axiom_soap_envelope_serialize(soap_envelope, env, om_output, AXIS2_FALSE); + + buffer = (axis2_char_t *) axiom_xml_writer_get_xml(xml_writer, env); + + printf("\n\nThe serialized xml is >>>>>>>>>>>>>\n\n\n%s \n\n\n", buffer); + + if (buffer) + AXIS2_FREE(env->allocator, buffer); + + axiom_soap_envelope_free(soap_envelope, env); + + printf(" \n __________ END TEST SOAP BUILD ____________ \n"); + + return AXIS2_SUCCESS; +} + +int +build_soap_programatically( + const axutil_env_t * env) +{ + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_soap_body_t *soap_body = NULL; + axiom_soap_header_t *soap_header = NULL; + axiom_soap_fault_t *soap_fault = NULL; + axiom_soap_fault_code_t *fault_code = NULL; + axiom_soap_header_block_t *hb1 = NULL; + + axiom_namespace_t *env_ns = NULL; + axiom_namespace_t *test_ns = NULL; + axiom_namespace_t *role_ns = NULL; + + axiom_xml_writer_t *xml_writer = NULL; + axiom_output_t *om_output = NULL; + + axis2_char_t *buffer = NULL; + axiom_node_t *hb_node = NULL; + axiom_element_t *hb_ele = NULL; + + printf(" \n ____________ BUILD SOAP PROGRAMATICALLY _______________ \n"); + + env_ns = + axiom_namespace_create(env, "http://www.w3.org/2003/05/soap-envelope", + "env"); + if (!env_ns) + return AXIS2_FAILURE; + + soap_envelope = axiom_soap_envelope_create(env, env_ns); + if (!soap_envelope) + return AXIS2_FAILURE; + + soap_header = axiom_soap_header_create_with_parent(env, soap_envelope); + if (!soap_header) + return AXIS2_FAILURE; + + test_ns = + axiom_namespace_create(env, "http://example.org/ts-tests", "test"); + + role_ns = + axiom_namespace_create(env, + "http://www.w3.org/2003/05/soap-envelope/role/next", + "role"); + + hb1 = + axiom_soap_header_block_create_with_parent(env, "echoOk", role_ns, + soap_header); + + hb_node = axiom_soap_header_block_get_base_node(hb1, env); + + hb_ele = axiom_node_get_data_element(hb_node, env); + + axiom_element_set_namespace(hb_ele, env, test_ns, hb_node); + + soap_body = axiom_soap_body_create_with_parent(env, soap_envelope); + + soap_fault = axiom_soap_fault_create_with_parent(env, soap_body); + + fault_code = axiom_soap_fault_code_create_with_parent(env, soap_fault); + + xml_writer = + axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE, + AXIS2_XML_PARSER_TYPE_BUFFER); + + om_output = axiom_output_create(env, xml_writer); + + axiom_soap_envelope_serialize(soap_envelope, env, om_output, AXIS2_FALSE); + + buffer = (axis2_char_t *) axiom_xml_writer_get_xml(xml_writer, env); + + printf("%s \n", buffer); + + axiom_soap_envelope_free(soap_envelope, env); + + AXIS2_FREE(env->allocator, buffer); + + buffer = NULL; + + axiom_output_free(om_output, env); + + printf("\n __________ END BUILD SOAP PROGRAMATICALLY ____________\n"); + + return AXIS2_SUCCESS; +} + +int +create_soap_fault( + const axutil_env_t * env) +{ + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_soap_body_t *soap_body = NULL; + axiom_soap_fault_t *soap_fault = NULL; + axiom_xml_writer_t *xml_writer = NULL; + axiom_output_t *om_output = NULL; + axis2_char_t *buffer = NULL; + axis2_char_t *exception_text = NULL; + axis2_status_t status = 0; + + soap_envelope = + axiom_soap_envelope_create_default_soap_fault_envelope(env, + "Fault Code", + "Fault Reason", + AXIOM_SOAP11, + NULL, NULL); + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + soap_fault = axiom_soap_body_get_fault(soap_body, env); + + axiom_soap_fault_detail_create_with_parent(env, soap_fault); + axiom_soap_fault_role_create_with_parent(env, soap_fault); + xml_writer = + axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE, + AXIS2_XML_PARSER_TYPE_BUFFER); + om_output = axiom_output_create(env, xml_writer); + axiom_soap_envelope_serialize(soap_envelope, env, om_output, AXIS2_FALSE); + buffer = (axis2_char_t *) axiom_xml_writer_get_xml(xml_writer, env); + printf("\n Testing Create soap fault \n %s \n", buffer); + + status = axiom_soap_fault_set_exception(soap_fault, env, "MyNewException"); + exception_text = axiom_soap_fault_get_exception(soap_fault, env); + + printf(" Testing soap fault set exception \n"); + printf("Actual = %s Expected = %s |", exception_text, "MyNewException"); + if (status && (0 == strcmp(exception_text, "MyNewException"))) + printf("SUCCESS\n"); + else + printf("FAILURE\n"); + + axiom_soap_envelope_free(soap_envelope, env); + axiom_output_free(om_output, env); + return 0; +} + +int +create_soap_fault_with_exception( + const axutil_env_t * env) +{ + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_soap_body_t *soap_body = NULL; + axiom_soap_fault_t *soap_fault = NULL; + axiom_xml_writer_t *xml_writer = NULL; + axiom_output_t *om_output = NULL; + axis2_char_t *exception_text = NULL; + + soap_envelope = + axiom_soap_envelope_create_default_soap_fault_envelope(env, + "Fault Code", + "Fault Reason", + AXIOM_SOAP11, + NULL, NULL); + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + soap_fault = + axiom_soap_fault_create_with_exception(env, soap_body, "MyException"); + + axiom_soap_fault_detail_create_with_parent(env, soap_fault); + axiom_soap_fault_role_create_with_parent(env, soap_fault); + xml_writer = + axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE, + AXIS2_XML_PARSER_TYPE_BUFFER); + om_output = axiom_output_create(env, xml_writer); + axiom_soap_envelope_serialize(soap_envelope, env, om_output, AXIS2_FALSE); + + exception_text = axiom_soap_fault_get_exception(soap_fault, env); + printf(" Testing Create soap fault with exception \n"); + printf("Actual = %s Expected = %s |", exception_text, "MyException"); + if (0 == strcmp(exception_text, "MyException")) + printf("SUCCESS\n"); + else + printf("FAILURE\n"); + + axiom_soap_envelope_free(soap_envelope, env); + axiom_output_free(om_output, env); + return 0; +} + +int +test_soap_fault_node( + const axutil_env_t * env) +{ + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_soap_body_t *soap_body = NULL; + axiom_soap_fault_t *soap_fault = NULL; + axis2_char_t *node_text = NULL; + axiom_soap_fault_node_t *fault_node = NULL; + axis2_status_t status = 0; + + printf("Testing soap fault node \n"); + soap_envelope = + axiom_soap_envelope_create_default_soap_fault_envelope(env, + "env:Receiver", + "Something went wrong!", + AXIOM_SOAP12, + NULL, NULL); + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + soap_fault = axiom_soap_body_get_fault(soap_body, env); + + fault_node = axiom_soap_fault_node_create_with_parent(env, soap_fault); + status = axiom_soap_fault_node_set_value(fault_node, env, "MyFaultNode"); + node_text = axiom_soap_fault_node_get_value(fault_node, env); + + printf("Actual = %s Expected = %s |", node_text, "MyFaultNode"); + if (0 == strcmp(node_text, "MyFaultNode")) + printf("SUCCESS\n"); + else + printf("FAILURE\n"); + axiom_soap_envelope_free(soap_envelope, env); + return 0; +} + +int +test_soap_fault_value( + const axutil_env_t * env) +{ + axiom_soap_envelope_t *soap_envelope = NULL; + axiom_soap_body_t *soap_body = NULL; + axiom_soap_fault_t *soap_fault = NULL; + axiom_soap_fault_code_t *soap_code = NULL; + axiom_soap_fault_value_t *value = NULL; + axis2_char_t *value_text = NULL; + + printf("TEST SOAP FAULT VALUE\n"); + soap_envelope = + axiom_soap_envelope_create_default_soap_fault_envelope(env, + "env:Receiver", + "Something went wrong!", + AXIOM_SOAP12, + NULL, NULL); + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + soap_fault = axiom_soap_body_get_fault(soap_body, env); + soap_code = axiom_soap_fault_get_code(soap_fault, env); + value = axiom_soap_fault_code_get_value(soap_code, env); + value_text = axiom_soap_fault_value_get_text(value, env); + + printf("Actual = %s Expected = %s |", value_text, "env:Receiver"); + if (0 == strcmp(value_text, "env:Receiver")) + printf("SUCCESS\n"); + else + printf("FAILURE\n"); + + axiom_soap_envelope_free(soap_envelope, env); + return 0; +} + +int +main( + int argc, + char *argv[]) +{ + axutil_env_t *env = NULL; + axutil_allocator_t *allocator = NULL; + axutil_error_t *error = NULL; + axutil_log_t *log = NULL; + const axis2_char_t *uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; + const char *filename = "../resources/xml/soap/test.xml"; + if (argc > 1) + filename = argv[1]; + if (argc > 2) + { + if (axutil_strcmp(argv[2], "0") == 0) + uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; + else if (axutil_strcmp(argv[2], "1") == 0) + uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; + } + allocator = axutil_allocator_init(NULL); + log = axutil_log_create(allocator, NULL, "test_soap.log"); + log->level = AXIS2_LOG_LEVEL_DEBUG; + error = axutil_error_create(allocator); + env = axutil_env_create_with_error_log(allocator, error, log); + + axutil_error_init(); + /*build_soap_programatically(env); */ + build_soap(env, filename, uri); + create_soap_fault(env); + create_soap_fault_with_exception(env); + test_soap_fault_node(env); + test_soap_fault_value(env); + axutil_env_free(env); + return 0; +} diff --git a/axiom/test/util/Makefile.am b/axiom/test/util/Makefile.am new file mode 100644 index 0000000..df0fd11 --- /dev/null +++ b/axiom/test/util/Makefile.am @@ -0,0 +1,8 @@ +noinst_PROGRAMS = axiom +axiom_SOURCES = axiom_util_test.c +axiom_LDADD = \ + $(top_builddir)/src/om/libaxis2_axiom.la + +INCLUDES = -I$(top_builddir)/include \ + -I ../../../util/include \ + -I ../../../include diff --git a/axiom/test/util/axiom_util_test.c b/axiom/test/util/axiom_util_test.c new file mode 100644 index 0000000..38f44f4 --- /dev/null +++ b/axiom/test/util/axiom_util_test.c @@ -0,0 +1,168 @@ +#include +#include +#include +#include +#include +#include "../../../util/test/util/create_env.h" + FILE *f = NULL; + axiom_node_t *node = NULL; + axiom_node_t *child = NULL; + axiom_types_t node_type; + axiom_node_t *first_node = NULL; + axiom_element_t *my_ele = NULL; + axiom_element_t *first_element = NULL; + axis2_char_t *uri = "http://www.develop.com/student"; + const axutil_uri_t * uri1 = NULL; + axiom_node_t *last_child = NULL; + axiom_element_t *localname_last_child = NULL; + axiom_element_t *localname_next_sibling = NULL; + axiom_element_t *uri_localname_first_child = NULL; + axiom_element_t *uri_localname_last_child = NULL; + axiom_element_t *uri_localname_next_sibling = NULL; + axiom_element_t *localname_first_child = NULL; + axis2_char_t *localname = NULL; + axiom_element_t *data_element = NULL; + axiom_element_t *next_sibling = NULL; + axiom_namespace_t *ns = NULL; + axiom_element_t *last_element = NULL; + axutil_qname_t *qname = NULL; + axis2_char_t *attr_name = NULL; + axiom_attribute_t *attr = NULL; + axis2_char_t *attr_value = NULL; + axiom_element_t *localname_attr_first_child = NULL; + axiom_element_t *localname_attr_last_child = NULL; + axiom_element_t *localname_attr_next_sibling = NULL; + axiom_child_element_iterator_t * child_element = NULL; + axis2_char_t * localpart = "type"; + axis2_char_t *child_node_text = NULL; + axis2_char_t *node_namespace_uri = NULL; + axiom_document_t * new_document = NULL; + axutil_array_list_t * names; + axiom_node_t *parent = NULL; + axis2_char_t * target = NULL; + axis2_char_t * value = NULL; + axiom_node_t *temp_node = NULL; + axiom_xml_reader_t *xml_reader = NULL; +int read_input_callback(char *buffer, int size, void* ctx) +{ + return fread(buffer, sizeof(char), size, f); +} +int close_input_callback(void *ctx) +{ + return fclose(f); +} +axis2_status_t build_and_serialize_om(axutil_env_t *env) +{ + axiom_node_t *root_node = NULL; + + axiom_element_t *root_ele = NULL; + axiom_document_t *document = NULL; + axiom_stax_builder_t *om_builder = NULL; + + f = fopen("test.xml","r"); + xml_reader = axiom_xml_reader_create_for_io(env, read_input_callback, close_input_callback, NULL, NULL); + if(!xml_reader) + return -1; + + om_builder = axiom_stax_builder_create(env, xml_reader); + if(!om_builder) + { + axiom_xml_reader_free(xml_reader, env); + return AXIS2_FAILURE; + } + + document = axiom_stax_builder_get_document(om_builder, env); + if(!document) + { + axiom_stax_builder_free(om_builder, env); + return AXIS2_FAILURE; + } + + root_node = axiom_document_get_root_element(document, env); + + if(!root_node) + { + axiom_stax_builder_free(om_builder, env); + return AXIS2_FAILURE; + } + if(root_node) + { + if(axiom_node_get_node_type(root_node, env) == AXIOM_ELEMENT) + { + root_ele = (axiom_element_t*)axiom_node_get_data_element(root_node, env); + if(root_ele) + { + printf(" %s is the root element \n" ,axiom_element_get_localname(root_ele, env)); + } + } + } + + axiom_document_build_all(document, env); + child = axiom_node_get_first_child(root_node, env); + printf ("%s\n", axiom_node_to_string (child, env)); + node = axiom_node_get_next_sibling(child, env); + temp_node = axiom_node_get_next_sibling (node, env); + child = axiom_node_get_first_child(node, env); + printf (" %s\n", axiom_node_to_string (temp_node, env)); + node_type = axiom_node_get_node_type(child,env); + data_element =(axiom_element_t*)axiom_node_get_data_element(child,env); + last_child = axiom_node_get_last_child(temp_node,env); + ns = axiom_element_get_namespace((axiom_element_t*)axiom_node_get_data_element(root_node,env), env, root_node); + printf("\nThe namespace = %s\n", axiom_namespace_to_string(ns,env)); + uri = axiom_namespace_get_uri(ns,env); + axiom_util_get_next_siblng_element_with_localnames(my_ele,env,node,names,&child); + axiom_util_get_last_child_element_with_localnames(my_ele,env,node,names,&child); + my_ele = axiom_util_get_first_child_element_with_uri(root_node,env,uri,&child); + axiom_util_get_first_child_element_with_localnames(my_ele,env,node,names,&child); + child = axiom_node_get_last_child(node, env); + axiom_util_new_document(env,uri1); + printf("\nmy_ele = "); + printf("%s\n ",axiom_element_to_string(my_ele,env,child)); + first_element = axiom_util_get_first_child_element(my_ele,env,child,&child); + printf("The first element = %s\n",axiom_element_to_string(first_element,env,node)); + last_element = axiom_util_get_last_child_element(my_ele,env,root_node,&child); + localname = axiom_element_get_localname(my_ele,env); + localname_last_child = axiom_util_get_last_child_element_with_localname(my_ele,env,root_node,localname,&child); + localname_next_sibling = axiom_util_get_next_siblng_element_with_localname(my_ele,env,root_node,localname,&child); + uri_localname_first_child = axiom_util_get_first_child_element_with_uri_localname(my_ele,env,root_node,localname,uri,&child); + uri_localname_last_child = axiom_util_get_last_child_element_with_uri_localname(my_ele,env,root_node,localname,uri,&child); + uri_localname_next_sibling = axiom_util_get_next_sibling_element_with_uri_localname(my_ele,env,root_node,localname,uri,&child); + qname = axutil_qname_create(env,localpart, NULL, NULL); + printf("The qname is "); + printf("%s",axutil_qname_to_string(qname,env)); + printf("\nThe localname is "); + printf("%s\n", axiom_element_get_localname(my_ele, env)); + attr = axiom_element_get_attribute(my_ele,env,qname); + attr_name = axiom_attribute_get_localname(attr,env); + attr_value = axiom_element_get_attribute_value(my_ele,env,qname); + localname_attr_first_child = axiom_util_get_first_child_element_with_localname_attr(my_ele,env,root_node,localname,attr_name,attr_value,&child); + localname_attr_last_child = axiom_util_get_last_child_element_with_localname_attr(my_ele,env,root_node,localname,attr_name,attr_value,&child); + localname_attr_next_sibling = axiom_util_get_next_siblng_element_with_localname_attr(my_ele,env,root_node,localname,attr_name,attr_value,&child); + axiom_util_get_child_node_text(node,env); + node_namespace_uri = axiom_util_get_node_namespace_uri(node,env); + child_element = axiom_util_get_child_elements(my_ele,env,node); + printf("%s\n",axiom_element_to_string(localname_attr_next_sibling,env,node)); + printf("%s\n","test is SUCCESS"); + return AXIS2_SUCCESS; +} + +int main() +{ + int status = AXIS2_SUCCESS; + axutil_env_t *env = NULL; + status = build_and_serialize_om(env); + + if(status == AXIS2_FAILURE) + { + printf(" build AXIOM failed"); + } + + axutil_env_free(env); + return 0; +} + + + + + + diff --git a/axiom/test/util/build.sh b/axiom/test/util/build.sh new file mode 100644 index 0000000..f3b3dd2 --- /dev/null +++ b/axiom/test/util/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +gcc axiom_util_test.c ../../../util/test/util/create_env.c -g -I$AXIS2C_HOME/include/axis2-1.2 -L$AXIS2C_HOME/lib -laxutil -laxis2_axiom -laxis2_parser -o axiom diff --git a/axiom/test/util/test.xml b/axiom/test/util/test.xml new file mode 100644 index 0000000..0b87a31 --- /dev/null +++ b/axiom/test/util/test.xml @@ -0,0 +1,7 @@ + + + 3235329 + Jeff Smith + C# + 9.5 + diff --git a/axiom/test/xpath/Makefile.am b/axiom/test/xpath/Makefile.am new file mode 100644 index 0000000..ed70ed6 --- /dev/null +++ b/axiom/test/xpath/Makefile.am @@ -0,0 +1,20 @@ +TESTS = +noinst_PROGRAMS = test_xpath test_xpath_streaming +check_PROGRAMS = test_xpath test_xpath_streaming +SUBDIRS = +test_xpath_SOURCES = test_xpath.c + +test_xpath_streaming_SOURCES = test_xpath_streaming.c + +test_xpath_LDADD = ../../../util/src/libaxutil.la \ + $(top_builddir)/src/om/libaxis2_axiom.la \ + $(top_builddir)/src/xpath/libaxis2_xpath.la + +test_xpath_streaming_LDADD = ../../../util/src/libaxutil.la \ + $(top_builddir)/src/om/libaxis2_axiom.la \ + $(top_builddir)/src/xpath/libaxis2_xpath.la + +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/src/parser \ + -I ../../../include \ + -I ../../../util/include diff --git a/axiom/test/xpath/results.txt b/axiom/test/xpath/results.txt new file mode 100644 index 0000000..10c7385 --- /dev/null +++ b/axiom/test/xpath/results.txt @@ -0,0 +1,616 @@ + +"2020" +"1919" +"1818" +"1717" +"1616" +"1515" +"1414" +"1313" +"1212" +"1111" +"1010" +"99" +"88" +"77" +"66" +"55" +"44" +"33" +"22" +"11" +"2020" +"1919" +"1818" +"1717" +"1616" +"1515" +"1414" +"1313" +"1212" +"1111" +"1010" +"99" +"88" +"77" +"66" +"55" +"44" +"33" +"22" +"11" +# +"40.000000" +# +"55" +# +"2020" +"1919" +"1818" +"1717" +"1616" +"1515" +"1414" +"1313" +"1212" +"1111" +"1010" +"99" +"88" +"77" +"66" +"55" +"44" +"33" +"22" +"11" +"2020" +"1919" +"1818" +"1717" +"1616" +"1515" +"1414" +"1313" +"1212" +"1111" +"1010" +"99" +"88" +"77" +"66" +"55" +"44" +"33" +"22" +"11" +# +" + + 10 + + + 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99 + 1010 + 1111 + 1212 + 1313 + 1414 + 1515 + 1616 + 1717 + 1818 + 1919 + 2020 + + + 5 + + + 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99 + 1010 + 1111 + 1212 + 1313 + 1414 + 1515 + 1616 + 1717 + 1818 + 1919 + 2020 + + +" +# +" + + 10 + + + 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99 + 1010 + 1111 + 1212 + 1313 + 1414 + 1515 + 1616 + 1717 + 1818 + 1919 + 2020 + + + 5 + + + 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99 + 1010 + 1111 + 1212 + 1313 + 1414 + 1515 + 1616 + 1717 + 1818 + 1919 + 2020 + + +" +" + 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99 + 1010 + 1111 + 1212 + 1313 + 1414 + 1515 + 1616 + 1717 + 1818 + 1919 + 2020 + " +"33" +# +"2020" +"1919" +"1818" +"1717" +"1616" +"1515" +"1414" +"1313" +"1212" +"1111" +"1010" +"99" +"88" +"77" +"66" +"55" +"44" +# +"11" +"22" +# +"20" +"2020" +"19" +"1919" +"18" +"1818" +"17" +"1717" +"16" +"1616" +"15" +"1515" +"14" +"1414" +"13" +"1313" +"12" +"1212" +"11" +"1111" +"10" +"1010" +"9" +"99" +"8" +"88" +"7" +"77" +"6" +"66" +"5" +"55" +"4" +"44" +"20" +"2020" +"19" +"1919" +"18" +"1818" +"17" +"1717" +"16" +"1616" +"15" +"1515" +"14" +"1414" +"13" +"1313" +"12" +"1212" +"11" +"1111" +"10" +"1010" +"9" +"99" +"8" +"88" +"7" +"77" +"6" +"66" +"5" +"55" +"4" +"44" +# +"10" +"1" +"11" +"2" +"22" +"3" +"33" +"4" +"44" +"5" +"55" +"6" +"66" +"7" +"77" +"8" +"88" +"9" +"99" +"10" +"1010" +"11" +"1111" +"12" +"1212" +"13" +"1313" +"14" +"1414" +"15" +"1515" +"16" +"1616" +"17" +"1717" +"18" +"1818" +"19" +"1919" +"20" +"2020" +" + 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99 + 1010 + 1111 + 1212 + 1313 + 1414 + 1515 + 1616 + 1717 + 1818 + 1919 + 2020 + " +"5" +"1" +"11" +"2" +"22" +# +attr1 = "attribute_value_2" +attr1 = "attribute_value_1" +# +nsp = "http://xpath/test" +nsx = "http://xpath/test" +# +"5" +# +"2020" +"1919" +"1818" +"1717" +"1616" +"1515" +"1414" +"1313" +"1212" +"1111" +"1010" +"99" +"88" +"77" +"66" +"55" +"44" +"33" +"22" +"11" +"2020" +"1919" +"1818" +"1717" +"1616" +"1515" +"1414" +"1313" +"1212" +"1111" +"1010" +"99" +"88" +"77" +"66" +"55" +"44" +"33" +"22" +"11" +# +"44" +# +"20" +"19" +"18" +"17" +"16" +"15" +"14" +"13" +"12" +"11" +"10" +"9" +"8" +"7" +"6" +"5" +"4" +"3" +"2" +"1" +# +"2020" +"1919" +"1818" +"1717" +"1616" +"1515" +"1414" +"1313" +"1212" +"1111" +"1010" +"99" +"88" +"77" +"66" +"55" +"44" +"33" +"22" +"11" +# +"2020" +"1919" +"1818" +"1717" +"1616" +"1515" +"1414" +"1313" +"1212" +"1111" +"1010" +"99" +"88" +"77" +"66" +"55" +"44" +"33" +"22" +"11" +# +attr1 = "attribute_value_2" +# +"5" +"10" +# +"10" +# +"55" +# +"true" +# +"20" +"19" +"18" +"17" +"16" +"15" +"14" +"13" +"12" +"11" +"10" +"9" +"8" +"7" +"6" +"5" +"4" +"3" +"2" +"1" +# +"2020" +"1919" +"1818" +"1717" +"1616" +"1515" +"1414" +"1313" +"1212" +"1111" +"1010" +"99" +"88" +"77" +"66" +"55" +"44" +"33" +"22" +"11" +# +"2020" +"1919" +"1818" +"1717" +"1616" +"1515" +"1414" +"1313" +"1212" +"1111" +"1010" +"99" +"88" +"77" +"66" +"55" +"44" +"33" +"22" +"11" +# +"5" +"10" +# +" + 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99 + 1010 + 1111 + 1212 + 1313 + 1414 + 1515 + 1616 + 1717 + 1818 + 1919 + 2020 + " +# +" + 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99 + 1010 + 1111 + 1212 + 1313 + 1414 + 1515 + 1616 + 1717 + 1818 + 1919 + 2020 + " +# +attr1 = "attribute_value_1" +# \ No newline at end of file diff --git a/axiom/test/xpath/test.ns b/axiom/test/xpath/test.ns new file mode 100644 index 0000000..45508e2 --- /dev/null +++ b/axiom/test/xpath/test.ns @@ -0,0 +1,2 @@ +test +http://xpath/test diff --git a/axiom/test/xpath/test.xml b/axiom/test/xpath/test.xml new file mode 100644 index 0000000..fa0adb6 --- /dev/null +++ b/axiom/test/xpath/test.xml @@ -0,0 +1,55 @@ + + + + + 10 + + + 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99 + 1010 + 1111 + 1212 + 1313 + 1414 + 1515 + 1616 + 1717 + 1818 + 1919 + 2020 + + + 5 + + + 11 + 22 + 33 + 44 + 55 + 66 + 77 + 88 + 99 + 1010 + 1111 + 1212 + 1313 + 1414 + 1515 + 1616 + 1717 + 1818 + 1919 + 2020 + + + diff --git a/axiom/test/xpath/test.xpath b/axiom/test/xpath/test.xpath new file mode 100644 index 0000000..1ebe4a8 --- /dev/null +++ b/axiom/test/xpath/test.xpath @@ -0,0 +1,37 @@ +#Test: Functions +test/descendant::child +count(test/descendant::child) +#Test: Axes +test/node2/child::child[5] +test/descendant::child +test/node2/parent::* +test/node2/child[3]/grandchild/ancestor::* +test/node2/child[3]/following-sibling::* +test/node2/child[3]/preceding-sibling::* +test/node2/child[3]/following::* +test/node2/child[3]/preceding::* +test/*/attribute::* +test/*/namespace::* +test/node1/self::* +test/descendant-or-self::child +test/node2/child[4]/grandchild/ancestor-or-self::child +#Test: Namespaces +test/test:node2//grandchild +test/test:node2/child +test/test:node2/* +#Test: Attributes and Predicates +test/node1/@* +//*[@*] +//*[@attr1 = 'attribute_value_1'] +test/node2/child[grandchild = /test/node1] +#Test: Equality Expressions +test/node1 = test/node2/child +#Test: Abbreviated Axes +test/node2//grandchild +test/node2/child +test/node2/* +#Test: Random +test/*[@*] +test/node2 +test/test:node2 +test/test:node1/@* diff --git a/axiom/test/xpath/test_xpath.c b/axiom/test/xpath/test_xpath.c new file mode 100644 index 0000000..95e0d94 --- /dev/null +++ b/axiom/test/xpath/test_xpath.c @@ -0,0 +1,513 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* +Compiling For Windows: +cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /I %AXIS2C_HOME%\include /c *.c +link.exe /LIBPATH:%AXIS2C_HOME%\lib axutil.lib axiom.lib axis2_parser.lib axis2_engine.lib /OUT:test.exe *.obj +*/ +#include +#include +#include +#include +#include + +/* Function headers */ +axiom_node_t *build_test_xml(const axutil_env_t *env); + +void output_results(const axutil_env_t *env, axiom_xpath_result_t *xpath_result); + +axiom_node_t *read_test_xml(const axutil_env_t *env, char *file_name); + +void output_results(const axutil_env_t *env, + axiom_xpath_result_t *xpath_result); + +void evaluate(const axutil_env_t *env, + axiom_xpath_context_t *context, + axis2_char_t *expr_str); + +void evaluate_expressions(const axutil_env_t *env, + axiom_xpath_context_t *context, + char *file_name); + +void add_namespaces(const axutil_env_t *env, + axiom_xpath_context_t *context, + char *file_name); + +int readline(FILE *fin, char *str); + +FILE *fcor; +/*FILE *ftemp;*/ + +int main(int argc, char *argv[]) +{ + axiom_node_t *test_tree = NULL; + axis2_char_t *test_tree_str; + char *xml_file = "test.xml"; + char *xpath_file = "test.xpath"; + char *ns_file = "test.ns"; + char *cor_file = "results.txt"; + axiom_xpath_context_t *context = NULL; + + /* Create environment */ + axutil_env_t *env = + axutil_env_create_all("xpath_test.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set input file */ + if (argc > 1) + { + printf("Usage: test [xml_file xpath_file namespaces_file results_file]\n\n"); + printf("\tLook at the example test case:"); + printf(" test.xml, test.xpath test.ns\n\n"); + + if(argc > 4) + { + xml_file = argv[1]; + xpath_file = argv[2]; + ns_file = argv[3]; + cor_file = argv[4]; + } + } + + /*Create the request */ + /* test_tree = build_test_xml(env); */ + test_tree = read_test_xml(env, (axis2_char_t *)xml_file); + + fcor = fopen(cor_file, "r"); + /*ftemp = fopen("temp.txt", "w");*/ + + if (!fcor) + { + printf("Error opening file: %s\n", cor_file); + } + + if (test_tree) + { + test_tree_str = axiom_node_to_string(test_tree, env); + printf("\nTesting XML\n-----------\n\"%s\"\n\n\n", test_tree_str); + + /* Create XPath Context */ + context = axiom_xpath_context_create(env, test_tree); + + /* Namespaces */ + add_namespaces(env, context, ns_file); + + evaluate_expressions(env, context, xpath_file); + + test_tree_str = axiom_node_to_string(test_tree, env); + printf("\n\nFinal XML\n-----------\n\"%s\"\n\n\n", test_tree_str); + } + + /* Freeing memory */ + if (context) + { + axiom_xpath_free_context(env, context); + } + + if (test_tree) + { + axiom_node_free_tree(test_tree, env); + } + + if (env) + { + axutil_env_free((axutil_env_t *) env); + } + + if(fcor) + { + fclose(fcor); + } + + return 0; +} + +int readline(FILE *fin, char *str) +{ + int i; + + for (i = 0; 1; i++) + { + str[i] = (char)getc(fin); + + if (str[i] == '\n' || str[i] == '\r' || str[i] == EOF) + { + break; + } + } + + str[i] = '\0'; + + return i; +} + +void add_namespaces(const axutil_env_t *env, + axiom_xpath_context_t *context, + char *file_name) +{ + FILE *fin = NULL; + char prefix[1024]; + char uri[1024]; + axiom_namespace_t *ns; + + fin = fopen(file_name, "r"); + + if (!fin) + { + printf("Error opening file: %s\n", file_name); + return; + } + + /* Compiling XPath expression */ + while (1) + { + if (readline(fin, prefix) == 0) + { + break; + } + + if (readline(fin, uri) == 0) + { + break; + } + + ns = axiom_namespace_create( + env, (axis2_char_t *)uri, (axis2_char_t *)prefix); + + if (ns) + { + axiom_xpath_register_namespace(context, ns); + } + } + + fclose(fin); +} + +void evaluate_expressions( + const axutil_env_t *env, + axiom_xpath_context_t *context, + char *file_name) +{ + FILE *fin = NULL; + char str[1024]; + + fin = fopen(file_name, "r"); + + if (!fin) + { + printf("Error opening file: %s\n", file_name); + return; + } + + /* Compiling XPath expression */ + while (1) + { + if (readline(fin, str) == 0) + { + break; + } + + if (str[0] == '#') + { + printf("\n\n%s", str + 1); + continue; + } + + evaluate(env, context, (axis2_char_t *)str); + } + + fclose(fin); +} + +void evaluate( + const axutil_env_t *env, + axiom_xpath_context_t *context, + axis2_char_t *expr_str) +{ + axiom_xpath_expression_t *expr = NULL; + axiom_xpath_result_t *result = NULL; + + printf("\nCompiling XPath expression: \"%s\" ...\n", expr_str); + expr = axiom_xpath_compile_expression(env, expr_str); + + if (!expr) + { + printf("Compilation error."); + printf("Please check the systax of the XPath query.\n"); + + return; + } + + /* Evaluating XPath expression */ + printf("Evaluating...\n"); + result = axiom_xpath_evaluate(context, expr); + + if (!result) + { + printf("An error occured while evaluating the expression.\n"); + + axiom_xpath_free_expression(env, expr); + + return; + } + + if (result->flag == AXIOM_XPATH_ERROR_STREAMING_NOT_SUPPORTED) + { + printf("Streaming not supported.\n"); + + axiom_xpath_free_expression(env, expr); + + return; + } + + output_results(env, result); + + if (result) + { + axiom_xpath_free_result(env, result); + } + + if (expr) + { + axiom_xpath_free_expression(env, expr); + } +} + +int compare_result(axis2_char_t *rs) +{ + int i; + char c; + + /*fprintf(ftemp, "%s#", rs);*/ + + if(!fcor) + { + return 0; + } + + for(i = 0; 1; i++) + { + while(rs[i] == ' ' || rs[i] == '\n' || rs[i] == '\r' || rs[i] == '\t') + { + i++; + } + + do + { + c = (char)getc(fcor); + } + while(c == ' ' || c == '\n' || c == '\r' || c == '\t'); + + if(c == '#' || c == EOF) + { + break; + } + + if(c != rs[i]) + { + while(c != '#' && c != EOF) + { + c = getc(fcor); + } + + return 0; + } + } + + return rs[i] == '\0'; +} + +void output_results(const axutil_env_t *env, + axiom_xpath_result_t *xpath_result) +{ + axiom_xpath_result_node_t *xpath_result_node; + axiom_node_t *result_node; + axis2_char_t *result_str; + axis2_char_t result_set[100000]; + axis2_char_t temp_res[100000]; + + axiom_element_t *ele; + int i; + + result_set[0] = '\n'; + result_set[1] = '\0'; + + for (i = 0; i < axutil_array_list_size(xpath_result->nodes, env); i++) + { + xpath_result_node = axutil_array_list_get(xpath_result->nodes, env, i); + + if (xpath_result_node->type == AXIOM_XPATH_TYPE_NODE) + { + result_node = xpath_result_node->value; + ele = (axiom_element_t *)axiom_node_get_data_element( + result_node, env); + + if (ele) + { + /*result_str = axiom_element_get_text(ele, env, result_node);*/ + result_str = axiom_node_to_string(result_node, env); + + sprintf(temp_res, "\"%s\"\n", result_str); + strcat(result_set, temp_res); + } + } + else if (xpath_result_node->type == AXIOM_XPATH_TYPE_ATTRIBUTE) + { + result_str = + axiom_attribute_get_localname(xpath_result_node->value, env); + sprintf(temp_res, "%s = ", result_str); + strcat(result_set, temp_res); + result_str = + axiom_attribute_get_value(xpath_result_node->value, env); + sprintf(temp_res, "\"%s\"\n", result_str); + strcat(result_set, temp_res); + } + else if (xpath_result_node->type == AXIOM_XPATH_TYPE_NAMESPACE) + { + result_str = + axiom_namespace_get_prefix(xpath_result_node->value, env); + sprintf(temp_res, "%s = ", result_str); + strcat(result_set, temp_res); + result_str = + axiom_namespace_get_uri(xpath_result_node->value, env); + sprintf(temp_res, "\"%s\"\n", result_str); + strcat(result_set, temp_res); + } + else if (xpath_result_node->type == AXIOM_XPATH_TYPE_BOOLEAN) + { + sprintf(temp_res, "\"%s\"\n", + (*(axis2_bool_t *)xpath_result_node->value) ? "true" : "false"); + strcat(result_set, temp_res); + } + else if (xpath_result_node->type == AXIOM_XPATH_TYPE_TEXT) + { + sprintf(temp_res, "\"%s\"\n", + (axis2_char_t *)xpath_result_node->value); + strcat(result_set, temp_res); + } + else if (xpath_result_node->type == AXIOM_XPATH_TYPE_NUMBER) + { + sprintf(temp_res, "\"%lf\"\n", + *(double *)xpath_result_node->value); + strcat(result_set, temp_res); + } + } + + if(compare_result(result_set)) + { + printf("Test case passed\n"); + } + else + { + printf("Failed test case!\nOutput\n%s\n", result_set); + } +} + +axiom_node_t *read_test_xml(const axutil_env_t *env, axis2_char_t *file_name) +{ + axiom_xml_reader_t *reader = NULL; + axiom_stax_builder_t *builder = NULL; + axiom_document_t *document = NULL; + axiom_node_t *root = NULL; + + /* Create parser */ + reader = axiom_xml_reader_create_for_file(env, file_name, NULL); + + if (!reader) + { + printf("Error creating pullparser"); + return NULL; + } + + /* Create axiom_stax_builder */ + builder = axiom_stax_builder_create(env, reader); + + if (!builder) + { + printf("Error creating pull parser"); + return NULL; + } + + /* Create an om document */ + document = axiom_stax_builder_get_document(builder, env); + + if (!document) + { + printf("Error creating document"); + return NULL; + } + + /* Get root element */ + root = axiom_document_get_root_element(document, env); + if (!root) + { + printf("Root element null "); + axiom_stax_builder_free(builder, env); + return NULL; + } + + while (axiom_document_build_next(document, env)); + + return root; +} + +axiom_node_t * build_test_xml(const axutil_env_t *env) +{ + axiom_node_t *main_node; + axiom_node_t *order_node; + axiom_node_t *values_node; + axiom_node_t *value_node; + axiom_node_t *grandchild; + axis2_char_t value_str[255]; + axiom_element_t *order_ele; + axiom_element_t *values_ele; + axiom_element_t *value_ele; + axiom_element_t *grandchild_ele; + axiom_attribute_t *attribute; + int i, N = 20; + + axiom_namespace_t *ns1 = + axiom_namespace_create(env, "http://xpath/test", "ns1"); + + axiom_element_create(env, NULL, "test", ns1, &main_node); + + order_ele = + axiom_element_create(env, main_node, "node1", NULL, &order_node); + axiom_element_set_text(order_ele, env, "10", order_node); + attribute = + axiom_attribute_create(env, "attr1", "attribute_value_1", NULL); + axiom_element_add_attribute(order_ele, env, attribute, order_node); + + values_ele = + axiom_element_create(env, main_node, "node2", NULL, &values_node); + + for (i = 0 ; i < N; i++) + { + sprintf(value_str, "%d", i + 1); + + value_ele = + axiom_element_create(env, values_node, "child", NULL, &value_node); + axiom_element_set_text(value_ele, env, value_str, value_node); + + grandchild_ele = + axiom_element_create(env, value_node, "grandchild", NULL, &grandchild); + axiom_element_set_text(grandchild_ele, env, value_str /*"3 rd level"*/, grandchild); + } + + return main_node; +} diff --git a/axiom/test/xpath/test_xpath_streaming.c b/axiom/test/xpath/test_xpath_streaming.c new file mode 100644 index 0000000..6b64262 --- /dev/null +++ b/axiom/test/xpath/test_xpath_streaming.c @@ -0,0 +1,468 @@ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* +Compiling For Windows: +cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" /I %AXIS2C_HOME%\include /c *.c +link.exe /LIBPATH:%AXIS2C_HOME%\lib axutil.lib axiom.lib axis2_parser.lib axis2_engine.lib /OUT:test.exe *.obj +*/ +#include +#include +#include +#include +#include + +/* Function headers */ +void output_results(const axutil_env_t *env, axiom_xpath_result_t *xpath_result); + +axiom_node_t *read_test_xml(const axutil_env_t *env, char *file_name); + +void output_results(const axutil_env_t *env, + axiom_xpath_result_t *xpath_result); + +void evaluate(const axutil_env_t *env, + axis2_char_t *expr_str); + +void evaluate_expressions(const axutil_env_t *env, + char *file_name); + +void add_namespaces(const axutil_env_t *env, + axiom_xpath_context_t *context, + char *file_name); + +int readline(FILE *fin, char *str); + +FILE *fcor; +char *xml_file = "test.xml"; +char *xpath_file = "test.xpath"; +char *cor_file = "results.txt"; +char *ns_file = "test.ns"; + +/*FILE *ftemp;*/ + +int main(int argc, char *argv[]) +{ + axiom_node_t *test_tree = NULL; + axis2_char_t *test_tree_str; + + /* Create environment */ + axutil_env_t *env = + axutil_env_create_all("xpath_test.log", AXIS2_LOG_LEVEL_TRACE); + + /* Set input file */ + if (argc > 1) + { + printf("Usage: test [xml_file xpath_file namespaces_file results_file]\n\n"); + printf("\tLook at the example test case:"); + printf(" test.xml, test.xpath test.ns\n\n"); + + if(argc > 4) + { + xml_file = argv[1]; + xpath_file = argv[2]; + ns_file = argv[3]; + cor_file = argv[4]; + } + } + + /*Create the request */ + test_tree = read_test_xml(env, (axis2_char_t *)xml_file); + + fcor = fopen(cor_file, "r"); + /*ftemp = fopen("temp.txt", "w");*/ + + if (!fcor) + { + printf("Error opening file: %s\n", cor_file); + } + + if (test_tree) + { + test_tree_str = axiom_node_to_string(test_tree, env); + printf("\nTesting XML\n-----------\n\"%s\"\n\n\n", test_tree_str); + + axiom_node_free_tree(test_tree, env); + + evaluate_expressions(env, xpath_file); + } + + /* Freeing memory */ + if (env) + { + axutil_env_free((axutil_env_t *) env); + } + + if(fcor) + { + fclose(fcor); + } + + return 0; +} + +int readline(FILE *fin, char *str) +{ + int i; + + for (i = 0; 1; i++) + { + str[i] = (char)getc(fin); + + if (str[i] == '\n' || str[i] == '\r' || str[i] == EOF) + { + break; + } + } + + str[i] = '\0'; + + return i; +} + +void add_namespaces(const axutil_env_t *env, + axiom_xpath_context_t *context, + char *file_name) +{ + FILE *fin = NULL; + char prefix[1024]; + char uri[1024]; + axiom_namespace_t *ns; + + fin = fopen(file_name, "r"); + + if (!fin) + { + printf("Error opening file: %s\n", file_name); + return; + } + + /* Compiling XPath expression */ + while (1) + { + if (readline(fin, prefix) == 0) + { + break; + } + + if (readline(fin, uri) == 0) + { + break; + } + + ns = axiom_namespace_create( + env, (axis2_char_t *)uri, (axis2_char_t *)prefix); + + if (ns) + { + axiom_xpath_register_namespace(context, ns); + } + } + + fclose(fin); +} + +void evaluate_expressions( + const axutil_env_t *env, + char *file_name) +{ + FILE *fin = NULL; + char str[1024]; + + fin = fopen(file_name, "r"); + + if (!fin) + { + printf("Error opening file: %s\n", file_name); + return; + } + + /* Compiling XPath expression */ + while (1) + { + if (readline(fin, str) == 0) + { + break; + } + + if (str[0] == '#') + { + printf("\n\n%s", str + 1); + continue; + } + + evaluate(env, (axis2_char_t *)str); + } + + fclose(fin); +} + +void evaluate( + const axutil_env_t *env, + axis2_char_t *expr_str) +{ + axiom_xpath_expression_t *expr = NULL; + axiom_xpath_result_t *result = NULL; + axiom_node_t *test_tree = NULL; + axiom_xpath_context_t *context = NULL; + + test_tree = read_test_xml(env, (axis2_char_t *)xml_file); + + if(!test_tree) + { + printf("Error reading file: %s\n", xml_file); + return; + } + + /* Create XPath Context */ + context = axiom_xpath_context_create(env, test_tree); + + if(!context) + { + printf("Could not initialise XPath context\n"); + return; + } + + /* Namespaces */ + add_namespaces(env, context, ns_file); + + + printf("\nCompiling XPath expression: \"%s\" ...\n", expr_str); + expr = axiom_xpath_compile_expression(env, expr_str); + + if (!expr) + { + printf("Compilation error."); + printf("Please check the systax of the XPath query.\n"); + + return; + } + + /* Evaluating XPath expression */ + printf("Evaluating...\n"); + result = axiom_xpath_evaluate_streaming(context, expr); + + if (!result) + { + compare_result(""); + printf("An error occured while evaluating the expression.\n"); + + axiom_xpath_free_expression(env, expr); + + return; + } + + if (result->flag == AXIOM_XPATH_ERROR_STREAMING_NOT_SUPPORTED) + { + compare_result(""); + printf("Streaming not supported.\n"); + + axiom_xpath_free_expression(env, expr); + + return; + } + + output_results(env, result); + + if (result) + { + axiom_xpath_free_result(env, result); + } + + if (expr) + { + axiom_xpath_free_expression(env, expr); + } +} + +int compare_result(axis2_char_t *rs) +{ + int i; + char c; + + /*fprintf(ftemp, "%s#", rs);*/ + + if(!fcor) + { + return 0; + } + + for(i = 0; 1; i++) + { + while(rs[i] == ' ' || rs[i] == '\n' || rs[i] == '\r' || rs[i] == '\t') + { + i++; + } + + do + { + c = (char)getc(fcor); + } + while(c == ' ' || c == '\n' || c == '\r' || c == '\t'); + + if(c == '#' || c == EOF) + { + break; + } + + if(c != rs[i]) + { + while(c != '#' && c != EOF) + { + c = getc(fcor); + } + + return 0; + } + } + + return rs[i] == '\0'; +} + +void output_results(const axutil_env_t *env, + axiom_xpath_result_t *xpath_result) +{ + axiom_xpath_result_node_t *xpath_result_node; + axiom_node_t *result_node; + axis2_char_t *result_str; + axis2_char_t result_set[100000]; + axis2_char_t temp_res[100000]; + + axiom_element_t *ele; + int i; + + result_set[0] = '\n'; + result_set[1] = '\0'; + + for (i = 0; i < axutil_array_list_size(xpath_result->nodes, env); i++) + { + xpath_result_node = axutil_array_list_get(xpath_result->nodes, env, i); + + if (xpath_result_node->type == AXIOM_XPATH_TYPE_NODE) + { + result_node = xpath_result_node->value; + ele = (axiom_element_t *)axiom_node_get_data_element( + result_node, env); + + if (ele) + { + /*result_str = axiom_element_get_text(ele, env, result_node);*/ + result_str = axiom_node_to_string(result_node, env); + + sprintf(temp_res, "\"%s\"\n", result_str); + strcat(result_set, temp_res); + } + } + else if (xpath_result_node->type == AXIOM_XPATH_TYPE_ATTRIBUTE) + { + result_str = + axiom_attribute_get_localname(xpath_result_node->value, env); + sprintf(temp_res, "%s = ", result_str); + strcat(result_set, temp_res); + result_str = + axiom_attribute_get_value(xpath_result_node->value, env); + sprintf(temp_res, "\"%s\"\n", result_str); + strcat(result_set, temp_res); + } + else if (xpath_result_node->type == AXIOM_XPATH_TYPE_NAMESPACE) + { + result_str = + axiom_namespace_get_prefix(xpath_result_node->value, env); + sprintf(temp_res, "%s = ", result_str); + strcat(result_set, temp_res); + result_str = + axiom_namespace_get_uri(xpath_result_node->value, env); + sprintf(temp_res, "\"%s\"\n", result_str); + strcat(result_set, temp_res); + } + else if (xpath_result_node->type == AXIOM_XPATH_TYPE_BOOLEAN) + { + sprintf(temp_res, "\"%s\"\n", + (*(axis2_bool_t *)xpath_result_node->value) ? "true" : "false"); + strcat(result_set, temp_res); + } + else if (xpath_result_node->type == AXIOM_XPATH_TYPE_TEXT) + { + sprintf(temp_res, "\"%s\"\n", + (axis2_char_t *)xpath_result_node->value); + strcat(result_set, temp_res); + } + else if (xpath_result_node->type == AXIOM_XPATH_TYPE_NUMBER) + { + sprintf(temp_res, "\"%lf\"\n", + *(double *)xpath_result_node->value); + strcat(result_set, temp_res); + } + } + + if(compare_result(result_set)) + { + printf("Test case passed\n"); + } + else + { + printf("Failed test case!\nOutput\n%s\n", result_set); + } +} + +axiom_node_t *read_test_xml(const axutil_env_t *env, axis2_char_t *file_name) +{ + axiom_xml_reader_t *reader = NULL; + axiom_stax_builder_t *builder = NULL; + axiom_document_t *document = NULL; + axiom_node_t *root = NULL; + + /* Create parser */ + reader = axiom_xml_reader_create_for_file(env, file_name, NULL); + + if (!reader) + { + printf("Error creating pullparser"); + return NULL; + } + + /* Create axiom_stax_builder */ + builder = axiom_stax_builder_create(env, reader); + + if (!builder) + { + printf("Error creating pull parser"); + return NULL; + } + + /* Create an om document */ + document = axiom_stax_builder_get_document(builder, env); + + if (!document) + { + printf("Error creating document"); + return NULL; + } + + /* Get root element */ + root = axiom_document_get_root_element(document, env); + if (!root) + { + printf("Root element null "); + axiom_stax_builder_free(builder, env); + return NULL; + } + + while (axiom_document_build_next(document, env)); + + return root; +} -- cgit v1.1-32-gdbae