Stumped Transforming DSML Data With XSLT`

Discussion in 'XML' started by awilliam@whitemice.org, Feb 1, 2005.

  1. Guest

    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" ?>
    <batchResponse xmlns="urn:eek:asis:names:tc:DSML:2:0:core"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <searchResponse requestID="9">
    <searchResultEntry dn="cn=Larry Simmons,ou=People,o=Morrison
    Industries,c=US" requestID="9">
    attr name="morrisonserialid">
    <value>1015</value>
    </attr>
    <attr name="birthDate">
    <value>02/17/1948</value>
    </attr>
    <attr name="cn">
    <value>Larry Simmons</value>
    </attr>
    <attr name="employeeNumber">
    <value>KZO004</value>
    </attr>
    </searchResultEntry>
    .....
    <searchResultDone requestID="9">
    <resultCode code="0" descr="Success" />
    </searchResultDone>
    </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:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <result>
    <xsl:for-each
    select="batchResponse/searchResponse/searchResultEntry">
    <xsl:sort select="morrisonserialid"/>
    <row>
    <cn><xsl:value-of select="attr[@name='cn']/value"/></cn>
    <birthdate><xsl:value-of
    select="attr[@name='birthday']/value"/></birthdate>
    <morrisonserialid><xsl:value-of
    select="attr[@name='morrisonserialid']/value"/></morrisonserialid>
    <fileAs><xsl:value-of
    select="attr[@name='fileAs']/value"/></fileAs>
    <startDate><xsl:value-of
    select="attr[@name='morrisonpositionstartdate']/value"/></startDate>
    </row>
    </xsl:for-each>
    </result>
    </xsl:template>
    </xsl:stylesheet>

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

    Huh?
     
    , Feb 1, 2005
    #1
    1. Advertising

  2. Joris Gillis Guest

    Tempore 20:02:40, die Tuesday 01 February 2005 AD, hinc in foro {comp.text.xml} scripsit <>:

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

    Hi,

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

    <xsl:template match="/">
    <result>
    <xsl:for-each
    select="in:batchResponse/in:searchResponse/in:searchResultEntry">
    <xsl:sort select="in:morrisonserialid"/>
    <row>
    <cn><xsl:value-of select="in:attr[@name='cn']/in:value"/></cn>
    <birthdate><xsl:value-of
    select="in:attr[@name='birthday']/in:value"/></birthdate>
    <morrisonserialid><xsl:value-of
    select="in:attr[@name='morrisonserialid']/in:value"/></morrisonserialid>
    <fileAs><xsl:value-of
    select="in:attr[@name='fileAs']/in:value"/></fileAs>
    <startDate><xsl:value-of
    select="in:attr[@name='morrisonpositionstartdate']/in:value"/></startDate>
    </row>
    </xsl:for-each>
    </result>
    </xsl:template>

    regards,
    --
    Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
    Veni, vidi, wiki (http://www.wikipedia.org)
     
    Joris Gillis, Feb 1, 2005
    #2
    1. Advertising

  3. this is a FAQ,

    <batchResponse xmlns="urn:eek:asis:names:tc:DSML:2:0:core"

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


    <xsl:for-each
    select="batchResponse/searchResponse/searchResultEntry">

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

    add

    xmlns:D="urn:eek:asis:names:tc:DSML:2:0:core"
    to xsl:stylesheet then use

    <xsl:for-each
    select="D:batchResponse/D:searchResponse/D:searchResultEntry">

    and similarly prefix all other references to this namespace.

    David
     
    David Carlisle, Feb 1, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cram TeXeD

    DSML : who use it ?

    Cram TeXeD, Dec 1, 2003, in forum: Java
    Replies:
    1
    Views:
    501
    Darren Davison
    Dec 1, 2003
  2. Mavrick

    Sun DSML Provider for LDAP

    Mavrick, Aug 30, 2004, in forum: Java
    Replies:
    0
    Views:
    424
    Mavrick
    Aug 30, 2004
  3. Cram TeXeD

    DSML a dead specification?

    Cram TeXeD, Nov 23, 2003, in forum: XML
    Replies:
    0
    Views:
    402
    Cram TeXeD
    Nov 23, 2003
  4. Francis Cianfrocca

    LDAP and DSML

    Francis Cianfrocca, Sep 8, 2006, in forum: Ruby
    Replies:
    0
    Views:
    138
    Francis Cianfrocca
    Sep 8, 2006
  5. Gerd Schering
    Replies:
    0
    Views:
    131
    Gerd Schering
    Apr 14, 2005
Loading...

Share This Page