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. Advertisements

  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. Advertisements

  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. Advertisements

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. Ken Adams
    Replies:
    1
    Views:
    834
    Arnaud Berger
    Mar 10, 2005
  2. Bernd Fuhrmann
    Replies:
    0
    Views:
    557
    Bernd Fuhrmann
    Feb 12, 2004
  3. Jody Greening
    Replies:
    5
    Views:
    862
    Jody Greening
    Jan 6, 2005
  4. Jody Greening
    Replies:
    0
    Views:
    442
    Jody Greening
    Jan 6, 2005
  5. Harry George

    Codesample for xml/xslt transforming

    Harry George, Sep 9, 2003, in forum: Python
    Replies:
    8
    Views:
    628
    Axel Straschil
    Sep 10, 2003
  6. Puzzled

    Transforming xhtml with xslt

    Puzzled, May 28, 2007, in forum: XML
    Replies:
    6
    Views:
    699
    Joe Kesselman
    May 30, 2007
  7. samppi
    Replies:
    1
    Views:
    509
    Martin Honnen
    Jan 6, 2008
  8. MaggotChild
    Replies:
    1
    Views:
    209
    Martin Honnen
    May 15, 2007
Loading...