Stumped Transforming DSML Data With XSLT`

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • awilliam@whitemice.org

    Stumped Transforming DSML Data With XSLT`

    I'm using the BIE workflow engine and after querying an LDAP DSA I need
    to transform the XML response, which looks like -

    <?xml version="1.0" encoding="UTF-8" ?>
    <batchRespons e xmlns="urn:oasi s:names:tc:DSML :2:0:core"
    xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
    <searchRespon se requestID="9">
    <searchResultEn try dn="cn=Larry Simmons,ou=Peop le,o=Morrison
    Industries,c=US " requestID="9">
    attr name="morrisons erialid">
    <value>1015</value>
    </attr>
    <attr name="birthDate ">
    <value>02/17/1948</value>
    </attr>
    <attr name="cn">
    <value>Larry Simmons</value>
    </attr>
    <attr name="employeeN umber">
    <value>KZO004 </value>
    </attr>
    </searchResultEnt ry>
    .....
    <searchResultDo ne requestID="9">
    <resultCode code="0" descr="Success" />
    </searchResultDon e>
    </searchResponse>
    </batchResponse>

    Into something like -
    <result>
    <row>
    <cn>...</cn>
    <birthdate>.. .</birthdate>
    ....
    </row>
    ....
    </result>

    So I have an xslt like
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:styleshe et version="1.0"
    xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <result>
    <xsl:for-each
    select="batchRe sponse/searchResponse/searchResultEnt ry">
    <xsl:sort select="morriso nserialid"/>
    <row>
    <cn><xsl:valu e-of select="attr[@name='cn']/value"/></cn>
    <birthdate><xsl :value-of
    select="attr[@name='birthday ']/value"/></birthdate>
    <morrisonserial id><xsl:value-of
    select="attr[@name='morrison serialid']/value"/></morrisonseriali d>
    <fileAs><xsl:va lue-of
    select="attr[@name='fileAs']/value"/></fileAs>
    <startDate><xsl :value-of
    select="attr[@name='morrison positionstartda te']/value"/></startDate>
    </row>
    </xsl:for-each>
    </result>
    </xsl:template>
    </xsl:stylesheet>

    Only when I -
    xsltproc /var/spool/bie/xslt/dsaEmployeeExpo rt.2.xslt /tmp/ldapData.xml
    - all I get is -
    <?xml version="1.0"?>
    <result/>

    Huh?

  • Joris Gillis

    #2
    Re: Stumped Transforming DSML Data With XSLT`

    Tempore 20:02:40, die Tuesday 01 February 2005 AD, hinc in foro {comp.text.xml} scripsit <awilliam@white mice.org>:
    [color=blue]
    > Only when I -
    > xsltproc /var/spool/bie/xslt/dsaEmployeeExpo rt.2.xslt /tmp/ldapData.xml
    > - all I get is -
    > <?xml version="1.0"?>
    > <result/>
    >
    > Huh?[/color]
    Hi,

    It is a namespacing issue.
    Include the namespace of the XML document in the XSLT
    e.g.
    <xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" version="1.0" exclude-result-prefixes="in" xmlns:in="urn:o asis:names:tc:D SML:2:0:core">

    <xsl:template match="/">
    <result>
    <xsl:for-each
    select="in:batc hResponse/in:searchRespon se/in:searchResult Entry">
    <xsl:sort select="in:morr isonserialid"/>
    <row>
    <cn><xsl:valu e-of select="in:attr[@name='cn']/in:value"/></cn>
    <birthdate><xsl :value-of
    select="in:attr[@name='birthday ']/in:value"/></birthdate>
    <morrisonserial id><xsl:value-of
    select="in:attr[@name='morrison serialid']/in:value"/></morrisonseriali d>
    <fileAs><xsl:va lue-of
    select="in:attr[@name='fileAs']/in:value"/></fileAs>
    <startDate><xsl :value-of
    select="in:attr[@name='morrison positionstartda te']/in:value"/></startDate>
    </row>
    </xsl:for-each>
    </result>
    </xsl:template>

    regards,
    --
    Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
    Veni, vidi, wiki (http://www.wikipedia.org)

    Comment

    • David Carlisle

      #3
      Re: Stumped Transforming DSML Data With XSLT`


      this is a FAQ,

      <batchRespons e xmlns="urn:oasi s:names:tc:DSML :2:0:core"

      an element with name consisting of local name batchResponse and
      Namespace URI urn:....


      <xsl:for-each
      select="batchRe sponse/searchResponse/searchResultEnt ry">

      this is selecting batchResponse and searchResponse in no-namespace.
      which selects nothing in your document.

      add

      xmlns:D="urn:oa sis:names:tc:DS ML:2:0:core"
      to xsl:stylesheet then use

      <xsl:for-each
      select="D:batch Response/D:searchRespons e/D:searchResultE ntry">

      and similarly prefix all other references to this namespace.

      David

      Comment

      Working...