473,405 Members | 2,349 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,405 software developers and data experts.

Display an existing XML in browser as readable without modifying it.

rk
I have the following library.xml file coming from a system, this can't
be modified.
__________________________________________________ __________________________
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<library>
<book>
<name>
Discover America
</name>
</book>
</library>
__________________________________________________ __________________________
I need to be able to display the above file in browser in readable
format. Here is the library.xsl.
__________________________________________________ __________________________
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tns="http://www.ibm.com/websphere/crossworlds/2002/HierarchicalProperties"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<html>
<head>
</head>
<body>
<table border="3" bgcolor="white" cellspacing="1" cellpadding="1">
<tr>
<th>Book</th>
</tr>
<xsl:for-each select="library/book">
<td>
<xsl:value-of select="name"/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet
__________________________________________________ __________________________

How can I present library.xml in readable format in browser without
modifying the xml file itself?

I have come across two options, which don't work.

1) Add <?xml-stylesheet to refer library.xsl in library.xml. This
doesn't work because I don't want to modify library.xml

2) Create a new file libary_read.xml with the following content and
open it in browser.

<!DOCTYPE apage [
<!ENTITY library SYSTEM "library.xml">
]>
<readlibrary>
&library;
</readlibrary>

And modify library.xsl to have <xsl:for-each
select="readlibary/library/book">
When I open this file in InternetExplorer, I get the following error.
__________________________________________________ ______________________
The standalone attribute cannot be used in external entities. Error
processing resource 'file:///C:/Documents and Settings/...

<?xml version="1.0" encoding="utf-8" standalone="no"?>
__________________________________________________ ______________________

I think having standalone="no" in library.xml is forcing me out of this
option. If I remove standalone="no" it works. Since I can't modify
library.xml, this option also gets ruled out.

Regards,
Rajesh Kamisetty

Jun 14 '06 #1
2 1786
> How can I present library.xml in readable format in browser without
modifying the xml file itself?


Rajesh,

You could create a new xml file called temp.xml with the following
content
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="library.xsl"?>
<root/>

The above file is just a dummy file, its main purpose being to load the
books.xsl.

Let us suppose that books.xml is the original xml file that you cannot
change.

Change library.xsl to the following stylesheet

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tns="http://www.ibm.com/websphere/crossworlds/2002/HierarchicalProperties"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:template match="/">
<xsl:apply-templates select="document('books.xml')/library" />
</xsl:template>

<xsl:template match="library">
<html>
<head>
</head>
<body>
<table border="3" bgcolor="white" cellspacing="1" cellpadding="1">
<tr>
<th>Book</th>
</tr>
<tr>
<xsl:for-each select="./book">
<td>
<xsl:value-of select="name"/>
</td>
</xsl:for-each>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

So, you will have three files

1)temp.xml - The dummy file to load the stylesheet.
2)books.xml - The original file you cannot change
3)library.xsl - The stylesheet that displays the table

Opening temp.xml in a browser will give you the required output.

-Dhanvanth

Jun 14 '06 #2
dh*******@gmail.com wrote:
Opening temp.xml in a browser will give you the required output.


Note that this end-run shouldn't be necessary -- browsers *SHOULD* let
the user mix source document and stylesheet arbitrarily to suit their
own needs -- but unfortunately browser authors haven't caught up with
this improved architecture yet.

Pester whoever wrote yours, telling them you want this feature.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jun 14 '06 #3

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

Similar topics

10
by: minchu | last post by:
Hello, I have used CSS in HTML page (font-verdana size-8pt), looks fine in windows but in linux the fonts are corrupt and its too small. Kindly help me and tell what is the solution to correct...
115
by: J | last post by:
I've run CSSCheck on my style sheets and I always get a warning similar to this: "font: bold 9pt/100% sans-serif Warning: Absolute length units should not generally be used on the Web ..." ...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
14
by: Gérard Talbot | last post by:
I personally disagree with the Viewable in Any browser campain. The site is frankly outdated, seems to be no longer maitained, has several recommendations that don't make a lot of sense anymore. In...
9
by: Maxi | last post by:
There is a very good javascript available at the following link that displays image and text wherever mouse follows a link. http://www.dynamicdrive.com/dynamicindex4/imagetooltip.htm I have a...
49
by: SamFeltus | last post by:
I am trying to figure out why so little web development in Python uses Flash as a display technology. It seems most Python applications choose HTML/CSS/JS as the display technology, yet Flash is a...
2
by: Nalin Gupta | last post by:
Hello, I am newbie to web programming, though a did bit 10 years back. I have to do this for embedded device, which is running some simple minimal web server as of now. On browser, I need to...
14
by: rolfejr | last post by:
I am trying to display a PDF in the users browser that is pulled from a binary field in our database, and keep that PDF from caching on the client computer. I can successfully pull the PDF and...
14
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.