<lowering>
  <sparqlQuery>
    PREFIX po: &lt;http://www.w3.org/2002/ws/sawsdl/spec/ontology/purchaseorder#&gt;
    SELECT ?qty ?UPC ?CustomerNo 
    WHERE { 
      ?order po:hasCustomer ?customer . 
        ?customer po:hasCustomerID ?id . 
          ?id po:hasLexicalRespresentation ?CustomerNo . 
      ?order po:hasLineItems ?item . 
        ?item po:hasQuantity ?qtyClass . 
          ?qtyClass po:hasAmount ?qty .
        ?item po:hasProduct ?product .
          ?product po:hasProductCode ?code . 
            ?code po:hasLexicalRespresentation ?UPC }
  </sparqlQuery>
  <xsl:transform version="2.0"
    xmlns:po="http://www.w3.org/2002/ws/sawsdl/spec/wsdl/order#"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:sp="http://www.w3.org/2005/sparql-results#">
    <xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes" />
    <xsl:template match="/sp:sparql">
      <po:OrderRequest>
        <po:customerNo>
          <xsl:value-of
            select="sp:results/sp:result[position()=1]/sp:binding[@name='CustomerNo']/sp:literal" />
        </po:customerNo>
        <xsl:apply-templates select="sp:results/sp:result" />
      </po:OrderRequest>
    </xsl:template>
    <xsl:template match="sp:result">
      <po:orderItem>
        <xsl:attribute name="quantity">
          <xsl:value-of select="sp:binding[@name='qty']/sp:literal" />
        </xsl:attribute>
        <po:UPC>
          <xsl:value-of select="sp:binding[@name='UPC']/sp:literal" />
        </po:UPC>
      </po:orderItem>
    </xsl:template>
  </xsl:transform>
</lowering>