on 12-12-2008 8:47 AM
Hi everyone,
Im looking for some assistance regarding string to xml. I wanted to extract the xml from the field 'sendDataReturn'. Is my xsl script correct?
XML in String
<sendDataResponse xmlns="http://service.aes.cust.mic.at" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sendDataReturn><b><?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> <MicExportResponseMessage xmlns="http://www.mic-cust.com/Webservice/MicExportWS/v1.1"><Connection><connectionID>MICWEBSERVICE</connectionID><partnerID>SAPKLD400</partnerID><dateTime>2008-12-12T09:35:40</dateTime></Connection><Messages><Message><Envelope><messageID>1</messageID><partyID>01</partyID><schemaID>V 1.0 B01</schemaID><sequenceNum>1</sequenceNum><transActionID>970002570-01-TR-V3</transActionID></Envelope><Detail><actionCode><code>ER</code></actionCode><error><errorSource>MIC</errorSource><errorCode>106615</errorCode><errorType>ERR</errorType><errorText>Objekt ist schon in der Datenbank vorhanden</errorText></error></Detail></Message></Messages></MicExportResponseMessage></b></sendDataReturn>
</sendDataResponse>
XSL SCRIPT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://service.aes.cust.mic.at">
<xsl:template match="/">
<xsl:for-each select="//sendDataReturn">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Thanks
Hi
In order to apply an xsl your input needs to be valid xml. In your example this starts at the XML declaration
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<MicExportResponseMessage xmlns="http://www.mic-cust.com/Webservice/MicExportWS/v1.1">
<Connection>
<connectionID>MICWEBSERVICE</connectionID>
<partnerID>SAPKLD400</partnerID>
<dateTime>2008-12-12T09:35:40</dateTime>
</Connection>
<Messages>
<Message>
<Envelope>
<messageID>1</messageID>
<partyID>01</partyID>
<schemaID>V 1.0 B01</schemaID>
<sequenceNum>1</sequenceNum>
<transActionID>970002570-01-TR-V3</transActionID>
</Envelope>
<Detail>
<actionCode>
<code>ER</code>
</actionCode>
<error>
<errorSource>MIC</errorSource>
<errorCode>106615</errorCode>
<errorType>ERR</errorType>
<errorText>Objekt ist schon in der Datenbank vorhanden</errorText>
</error>
</Detail>
</Message>
</Messages>
</MicExportResponseMessage>
To Output all the inpit xml see here use the xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://service.aes.cust.mic.at">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
It looks like you are trying to extract the xml from a syschronous call response, the xsl above may bot be the entire solution but a atarting point at least to extract data, tags included .. you can eaisly test this in a xsl tool such as xml spy (there is a trial version) ..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks!
I also made it to work with this xsl
<?xml version='1.0' encoding='UTF-8' ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:m="http://service.aes.cust.mic.at">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:template match="/">
<xsl:for-each select="//m:sendDataReturn">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Hi Brian,
it is mostly right.
You just forgot the namespace (notice that in your input XML the namespace is set, it's just that it is set to the default (empty) prefix).
The XSLT would be then:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://service.aes.cust.mic.at">
<xsl:template match="/">
<xsl:for-each select="//ns0:sendDataReturn">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Regards,
Henrique.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.