473,770 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:tns="http ://www.ibm.com/websphere/crossworlds/2002/HierarchicalPro perties"
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.xm l">
]>
<readlibrary>
&library;
</readlibrary>

And modify library.xsl to have <xsl:for-each
select="readlib ary/library/book">
When I open this file in InternetExplore r, 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 1816
> 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.x sl"?>
<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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:tns="http ://www.ibm.com/websphere/crossworlds/2002/HierarchicalPro perties"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:template match="/">
<xsl:apply-templates select="documen t('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
2806
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 this. www.teledna.com Regards, Minchu
115
7241
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 ..." Yet if I use 'x-small' instead of 9pt, I get bigger type on IE6 and smaller type on Mozilla. My choices seem to be:
19
6932
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 JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the page....Take a look at the JavaScript code and please let me know what each line is doing....I have been...
14
2359
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 my mind, it is much more important to code according to standards (valid markup and CSS code) and good coding practices (tableless design, graceful degradation, etc.) than to code according to the lower common denominator among browsers. ...
9
6258
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 question and not sure who to ask. I used this script and it is working fine. I changed those two images and put my own. Image1 is of 600 width and 340 height and Image2 is of 560 width and 794 height.
49
3276
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 far more powerful and elegant display technology. On the other hand, HTML/JS seems clunky and antiquated. I am a gardener, and not a coder by trade, but Flash seems to integrate just fine with Python. Anyways, what are the technical reasons...
2
3941
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 display (say) a simple graph, with X-axis and Y-axis. Say throughput or CPU Performance extra. (refresh it at run time) How to do this whole thing ?
14
11901
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 display it using the following code: Response.ContentType = "application/pdf" Response.BinaryWrite objRS("Attachment") where objRS("Attachment") is a reference to the binary field retrieved from the database. However, I have tried adding...
14
23170
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, we're looking for a way to display the page with a "please wait..." message while the process is running, and then, when the process is done, update the page with the actual results/page content. We have a page that opens another browser/page...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10102
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9910
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.