cancel
Showing results for 
Search instead for 
Did you mean: 

Removing specific XML tag in XSLT mapping

Former Member
0 Kudos

Hi there,

I've asked before about a XML to string XSLT mapping and the answers provided here helped me to successfully do that mapping! Thanks a lot!

I'm using the following mapping to convert a string back to XML.

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:m="http://my.namespace.com">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>

<xsl:template match="/">

<xsl:for-each select="//m:my_tag">

<xsl:value-of select="." disable-output-escaping="yes"/>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

But now, I'm having a problem converting back from string to XML. The response tag "m:mytag" has a string like this:

"<?xml version="1.0" encoding="UTF-8"?><tag1><tag2>Data</tag2></tag1>".

And when I use the XSLT mapping shown above, the output file comes like this:

<?xml version="1.0" encoding="UTF-8"?>

<?xml version="1.0" encoding="UTF-8"?>

<tag1>

<tag2>Data</tag2>

</tag1>

As you can see, the initial <?xml ...> tag is duplicated, and it generates a parsing error in XI.

How can I eliminate one of the "<?xml version="1.0" encoding="UTF-8"?>" strings in the mapping?

Thanks a lot.

Accepted Solutions (1)

Accepted Solutions (1)

MichalKrawczyk
Active Contributor
0 Kudos

hi,

try using:

<xsl:output method="html"/>

BTw

you can also try deleting the xml tag from your xslt

program but try html method too

Regards,

michal

Message was edited by: Michal Krawczyk

henrique_pinto
Active Contributor
0 Kudos

Wow!!!

The output="html" actually worked on XML Spy!

Removing the XSLT file initial tag didn't work.

I had already resolved this problem using the replace-string method that I found here: http://aspn.activestate.com/ASPN/Cookbook/XSLT/Recipe/65426

But your method is way more elegant and efficient. 🐵

I'll test the html method on XI, but I'm almost sure it'll work too.

MichalKrawczyk
Active Contributor
0 Kudos

hi,

I hope it will work too:)

Regards,

michal

henrique_pinto
Active Contributor
0 Kudos

It worked on XI, too.

MichalKrawczyk
Active Contributor
0 Kudos

hi,

hehe you had any dobuts? )

glad it works

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

Answers (0)