473,385 Members | 1,830 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,385 software developers and data experts.

Is there a way to have the style sheet included in the sqame file as the XML data

RD
My app transmits XML data file via e-mail and for now I attach both the XML
data file and the corresponding style sheet. I found however that whenthe
recipient double clicks on the XML file to read it, he/she can't open it
that way. For some reason that escapes me, the XSL fil can't be found,
although theoretically they bot are in the same folder. If user copies both
XML and XSL files to another same folder for both, then he/she can read XML
by double clicking on it and it finds its XSL OK.

Which behavioiur brings me to me question above. Is there a way to directly
embed the XSL in the XML file itself. I want to send tye data as XML to make
it easy for the recipient to devellop a method to import it in hois own
database and it needs to be as user friendly as possible when it commes to
viewing from the e-mail message, but the behaviour above makes it a bit hard
for recipient.

Any help or suggestions would be greatly appreciated.

Bob

Hope you all had a pleasant Christmas.
Nov 12 '05 #1
3 1361


RD wrote:

Is there a way to directly
embed the XSL in the XML file itself.


In theory you can do that, yes

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="#theSheet"?>
<root>
<xsl:stylesheet id="theSheet"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
</xsl:stylesheet>
</root>

though to have that work you need to include a DTD that defines the id
attribute of the xsl:stylesheet element.

Details are here:
<http://www.w3.org/TR/xslt#section-Embedding-Stylesheets>

But as far as I remember MSXML used by IE doesn't support that.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
Hello RD,

Instead of passing the XSL, why not just send the XML and also send an HTML
that is the result of applying the XSL to the XML. that way, the user does
not need to know anything about stylesheets, and the XML simply arrives as
an attachment like so many others they probably get.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"RD" <no****@nospam.net> wrote in message
news:u3*************@TK2MSFTNGP15.phx.gbl...
My app transmits XML data file via e-mail and for now I attach both the XML data file and the corresponding style sheet. I found however that whenthe
recipient double clicks on the XML file to read it, he/she can't open it
that way. For some reason that escapes me, the XSL fil can't be found,
although theoretically they bot are in the same folder. If user copies both XML and XSL files to another same folder for both, then he/she can read XML by double clicking on it and it finds its XSL OK.

Which behavioiur brings me to me question above. Is there a way to directly embed the XSL in the XML file itself. I want to send tye data as XML to make it easy for the recipient to devellop a method to import it in hois own
database and it needs to be as user friendly as possible when it commes to
viewing from the e-mail message, but the behaviour above makes it a bit hard for recipient.

Any help or suggestions would be greatly appreciated.

Bob

Hope you all had a pleasant Christmas.

Nov 12 '05 #3
I have a similar need. My users need the XML data for later import into
ACCESS or EXCEL. The need to be able to click on the attachment to see it,
and save it later.

I've gotten it to work, but have run into a formatting issue in the xsl
itself. Any input is appreciated.

Here are the original xml and xsl, which works fine.

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test2.xsl"?>
<test>
<row>
<item>test item 1 </item>
</row>
<row>
<item>test item 2 </item>
</row>
<row>
<item>test item 3 </item>
</row>
<row>
<item>test item 4 </item>
</row>
<row>
<item>test item 5 </item>
</row>
</test>

Here is the original xsl:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="kItem" match="row" use="item" />
<xsl:template match="/">
<HTML>
<HEAD>
<STYLE>
.HEADER { background-color:lightblue;font-weight:bold }
.ITEMROW { background-color:beige;font-weight:bold }
</STYLE>
</HEAD>
<BODY>
<TABLE>
<COLGROUP WIDTH="200" ALIGN="LEFT" />
<TR>
<TD CLASS="HEADER">Item</TD>
</TR>
<xsl:for-each
select="test/row[generate-id()=generate-id(key('kItem',item))]">
<COLGROUP WIDTH="200" ALIGN="LEFT" />
<TR>
<TD CLASS="ITEMROW">
<xsl:value-of select="item" />
</TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
The above all works fine. When I combine the XML and XSL into a single file,
apparently the xsl:for-each does not work.

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="#stylesheet"?>
<!DOCTYPE doc [
<!ATTLIST xsl:stylesheet
id ID #REQUIRED>
]>
<doc>
<xsl:stylesheet id="stylesheet" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="kItem" match="test/row" use="item" />
<xsl:template match="xsl:stylesheet" />
<HTML>
<HEAD>
<STYLE>
.HEADER { background-color:lightblue;font-weight:bold }
.ITEMROW { background-color:beige;font-weight:bold }
</STYLE>
</HEAD>
<BODY>
<TABLE>
<COLGROUP WIDTH="200" ALIGN="LEFT" />
<TR>
<TD CLASS="HEADER">Item</TD>
</TR>
<xsl:for-each
select="test/row[generate-id()=generate-id(key('kItem',item))]">
<COLGROUP WIDTH="200" ALIGN="LEFT" />
<TR>
<TD CLASS="ITEMROW" >
<xsl:value-of select="item" />
</TD>
</TR>
</xsl:for-each>
</TABLE>
</BODY>
</HTML>
</xsl:stylesheet>
<test>
<row>
<item>test item 1 </item>
</row>
<row>
<item>test item 2 </item>
</row>
<row>
<item>test item 3 </item>
</row>
<row>
<item>test item 4 </item>
</row>
<row>
<item>test item 5 </item>
</row>
</test>
</doc>

Thanks in advance to all the gurus out there.
Nov 12 '05 #4

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

Similar topics

2
by: Mark | last post by:
Hi - I want to allow users of an intranet application, to select their own colours etc. So I have a tbale in my database, which has fields called bgcolour, fontcolour etc. As I want all pages...
19
by: Roger | last post by:
How can I pass parameters to a style sheet? I have noticed a couple of sites are now passing variables to the style sheet, which appear to be substituted at run time. For example: <link...
3
by: joealey2003 | last post by:
Hi all... I included a css file on my html and i need to check some properties. The html is: <style id="myid" src="mycsspage.css"> </style> Now i need something to access it like: ...
2
by: Wade Beasley | last post by:
I have a web site I am working on for a client using ASP.NET with VB.Net for the language. The client decided they needed the ability to choose between different page layouts based on a setting in...
2
by: Matthew McDermott | last post by:
Hi, I am working on "reskinning" an application that uses style sheets. I have been editing the default stylesheets by adding my alterations to the bottom of the .css files. I was wondering...
1
by: Amanda H. | last post by:
I posted about this a few days ago, and I got a few suggestions that fixed part of my problem. I am using a PHP script to switch external style sheets when the viewer clicks on the style link. ...
8
by: pamelafluente | last post by:
Hi guys, Is it possible to add "onload" (via Javascript) a new class to the <styleheader section? If yes, how would that be done ? <style type="text/css" media="screen"> .NewStyleClass{...
1
by: Looch | last post by:
Hi All, I have a need for a user to open an XML file from a web site and have it open based on a style sheet, not just looking at the raw XML data. I'm wondering what the best way to go about...
5
by: Gretsch | last post by:
After lots of problems trying to allow the visitor to switch styles using Javascript - but encountering browser incompatabilities!! I decided to use PHP and found a simple way of doing it here: ...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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?
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...

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.