473,382 Members | 1,225 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

problem with xslt transformation

Hi All,

I am New to xml. Currently I am trying to transform one xml file to
another file using xslt

my xml file is as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xml" href="test.xsl" version="2.0"?>
<Data>
<Header>
<ID>JD014</ID>
<Test>true</Test>
</Header>
</Data>

and xsl file is as follows:test.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:template match="/">
<xsl:for-each select="Header">
<xsl:value-of select="ID"></xsl:value-of>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

I m trying to print the value of ID in output . But instead of
transformation Internet explorer simply
shows input file as it is.

Please check this and let me know where i am wrong.

Thanks and Regards,
Pathik

Mar 27 '07 #1
2 2010
* Pathik wrote in comp.text.xml:
>Hi All,

I am New to xml. Currently I am trying to transform one xml file to
another file using xslt

my xml file is as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xml" href="test.xsl" version="2.0"?>
<Data>
<Header>
<ID>JD014</ID>
<Test>true</Test>
</Header>
</Data>

and xsl file is as follows:test.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:template match="/">
<xsl:for-each select="Header">
<xsl:value-of select="ID"></xsl:value-of>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

I m trying to print the value of ID in output . But instead of
transformation Internet explorer simply
shows input file as it is.
Internet Explorer does not support XSLT 2.0 and the xml-stylesheet
processing instruction does not have a version pseudo-attribute.
Further, <xsl:template match="/"matches the document node, not
the root element node, so your for-each would select no nodes as
there are no "Header" elements that are children of the document
node.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Mar 27 '07 #2
Pathik wrote:
<Data>
<Header>
<ID>JD014</ID>
<Test>true</Test>
</Header>
</Data>

and xsl file is as follows:test.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/
^^^^^^^^^^^^^
Use version="1.0" for IE or other browsers as XSLT 2.0 is too new to be
supported by browsers. While the XSLT processor will try to process the
stylesheet even for a not supported version (so called forwards
compatible processsing <http://www.w3.org/TR/xslt#forwards>) you do not
help yourself understanding normal XSLT transformation if you run
stylesheet that way.
Transform">
<xsl:template match="/">
Inside a browser you usually want to transform XML to HTML so best
practice is to include the necessary elements making up a HTML document e.g.
<html>
<head>
<title>XSLT test</title>
</head>
<body>
<xsl:for-each select="Header">
The Header element is a child of the Data element so you need
<xsl:for-each select="Data/Header>
<xsl:value-of select="ID"></xsl:value-of>
</xsl:for-each>
</body>
</html>
</xsl:template>


--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 27 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dominique Bejean | last post by:
Hello, I am having a problem doing an XSLT transformation using Java. I have a XML document as a DOM Document object, wrap the Document object with a DOMSource object, and do the...
0
by: Collin VanDyck | last post by:
Hello! I have set up a pluggable SAX transformation pipeline which is made up of individual nodes that transform the source XML, and for the most part it works well. Each node in the pipeline...
4
by: Stephen | last post by:
I have the following that outputs an xml file to a div using ajax: <script type="text/javascript"> function ajaxXML(url,control_id){ if (document.getElementById) { var x =...
5
by: shauldar | last post by:
Is there a way (tool, hack...) to create an XSL:FO from an XSLT + XML files? My motivation is that we want to use a tool to design reports, and from that "design" generate both HTML (via XSLT)...
6
by: JJBean | last post by:
Hi Oleg and All, Is this correct? Can I do this? <code> XmlDocument doc=new XmlDocument(); XPathNavigator nav = doc.CreateNavigator(); //Load the xml file. Change path if needed...
8
by: Demon News | last post by:
I'm trying to do a transform (Using XmlTransform class in c#) and in the Transform I'm specifying the the output xsl below: <xsl:output method="xml" encoding="UTF-8" indent="no"/> the...
0
by: Thomas H. | last post by:
Hello, I have a problem with security-settings in a .NET Application. The application has a strong name and is full trusted ("Trust an assembly" - Full Trust), ..NET Security is set "Local...
5
by: crazydiode | last post by:
HI All, I am new to XSLT. I am trying to use xslt with xml in my java code. I am basically trying to replace one node of the original xml with my own node. I defined the xslt as follows: ...
4
by: simon.a.hulbert | last post by:
Hi, I'm trying to view the following xslt transformation using firefox <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" > <xsl:output method = "xml" indent =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.