473,769 Members | 7,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 externalparagra ph SYSTEM "test2.xml" >
]>
<document>
<paragraph>Lore m ipsum dolor.</paragraph>
<paragraph>Du is iaculis purus id augue.</paragraph>
&externalparagr aph;
</document>

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

-----TEST2.XML-----
<?xml version="1.0" encoding="UTF-8"?>
<paragraph>hell o world!</paragraph>
-------------------
-----TEST.XSL------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et 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.DOMDocum ent in ASP.

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

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>Lore m ipsum dolor.</paragraph>
<paragraph>Du is iaculis purus id augue.</paragraph>
<foo href="other-doc.xml"/>
</document>
and your styleshet has

<xsl:template match="foo">
<xsl:apply-templates select="documen t(@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
3180
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 running Tomcat 4.1.27 under Eclipse 2.1.0 using the Sysdeo Tomcat plugin using j2re1.4.1_02 under Windows 2000 SP4. I've digested this down to a small (albeit convoluted) sample that exhibits the behavior reliably on my development workstation.
0
1104
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 some productcodes and names) i think this could be done using xml-catalogs (right?) but unforunately im using IE for a quick preview and it cant handle catalogs.
1
1167
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 document. ---------------------- TEST.XML <?xml version="1.0" encoding="windows-1252"?> <component> <content> <small>© Copyright</small>
5
1845
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 for the input to the Transform method and specifying a Stream for the output. Here is an example of a transform and a document (it's the IconStyle sections that are causing problems): <?xml version="1.0" encoding="UTF-16"?> <!-- Copyright...
2
1980
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 10:04:48" ModifiedBy="Smith, Geoff"><NameOfDog>Fido</NameOfDog><Weight>10</Weight></Dog><Dog TimeStamp="16.02.2004 10:05:24" ModifiedBy="Scott, Al"><Color>Black</Color><Weight>12</Weight></Dog></LogFile By the magic of some XSLT file I want the...
3
2134
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 string. I expected the xml to be transformed into a plain text document. Everything works fine when i transform using XmlPad. Here's the code (which does generate the Xml properly): Sample XML:
3
2400
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" href="D:\app\jboss-3.2.5\server\default\deploy\xifs.war\WEB-INF\classes\de\xifs\resource\xml\de\xifs\resource\xml\dunningaccountreport_de.xsl"?> <!DOCTYPE entities >
1
1385
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 writing my first transform yesterday and no one at my company knows this stuff.) Assume I have the following XML: <P C="P" O="1" > <E C="P_E1" O="1" W='True'>
1
1525
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 writing my first transform yesterday and no one at my company knows this stuff.) Assume I have the following XML: <P C="P" O="1" > <E C="P_E1" O="1" W='True'>
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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
10216
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
10049
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...
0
9865
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
8873
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
5310
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...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.