dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Help on xsl

  1. #1
    Join Date
    Jun 2011
    Posts
    2

    Help on xsl

    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'"/>
    <xslutput
    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>
    </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>
    </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.2etail/icc:faults/icc:fault">
    <xsl:text>
    </xsl:text>
    <xsl:value-of select = "icc:descriptionForUser"/>
    </xsl:for-each>
    </errorsSummarisedForUser>
    <faults>
    <xsl:for-each select = "SOAP-ENV-1.2etail/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

  2. #2
    Join Date
    Jun 2011
    Posts
    2
    It's ok, please ignore this question. It seems that the xml source file has been formatted incorrectly.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles