All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.axis2.xmlbeans.template.XmlbeansDatabindingTemplate.xsl Maven / Gradle / Ivy




    

    
    
    

    
    
    
        
        
        
        private final org.apache.xmlbeans.XmlOptions _xmlOptions;
        
        {
            _xmlOptions = new org.apache.xmlbeans.XmlOptions();
            _xmlOptions.setSaveNoXmlDecl();
            _xmlOptions.setSaveAggressiveNamespaces();
            _xmlOptions.setSaveNamespacesFirst();
        }
        
        /**
         * Get the {@link org.apache.xmlbeans.XmlOptions} object that the stub uses when
         * serializing objects to XML.
         *
         * @return the options used for serialization
         */
        public org.apache.xmlbeans.XmlOptions _getXmlOptions() {
            return _xmlOptions;
        }
        
        
            private static javax.xml.namespace.QName[] qNameArray = {
            
                ,new javax.xml.namespace.QName("","")
            
            };
        

        

            private  org.apache.axiom.om.OMElement  toOM( param, boolean optimizeContent)
            throws org.apache.axis2.AxisFault{

            
                
                     if (optimizeContent) {
                        org.apache.axiom.om.OMXMLParserWrapper builder = org.apache.axiom.om.OMXMLBuilderFactory.createStAXOMBuilder
                        (org.apache.axiom.om.OMAbstractFactory.getOMFactory(),new org.apache.axis2.util.StreamWrapper(param.newXMLStreamReader())) ;
                        org.apache.axiom.om.OMElement documentElement = builder.getDocumentElement(true);
                        optimizeContent(documentElement,qNameArray);
                        return documentElement;
                     } else {
                        return toOM(param);
                     }
                
                
                    return toOM(param);
                
            

            }

            private org.apache.axiom.om.OMElement toOM(final  param)
                    throws org.apache.axis2.AxisFault {

                org.apache.axiom.om.OMXMLParserWrapper builder = org.apache.axiom.om.OMXMLBuilderFactory.createOMBuilder(
                        new javax.xml.transform.sax.SAXSource(new org.apache.axis2.xmlbeans.XmlBeansXMLReader(param, _xmlOptions), new org.xml.sax.InputSource()));
                try {
                    return builder.getDocumentElement(true);
                } catch (java.lang.Exception e) {
                    throw org.apache.axis2.AxisFault.makeFault(e);
                }
            }
        


        

            
            
            
             
            

            
                
                    
                        
                        
                        
                        
                        

                        
                            
                            
                                
                                private  org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory,
                                
                                     param,
                                 dummyWrappedType,
                                boolean optimizeContent) throws org.apache.axis2.AxisFault{

                                 wrappedType = .Factory.newInstance();

                                
                                    
                                         innerType = wrappedType.addNew();
                                    
                                    
                                        . innerType = wrappedType.addNew();
                                    
                                

                                
                                    
                                        
                                            innerType.xsetArray(param);
                                        
                                        
                                            innerType.xset(param);
                                        
                                    
                                

                                org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
                                envelope.getBody().addChild(toOM(wrappedType, optimizeContent));
                                return envelope;

                                }

                            
                            
                                
                                private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory,  param, boolean optimizeContent, javax.xml.namespace.QName elementQName)
                                throws org.apache.axis2.AxisFault{
                                org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
                                if (param != null){
                                envelope.getBody().addChild(toOM(param, optimizeContent));
                                }
                                return envelope;
                                }
                            
                        
                        
                    

                    
                        
                    
                
            
            
            


                
                    
                        
                        

                        
                        
                            private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory,  param, boolean optimizeContent, javax.xml.namespace.QName elementQName)
                            throws org.apache.axis2.AxisFault {
                            org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
                            if (param != null){
                            envelope.getBody().addChild(toOM(param, optimizeContent));
                            }
                            return envelope;
                            }
                        

                    
                
                
                    
                   
                   
                   
                   

                    
                        
                        

                        

                            private  get(
                             wrappedType){

                            
                            
                                 
                                     return wrappedType.get().xgetArray();
                                 
                                 
                                     return wrappedType.get().xget();
                                 
                            
                        }
                       
                    
                
            
        


        /**
        *  get the default envelope
        */
        private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory){
        return factory.getDefaultEnvelope();
        }

        public org.apache.xmlbeans.XmlObject fromOM(
        org.apache.axiom.om.OMElement param,
        java.lang.Class type) throws org.apache.axis2.AxisFault{
        try{
        

            if (.class.equals(type)){
                org.apache.axiom.om.OMXMLStreamReaderConfiguration configuration
                    = new org.apache.axiom.om.OMXMLStreamReaderConfiguration();
                configuration.setPreserveNamespaceContext(true);
                return .Factory.parse(
                    param.getXMLStreamReader(false, configuration));
            }

        
        }catch(java.lang.Exception e){
        throw org.apache.axis2.AxisFault.makeFault(e);
        }
        return null;
        }

        
        

            private void optimizeContent(org.apache.axiom.om.OMElement element, javax.xml.namespace.QName[] qNames){
            for (int i = 0; i < qNames.length; i++) {
            markElementsAsOptimized(qNames[i],element);
            }
            }

            private void markElementsAsOptimized(javax.xml.namespace.QName qName,org.apache.axiom.om.OMElement rootElt){
            if (rootElt.getQName().equals(qName)){
            //get the text node and mark it
            org.apache.axiom.om.OMNode node = rootElt.getFirstOMChild();
            if (node.getType()==org.apache.axiom.om.OMNode.TEXT_NODE){
            ((org.apache.axiom.om.OMText)node).setOptimize(true);
            }

            }
            java.util.Iterator childElements = rootElt.getChildElements();
            while (childElements.hasNext()) {
            markElementsAsOptimized(qName,(org.apache.axiom.om.OMElement)childElements.next());
            }
            }
        
    




© 2015 - 2025 Weber Informatics LLC | Privacy Policy