0

I have written XSLT and tested online.

I have tested it on following website: http://www.freeformatter.com/xsl-transformer.html

It is working perfectly and i am getting output as an XML

I tested it again at W3Schools, but it is not transforming to XML but just giving tag contents of first XML only, and same issue i am getting in my MULE code.

http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog

Following is XML:

<Data><DServ><service><SID>A-9000</SID><SITID>A-9000-01-0500</SITID><Parameters><Parameter><name>A</name><params><param><name>B</name><value>false</value></param><param><name>C</name><value>true</value></param><param><name>D</name><value>true</value></param><param><name>E</name><value>localhost</value></param></params></Parameter></Parameters></service></DServ></Data>

Following is XSLT CODE :

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="utf-8" indent="no"/><xsl:template match="/"><execution-context xmlns="http://www.jhere.com/vco"><parameters><parameter name="name" type="string"><string><xsl:value-of select="Data/DServ/service/Parameters/Parameter/name" /></string></parameter> <xsl:for-each select="Data/DServ/service/Parameters/Parameter/params/param"><xsl:variable name="man"><xsl:value-of select="name" /></xsl:variable><xsl:if test="contains($man,'B')"> <parameter name="B" type="boolean"><boolean><xsl:value-of select="value" /></boolean></parameter></xsl:if></xsl:for-each><xsl:for-each select="Data/DServ/service/Parameters/Parameter/params/param"><xsl:variable name="man"><xsl:value-of select="name" /></xsl:variable><xsl:if test="contains($man,'C')"><parameter name="C" type="boolean"> <boolean><xsl:value-of select="value" /></boolean></parameter></xsl:if></xsl:for-each><xsl:for-each select="Data/DServ/service/Parameters/Parameter/params/param"><xsl:variable name="man"><xsl:value-of select="name" /></xsl:variable><xsl:if test="contains($man,'D')"><parameter name="D" type="boolean"><boolean><xsl:value-of select="value" /></boolean></parameter></xsl:if></xsl:for-each></parameters></execution-context></xsl:template></xsl:stylesheet> `

WRONG OUTPUT:

Afalsetruetrue

It is just giving value but not XML tags? Could anyone find out reason why?

In some websites it is perfectly giving XML outputs with tags and data.

1 Answer 1

1

Your XSLT is fine and produces the correct output. The problem is that if you try to show the result in a browser, it will not display the tags and will just show the text content. That's exactly what's happening when you try it on w3schools.com:

XSLT Result

The w3schools tester is designed to show the result of the XSLT as HTML, so even though it is transforming correctly (as shown in FireBug in my screenshot), only the text content gets rendered in the page.

Sign up to request clarification or add additional context in comments.

2 Comments

Ok. Thanks for information. It looks like - freeformatter.com/xsl-transformer.html -, which is showing perfectly fine, so they are generating a string server side? and what about Java Console or Mule console (i.e Eclipse IDE Console), why they are not showing whole XML? are also designed to do the same or any way out?
The FreeFormatter tool is designed to display the resulting markup as markup rather than show it rendered in the browser, so that is why you are able to see the resulting XML. It has nothing to do with server vs. client side but rather with what the tool is designed to do. I'm not familiar with how to show XSLT output in a Java or Mule console. How are you carrying that out?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.