 <xsl:transform version="2.0"
    xmlns:po="http://www.w3.org/2002/ws/sawsdl/spec/examples/wsdl/PurchaseOrderService#"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    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:complexType>
        <xsl:variable name="fullName">
          <xsl:value-of select="sp:results/sp:result[position()=1]/sp:binding[@name='name']/sp:literal"/>
        </xsl:variable>
        <po:firstName>
          <xsl:value-of select="substring-before($fullName,' ')" />
        </po:firstName>
        <po:lastName>
          <xsl:value-of select="substring-after($fullName,' ')" />
        </po:lastName>
        <po:billingInfo type="item" minOccurs="1" maxOccurs="unbounded"/>
      </po:complexType>
      <xsl:apply-templates select="sp:results/sp:result" />
    </po:OrderRequest>
    </xsl:template>
    <xsl:template match="sp:result">
    <po:complexType name="item">
      <po:itemCode type="xs:string">
        <xsl:value-of select="sp:binding[@name='partNum']/sp:literal" />
      </po:itemCode>
      <po:quantity type="xs:float">
          <xsl:value-of select="sp:binding[@name='quantity']/sp:literal" />
      </po:quantity>
      <po:dueDate tyep="xs:string">
        <xsl:value-of select="sp:binding[@name='dueDate']/sp:literal" />
      </po:dueDate>
      <po:billingInfo type="xsd1:POBilling">
        <xsl:value-of select="sp:binding[@name='billingInfo']/sp:literal" />
      </po:billingInfo>
    </po:complexType>
  </xsl:template>
 </xsl:transform>
