Simples Assim

Posts Tagged ‘XQuery

Issue with XQDT 0.8.0

leave a comment »

Written by Fernando Ribeiro

August 14, 2011 at 11:40 pm

Posted in Software

Tagged with ,

Conditional Expressions in XQuery

leave a comment »

As per section 3.10 of the spec, the else-expression is required, but you can write it as:

if (true())
then
  <Element>Text</Element>
else
  ()

Written by Fernando Ribeiro

March 30, 2010 at 10:52 pm

Posted in Software

Tagged with

Custom SOAP Faults in Apache ServiceMix 4

leave a comment »

It can’t be realized without custom processors because although several expression languages can retrieve the exception message, neither the XQuery or XSLT components work with fault messages.

WSDL

<wsdl:definitions targetNamespace="http://www.fernandoribeiro.eti.br/ws/sample" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.fernandoribeiro.eti.br/ws/sample" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <xs:schema elementFormDefault="qualified" targetNamespace="http://www.fernandoribeiro.eti.br/ws/sample" xmlns:xs="http://www.w3.org/2001/XMLSchema">
            ...
            <xs:element name="SampleFault"> <!-- great opportunity for a common type -->
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="Message" type="xs:string" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:schema>
    </wsdl:types>
    ...
    <wsdl:message name="SampleFault">
        <wsdl:part name="SampleFault" element="tns:SampleFault" />
    </wsdl:message>
    <wsdl:portType name="SamplePortType">
        <wsdl:operation name="SampleOperation">
            ...
            <wsdl:fault name="SampleFault" message="tns:SampleFault" />
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="SampleSoapBinding" type="tns:SamplePortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
        ...
        <wsdl:operation name="SampleOperation">
            <soap:operation ... />
            ...
            <wsdl:fault name="SampleFault">
                <soap:fault name="SampleFault" use="literal" />
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="SampleService">
        <wsdl:port name="SamplePort" binding="tns:SampleSoapBinding">
            <soap:address location="http://ws.fernandoribeiro.eti.br/SampleService/" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

RouteBuilder

package br.eti.fernandoribeiro.ws.sample;

import org.apache.camel.builder.RouteBuilder;

public final class SampleRouteBuilder extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        onException(Exception.class).process(new SampleFaultProcessor());

        ...
    }

}

Processor

package br.eti.fernandoribeiro.ws.sample;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public final class SampleFaultProcessor implements Processor {
    private static final DocumentBuilderFactory FACTORY = DocumentBuilderFactory.newInstance();

    private DocumentBuilder builder;

    public SampleFaultProcessor() throws ParserConfigurationException {
        builder = FACTORY.newDocumentBuilder();
    }

    public void process(final Exchange exch) throws ParserConfigurationException {
        final Document doc = builder.newDocument();

        final Element root = doc.createElementNS("http://www.fernandoribeiro.eti.br/ws/sample", "SampleFault");

        final Element msg = doc.createElementNS("http://www.fernandoribeiro.eti.br/ws/sample", "Message");

        msg.setTextContent(exch.getException().getMessage());

        root.appendChild(msg);

        doc.appendChild(root);

        exch.getFault().setBody(doc);
    }

}

SOAP Response

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Server</faultcode>
         <faultstring/>
         <detail>
            <SampleFault xmlns="http://www.fernandoribeiro.eti.br/ws/sample">
               <Message>Sample Message</Message>
            </SampleFault>
         </detail>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Written by Fernando Ribeiro

December 21, 2009 at 12:36 am

Improvement to JBossESB 4.7

leave a comment »

It still misses support for XQuery.

https://jira.jboss.org/jira/browse/JBESB-3074 (vote for it!)

Written by Fernando Ribeiro

December 18, 2009 at 3:37 pm

Posted in Software

Tagged with ,

XQuery’s FLWOR “Flower” Expressions

leave a comment »

Written by Fernando Ribeiro

October 23, 2009 at 9:28 pm

Posted in Software

Tagged with

Using XQuery in FUSE 4.1

leave a comment »

Before you deploy routes with XQuery, you need to install the camel-saxon feature, as well as adding it to your POMs.

http://camel.apache.org/xquery.html

Written by Fernando Ribeiro

July 18, 2009 at 8:34 pm

Posted in Software

Tagged with ,

xs:choice in Apache XMLBeans

leave a comment »

When using it, you may need to iterate through several element lists:

import org.apache.xmlbeans.XmlCursor;
...
final XmlCursor cur = el.newCursor();

cur.selectPath("declare namespace simplesassim='http://fernandoribeiro.eti.br'; simplesassim:Element1 | simplesassim:Element2");

while (cur.toNextSelection()) {
  final Object obj = cur.getObject();
  ...
}

http://xmlbeans.apache.org/docs/2.0.0/guide/conSelectingXMLwithXQueryPathXPath.html

Written by Fernando Ribeiro

June 11, 2009 at 4:52 pm

Posted in Software

Tagged with ,

DataDirect Technologies Breaks SOA Price Barrier for Mainframes by Eliminating Costs for Web Services Processing

with 2 comments

With the DataDirect Shadow product’s patent-pending design, processing associated with SOA integration and data queries can be diverted from the mainframe’s General Purpose Processor (GPP) to be handled by the zIIP specialty engine – which does the work without using any of the mainframe licensed MIPs capacity.

Wouldn’t it be great if Progress Sonic ESB and DataDirect Shadow z/Services were integrated? There could also be service types for DataDirect XQuery and DataDirect XML Converters.

It ain’t really bad news for ESBs that web services can be created downstream, there is plenty to do in the middle.

http://www.businesswire.com/portal/site/google/?ndmViewId=news_view&newsId=20090505005528&newsLang=en

Written by Fernando Ribeiro

May 10, 2009 at 1:41 am

How to Create Null Elements in XSLT and XQuery

leave a comment »

XSLT

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <xsl:template match="/Root">
    <Root>
      <Element>
        <xsl:attribute name="xsi:nil">true</xsl:attribute>
      </Element>
    </Root>
  </xsl:template>
</xsl:stylesheet>

XQuery

declare namespace xsi= "http://www.w3.org/2001/XMLSchema-instance";

<Root>
  <Element>
    {
      attribute xsi:nil {true()}
    }
  </Element>
</Root>

http://www.w3.org/TR/xquery/#id-computedAttributes

Written by Fernando Ribeiro

January 30, 2009 at 1:23 pm

Posted in Software

Tagged with ,

XQuery 1.0 and XPath 2.0 Functions and Operators

leave a comment »

Written by Fernando Ribeiro

November 10, 2008 at 7:13 am

Posted in Software

Tagged with ,

Follow

Get every new post delivered to your Inbox.

Join 784 other followers