Avatar billede agentjna Nybegynder
12. november 2007 - 13:00 Der er 4 kommentarer og
1 løsning

XSLT og Cdata?

Hej

Er lidt novice ud i dette men jeg har behov for et output der ser således ud: (Bemærk at der i output skal være cdata for at den webservice jeg bruger virker.)

Håber på lidt respons.
Jesper

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <SOAP-ENV:Body>
        <m:GemIndSigelse xmlns:m="http://tempuri.org/hportal/XMLUpload">
            <m:XMLfil><![CDATA[
<a6001_v1r0m0>
    <IndkommenpostID>4</IndkommenpostID>
    <mc_ansvar>ALLE</mc_ansvar>
</a6001_v1r0m0>
                ]]></m:XMLfil>
        </m:GemIndSigelse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Mine data ser således ud:

<a6001_v1r0m0>
    <IndkommenpostID>4</IndkommenpostID>
    <mc_ansvar>ALLE</mc_ansvar>
</a6001_v1r0m0>

Og stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-16" indent="yes" cdata-section-elements="a6001_v1r0m0"/>
    <xsl:template match="/">
        <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <SOAP-ENV:Body>
                <m:GemIndSigelse xmlns:m="http://tempuri.org/hportal/XMLUpload">
                    <m:XMLfil>
                        <xsl:copy-of select="//a6001_v1r0m0"/>
                    </m:XMLfil>
                </m:GemIndSigelse>
            </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>
    </xsl:template>
</xsl:stylesheet>
Avatar billede jokkejensen Novice
14. november 2007 - 16:58 #1
Værsgo'

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <SOAP-ENV:Body>
                <m:GemIndSigelse xmlns:m="http://tempuri.org/hportal/XMLUpload">
                    <m:XMLfil>
                        <xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[]]></xsl:text>
                        <xsl:copy-of select="."></xsl:copy-of>
                        <xsl:text disable-output-escaping="yes"><![CDATA[]]]]><![CDATA[>]]></xsl:text>
                    </m:XMLfil>
                </m:GemIndSigelse>
            </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>
    </xsl:template>
</xsl:stylesheet>
Avatar billede jokkejensen Novice
14. november 2007 - 16:58 #2
Outputter :

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Body>
        <m:GemIndSigelse xmlns:m="http://tempuri.org/hportal/XMLUpload">
            <m:XMLfil><![CDATA[<a6001_v1r0m0>
                    <IndkommenpostID>4</IndkommenpostID>
                    <mc_ansvar>ALLE</mc_ansvar>
                </a6001_v1r0m0>]]></m:XMLfil>
        </m:GemIndSigelse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


På :

<a6001_v1r0m0>
    <IndkommenpostID>4</IndkommenpostID>
    <mc_ansvar>ALLE</mc_ansvar>
</a6001_v1r0m0>
Avatar billede jokkejensen Novice
14. november 2007 - 17:00 #3
Vil du ikke have <xml> deklerationen med i dit output, så smid:

omit-xml-declaration="yes"

På din <xsl:output/>
Avatar billede agentjna Nybegynder
14. november 2007 - 23:27 #4
mange tak
Avatar billede jokkejensen Novice
15. november 2007 - 08:50 #5
Selv tak !
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester