homepage Welcome to WebmasterWorld Guest from 54.145.183.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Help on xsl
gavinokane



 
Msg#: 4329788 posted 6:56 am on Jun 23, 2011 (gmt 0)

I have an xml string :

<?xml version="1.0" encoding="UTF-8"?>
<ns0:Envelope xmlns:ns0="http://www.w3.org/2003/05/soap-envelope">
<ns0:Header>
<ns1:applicationHeader
xmlns:ns1="http://www.funnyoldgame.com/afs/icc/common/iccHeader-v1.0">
<transaction>
<name />
<uniqueId />
<sequenceNumber />
</transaction>
<sender>
<applicationName>Teamworks</applicationName>
</sender>
</ns1:applicationHeader>
</ns0:Header>
<ns0:Body>
<ns1:faults xmlns:ns1="http://www.funnyoldgame.com/afs/icc/common/iccFaults-v1.0">
<fault>
<code>BW-XML-100013</code>
<descriptionForTechnician>Im</descriptionForTechnician>
<descriptionForUser>A validation </descriptionForUser>
<sourceMsg>asdf</sourceMsg>
</fault>
</ns1:faults>
</ns0:Body>
</ns0:Envelope>

and an xsl as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version = "1.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
xmlns:fo = "http://www.w3.org/1999/XSL/Format"
xmlns:icc = "http://www.funnyoldgame.com/afs/icc/common/iccFaults-0.1-20080620"
xmlns:icc_v1.0 = "http://www.funnyoldgame.com/afs/icc/common/iccFaults-v1.0"
xmlns:SOAP-ENV-1.1 = "http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENV-1.2 = "http://www.w3.org/2003/05/soap-envelope"
exclude-result-prefixes = "icc fo SOAP-ENV-1.1 SOAP-ENV-1.2">
<xsl:variable name = "prePilotNamespace" select = "'http://www.funnyoldgame.com/afs/icc/common/iccFaults-0.1-20080620'"/>
<xsl:variable name = "postPilotNamespace" select = "'http://www.funnyoldgame.com/afs/icc/common/iccFaults-v1.0'"/>
<xsl:output
method = "xml"
encoding = "UTF-8"
indent = "yes"/>
<xsl:template match = "/">
<xsl:apply-templates select = "//SOAP-ENV-1.1:Fault"/>
<xsl:apply-templates select = "//SOAP-ENV-1.2:Fault"/>
</xsl:template>
<!--SOAP 1.1 -->
<xsl:template match = "SOAP-ENV-1.1:Fault">
<variable type = "Fault">
<reason>
<xsl:value-of select = "faultstring"/>
</reason>
<xsl:apply-templates select = "detail/icc:faults"/>
<xsl:apply-templates select = "detail/icc_v1.0:faults"/>
</variable>
</xsl:template>

<!--SOAP 1.1 pre pilot fault transform-->
<xsl:template match="detail/icc:faults">
<errorsSummarisedForUser>
<xsl:for-each select = "icc:fault">
<xsl:text>&#10;</xsl:text>
<xsl:value-of select = "icc:descriptionForUser"/>
</xsl:for-each>
</errorsSummarisedForUser>
<faults>
<xsl:for-each select = "icc:fault">
<item>
<code>
<xsl:value-of select = "icc:code"/>
</code>
<descriptionForTechnician>
<xsl:value-of select = "icc:descriptionForTechnician"/>
</descriptionForTechnician>
<descriptionForUser>
<xsl:value-of select = "icc:descriptionForUser"/>
</descriptionForUser>
</item>
</xsl:for-each>
</faults>
</xsl:template>

<!--SOAP 1.1 post pilot fault transform -->
<xsl:template match="detail/icc_v1.0:faults">
<errorsSummarisedForUser>
<xsl:for-each select = "fault">
<xsl:text>&#10;</xsl:text>
<xsl:value-of select = "descriptionForUser"/>
</xsl:for-each>
</errorsSummarisedForUser>
<faults>
<xsl:for-each select = "fault">
<item>
<code>
<xsl:value-of select = "code"/>
</code>
<descriptionForTechnician>
<xsl:value-of select = "descriptionForTechnician"/>
</descriptionForTechnician>
<descriptionForUser>
<xsl:value-of select = "descriptionForUser"/>
</descriptionForUser>
</item>
</xsl:for-each>
</faults>
</xsl:template>

<!--SOAP 1.2 -->
<xsl:template match = "SOAP-ENV-1.2:Fault">
<variable type = "Fault">
<reason>
<xsl:value-of select = "SOAP-ENV-1.2:Reason/SOAP-ENV-1.2:Text"/>
</reason>
<errorsSummarisedForUser>
<xsl:for-each select = "SOAP-ENV-1.2:Detail/icc:faults/icc:fault">
<xsl:text>&#10;</xsl:text>
<xsl:value-of select = "icc:descriptionForUser"/>
</xsl:for-each>
</errorsSummarisedForUser>
<faults>
<xsl:for-each select = "SOAP-ENV-1.2:Detail/icc:faults/icc:fault">
<item>
<code>
<xsl:value-of select = "icc:code"/>
</code>
<descriptionForTechnician>
<xsl:value-of select = "icc:descriptionForTechnician"/>
</descriptionForTechnician>
<descriptionForUser>
<xsl:value-of select = "icc:descriptionForUser"/>
</descriptionForUser>
</item>
</xsl:for-each>
</faults>
</variable>
</xsl:template>
</xsl:stylesheet>


but I'm unable to get the transformation working. It's been a few years since I done any xsl work so it's not coming back to me as quickly as I need to get this done.

Thanks in advance for any help.

Gavin

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved