Stumped Transforming DSML Data With XSLT`

A

awilliam

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?
 
J

Joris Gillis

Tempore 20:02:40 said:
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,
 
D

David Carlisle

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top