[KLUG Members] XML/DSML/XSL Transform Help

Adam Tauno Williams adam at morrison-ind.com
Wed Feb 16 14:28:50 EST 2005


> Okay, explain this.
> If the document root tag is -
> <batchResponse xmlns="urn:oasis:names:tc:DSML:2:0:core"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> then the XSLT doesn't work.
> If I strip the document root tag down to just <batchResponse>, then it
> works.  Eh?

It finally became clear to me: the xslt processor is aware of the
namespace. Duh!

One has to declare an alias for the namespace in the xslt tag and then
prefix the corresponding attributes.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:D="urn:oasis:names:tc:DSML:2:0:core">
<xsl:template match="/">
  <ditData>
    <xsl:for-each
select="D:batchResponse/D:searchResponse/D:searchResultEntry">
    <object>
     <cn><xsl:value-of select="D:attr[@name='cn']/D:value"/></cn>
     <birthdate><xsl:value-of
select="D:attr[@name='birthDate']/D:value"/></birthdate>
     <serialid><xsl:value-of
select="D:attr[@name='morrisonserialid']/D:value"/></serialid>
     <fileAs><xsl:value-of
select="D:attr[@name='fileAs']/D:value"/></fileAs>
     <startdate><xsl:value-of
select="D:attr[@name='morrisonpositionstartdate']/D:value"/></startdate>
     <employeeNumber><xsl:value-of
select="D:attr[@name='employeeNumber']/D:value"/></employeeNumber>
     <displayName><xsl:value-of
select="D:attr[@name='displayName']/D:value"/></displayName>
    </object>
   </xsl:for-each>
  </ditData>
</xsl:template>
</xsl:stylesheet>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://www.kalamazoolinux.org/pipermail/members/attachments/20050216/70ec4c8f/attachment.bin


More information about the Members mailing list