473,372 Members | 894 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,372 software developers and data experts.

how to display xslt output in web browser

16
here is the xml code

Expand|Select|Wrap|Line Numbers
  1. <?xml-stylesheet href="example2.xsl" type="text/xsl" ?>
  2.  
  3. <?xml version="1.0" ?>
  4.  
  5. <persons>
  6.   <person username="JS1">
  7.     <name>John</name>
  8.     <family-name>Smith</family-name>
  9.   </person>
  10.   <person username="MI1">
  11.     <name>Morka</name>
  12.     <family-name>Ismincius</family-name>
  13.   </person>
  14. </persons>
xsl code

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  3.   <xsl:output method="xml" indent="yes"/> 
  4.  
  5.   <xsl:template match="/persons">
  6.     <root>
  7.       <xsl:apply-templates select="person"/> 
  8.     </root>
  9.   </xsl:template>
  10.  
  11.   <xsl:template match="person">
  12.     <name username="{@username}">
  13.       <xsl:value-of select="name" />
  14.     </name>
  15.   </xsl:template>
  16.  
  17. </xsl:stylesheet>

output required


Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <root>
  3.   <name username="JS1">John</name>
  4.   <name username="MI1">Morka</name>
  5. </root>
Feb 13 '10 #1
8 6308
Dormilich
8,658 Expert Mod 8TB
what’s the problem? as far as my browser tells me, the output is the desired one.
Feb 13 '10 #2
sisu
16
only text is displayed in my browser no xml tags as mentioned in output field

that is 'JohnMorka'
Feb 13 '10 #3
Dormilich
8,658 Expert Mod 8TB
did you have a look at the generated* source code?

PS. you use Internet Explorer?

* - may require plugins/add-ons/extensions
Feb 13 '10 #4
drhowarddrfine
7,435 Expert 4TB
The xml declaration in your xml file is in the wrong place. Move line 3 to line 1.

Do I understand correctly that you want to display the element tags in the browser along with the text? The browser will not do this unless that data is supplied as CDATA. I believe that's possible to implement in the xslt file but I've not done that.
Feb 13 '10 #5
sisu
16
I am getting the output in xsl-easy editor but while trying to run in browser only text is displayed no xml tags with it
Feb 14 '10 #6
Dormilich
8,658 Expert Mod 8TB
it’s exactly how doc said, a browser normally doesn’t show the tags (even if they are there).
Feb 14 '10 #7
sisu
16
i am greatfull for your kind information

thank you
Feb 14 '10 #8
sisu
16
i have attached a style sheet to it but style sheet not taken by rss in browser ,but in editor it takes why?

rssfeed source code


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

<?xsl-stylesheet href="xsltest.xsl" type="text/xsl"?>

<rss version="2.0">

<channel>

<title>wholesale</title>

<link>http://localhost/fusionchart/rssfeed1.aspx</link>

<description>The latest whole sale report</description>

<copyright>Copyright 2001 - 2009 Roxy Palace Casino</copyright>

<language>en-us</language>
<guid>http://localhost/fusionchart/rssfeed12.aspx</guid>
<url>http://localhost/fusionchart/rssfeed12.aspx</url>
<title>wholesale</title>
<link>http://localhost/fusionchart/rssfeed12.aspx</link>
<description>This shows up in title of link</description>
<item>
<title>XTPNR : 122.0000</title>
<description>122.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XTPR0 : 1011.0000</title>
<description>1011.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XTPNR1 : 85.0000</title>
<description>85.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XXABK5 : 45.0000</title>
<description>45.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XXABK6 : 86.0000</title>
<description>86.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XXABK2 : 5.0000</title>
<description>5.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XXABK20 : 56.0000</title>
<description>56.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XXABK4 : 56.0000</title>
<description>56.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XTPNR7 : 78.0000</title>
<description>78.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XTPNR8 : 3.0000</title>
<description>3.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XTPNR9 : 56.0000</title>
<description>56.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XTPNR2 : 78.0000</title>
<description>78.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XTPNR3 : 28.0000</title>
<description>28.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XTPNR4 : 78.0000</title>
<description>78.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XTPNR5 : 66.0000</title>
<description>66.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XTPNR6 : 98.0000</title>
<description>98.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XXABK3 : 87.0000</title>
<description>87.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XXABK7 : 56.0000</title>
<description>56.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XXABK8 : 567.0000</title>
<description>567.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
<item>
<title>XXABK9 : 455.0000</title>
<description>455.0000</description>
<link>http://192.168.0.131/fusionchart/Default.aspx</link>
</item>
</channel>
</rss>

xsl code

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

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output method="xml" indent="yes" />

<xsl:template match="/">

<channel>
<title>


<xsl:copy select="title">

</xsl:copy>

</title>

<xsl:apply-templates select="item"/>


</root>

</xsl:template>


<xsl:template match="item">

<xsl:for-each select="title">

<title>
<xsl:copy select="title"/>

</title>

</xsl:for-each>

<xsl:for-each select="description">

<description>
<xsl:copy select="description"/>

</description>

</xsl:for-each>


</xsl:template>


</xsl:stylesheet>


output reqiured

<channel>



<title>wholesale</title>

<description>The latest whole sale report</description>






<item>


<title>XTPNR </title>

<description>122.0000</description>

</item>


<item>

<title>XTPNR0 </title>

<description>1011.0000</description>

</item>


<item>

<title>XTPNR1</title>

<description>85.0000</description>

</item>


<item>

<title>XTPNR1</title>

<description>85.0000</description>

</item>


<item>

<title>XXABK5</title>

<description>45.0000</description>


</item>


<item>

<title>XXABK6</title>

<description>86.0000</description>

</item>


<item>


<title>XXABK2 </title>

<description>5.0000</description>


</item>

<item>


<title>XXABK20 </title>

<description>56.0000</description>


</item>

<item>


<title>XXABK4 </title>

<description>56.0000</description>


</item>


<item>

<title>XTPNR7 </title>

<description>78.0000</description>

</item>

<item>





<title>XTPNR8 </title>

<description>3.0000</description>


</item>


<item>

<title>XTPNR9 </title>

<description>56.0000</description>

</item>


<item>

<title>XTPNR2 </title>

<description>78.0000</description>

</item>

<item>


<title>XTPNR3 </title>

<description> 28.0000</description>

</item>


<item>

<title>XTPNR4 </title>

<description> 78.0000</description>

</item>



<item>

<title>XTPNR5 </title>

<description> 66.0000</description>

</item>




<item>

<title>XTPNR6 </title>

<description> 98.0000</description>

</item>


<item>

<title>XXABK3 </title>

<description> 87.0000</description>

</item>


<item>

<title>XXABK7 </title>

<description>56.0000</description>

</item>


<item>

<title>XXABK8</title>

<description>567.0000</description>

</item>


<item>

<title>XXABK9</title>

<description>455.0000</description>

</item>



</channel>
Feb 14 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jesper Moth | last post by:
The MSXML4 xslt-parser would output any source <div/> like this: <div></div> I never figured out how to disable this behaviour. But since it makes the source document look cleaner, and since...
1
by: Wolfgang | last post by:
XSLT transformations by default seem to pass name space attributes into the root element of their output (example below). QUESTION: Is it possible to control this, i.e. not genrating a name...
2
by: Lionel Fourquaux | last post by:
In .Net 1.1, System.Xml.Xsl.XslTransform cannot output directly a document in an encoding that cannot represent all the characters used (e.g. write in us-ascii for compatibility, and convert all...
7
by: mjarends | last post by:
I'm using JAXP for XSLT - I'm using the examples from http://www.w3.org/TR/xslt#section-Examples. I'm using the following XML file: <?xml version="1.0" encoding="UTF-8"?> <sales> <division...
1
by: Peran | last post by:
If I create a simple xslt stylesheet I can quickly test this in VS2005 by pressing the "Show XSLT Output" button rather than running the whole solution. If I then create a xslt stylesheet with...
18
by: Terry Holland | last post by:
I have an asp.net (1.1) application that connects to a SQL server 2000 db. I have a stored procedure in my db that out puts data in xml format. What I need to be able to do is display that xml...
2
by: Tuna Fly | last post by:
I'm trying to work with XML/XSLT in the Visual Studio IDE (VS 2005) and when I select the menu option XML/Show XSLT Output I get a tab with the output showing the text HTML code. I'd like to have...
2
by: trash.muell | last post by:
Hi, I am struggling with an XSLT task and need a hint: I have a complex XML file but want to only output some sub-trees of the XML structure. My XSLT script is always printing the information of...
6
by: ronburk | last post by:
Is there any standard way to control the end-of-line convention (LF versus CR/LF) for XSLT processor output? The obvious logical point to control this would be in xsl:output. However, Kay says...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.