Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Stumped Transforming DSML Data With XSLT`

Reply
Thread Tools

Stumped Transforming DSML Data With XSLT`

 
 
awilliam@whitemice.org
Guest
Posts: n/a
 
      02-01-2005
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="urnasis:names:tcSML:2:0:core"
xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlnssi="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"
xmlnssl="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?

 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      02-01-2005
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 xmlnssl="http://www.w3.org/1999/XSL/Transform" version="1.0" exclude-result-prefixes="in" xmlns:in="urnasis:names:tcSML: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-v...i?userid=38041)
Veni, vidi, wiki (http://www.wikipedia.org)
 
Reply With Quote
 
 
 
 
David Carlisle
Guest
Posts: n/a
 
      02-01-2005

this is a FAQ,

<batchResponse xmlns="urnasis:names:tcSML: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="urnasis:names:tcSML: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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LDAP and DSML Francis Cianfrocca Ruby 0 09-08-2006 06:47 PM
Problem with Net::LDAP::DSML or XML::SAX::Writer Gerd Schering Perl Misc 0 04-14-2005 09:52 AM
Sun DSML Provider for LDAP Mavrick Java 0 08-30-2004 02:13 PM
DSML : who use it ? Cram TeXeD Java 1 12-01-2003 08:03 PM
DSML a dead specification? Cram TeXeD XML 0 11-23-2003 09:43 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57