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

Problems trying to XSL transform a document with entities.

I was wondering if someone could help me out. I'm trying to perform an
XSL transformation on an XML document that uses entities. While I can
do XSLT on a file without entities, it all falls apart when I try and
add an entity. Here are my files...

-----TEST.XML------

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<!DOCTYPE document [
<!ENTITY externalparagraph SYSTEM "test2.xml">
]>
<document>
<paragraph>Lorem ipsum dolor.</paragraph>
<paragraph>Duis iaculis purus id augue.</paragraph>
&externalparagraph;
</document>

-------------------

-----TEST2.XML-----
<?xml version="1.0" encoding="UTF-8"?>
<paragraph>hello world!</paragraph>
-------------------
-----TEST.XSL------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8"
doctype-system="http://www.w3.org/TR/html4/loose.dtd"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" />
<xsl:template match="/">
<xsl:for-each select="//paragraph">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
-------------------

Now, this works fine when I load up text.xml in IE6, however if I load
it up in Firefox 1.0 it fails.

It also fails when I try and do my transformation usine
MSXML2.DOMDocument in ASP.

Can anyone give me some pointers as to what I'm doing wrong?
Jul 20 '05 #1
3 1405

The XML spec allows non-validating parsers to _not_ read external parts
of a DTD (for various reasons to do with history, security and
politics:-)

mozilla family browsers take up this option and don't ever read DTD
parts from another site. If the filename or public ID matches a DTD in
the $MOZILLAHOME/res cached dtd areas (which means, essentially XHTML or
XHTML+MathML then it reads the version it has locally, but it never
reads the external DTD file.

If XSLT sees an unexpanded entity in its input, it dies.
Can anyone give me some pointers as to what I'm doing wrong?


Nothing is wrong (except your expectations).

In the case of ASP I'm sure you can make it work, as MSXML does normally
read dtd files, it's probably a security issue (I don't know) In the case
of firefox, you are doomed.

David
Jul 20 '05 #2
Fortunately, browser compatibility is not a requirement as I intend to
do my XSL processing server-side. However I still can't get it working
with MSXML and ASP. The doctype gets output, but that's all. Does
anyone have any sample code that I might be able to copy.

Also, is there a better way of achieving my goal? I think perhaps XLink
may be an option.

I just want to be able to import an xml document in top another and do
an XSL transformation as if it were all one file.

For example I might have lots of XML files that need a list of
countries and their respective database codes. However I want to be
able to update those countries from time to time and only change one
XML file.

Can anyone give me any pointers on how to do this if entities are not
the way to go?

Jul 20 '05 #3

As I said msxml normally follows external dtd references so I'm
surprised it doesn't work from your asp page. Hard to tell really sounds
like a permissions problem I would guess (but ASP ain't my thing really
so I'm only guessing:-)

Otherwise it's easy enough to use xlink or xinclude or even easier roll your own:
If your main document says

<document>
<paragraph>Lorem ipsum dolor.</paragraph>
<paragraph>Duis iaculis purus id augue.</paragraph>
<foo href="other-doc.xml"/>
</document>
and your styleshet has

<xsl:template match="foo">
<xsl:apply-templates select="document(@href)"/>
</xsl:template>

then processing will move to other-doc.xml when you hit the foo element.

David
Jul 20 '05 #4

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

Similar topics

3
by: Alan Krueger | last post by:
Greetings, I've been able to cache Transformer objects in a Tomcat-based servlet application to avoid unnecessary Transformer rebuilding, except for certain ones on certain machines. I'm...
0
by: Sebastian Fey | last post by:
hi, im looking for a way to paramterize a xml document. ive a documentation in docbook-xml and want to transform it using two different sets of entities. (resulting documents just differ in...
1
by: cawoodm | last post by:
I need an identity XSLT that does not change the incoming XML document. The trick is that I need the entities to be preserved. My current transform converts   to the copyright symbol in the output...
5
by: Kevin Westhead | last post by:
I'm using XslTransform to apply a transform to an XML document, however I get validation problems when parsing the resulting XML document due to invalid whitespace. I'm passing in an XPathNavigator...
2
by: Daniel Walzenbach | last post by:
Hi I need to know how to transform a XML file by using a XSLT file. Consider the following XML file <?xml version="1.0" encoding="UTF-8" standalone="yes"?><LogFile><Dog TimeStamp="16.02.2004...
3
by: Andy | last post by:
Hi all, I'm having a problem doing an Xslt transform in code. I've done it before, so I'm not really sure why its not working. The problem is that the result of the transform is an empty...
3
by: Ali Sahin | last post by:
Hi there, I'd like to transform a XML-File to PDF. The XML-File ist build like followed: <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml-stylesheet type="text/xsl"...
1
by: Candle | last post by:
I am having a problem with writing an XSL Transform. Please help. Note: I know this a long post but I wanted to provide as must detail as possible. Any help would be appreciated. (Just started...
1
by: Candle | last post by:
I am having a problem with writing an XSL Transform. Please help. Note: I know this a long post but I wanted to provide as must detail as possible. Any help would be appreciated. (Just started...
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: 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: 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
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,...

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.