Problems trying to XSL transform a document with entities.

Discussion in 'XML' started by annoyed tuna, Apr 20, 2005.

  1. annoyed tuna

    annoyed tuna Guest

    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...


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


    <?xml version="1.0" encoding="UTF-8"?>
    <paragraph>hello world!</paragraph>

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    <xsl:eek:utput method="html" encoding="utf-8"
    doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" />
    <xsl:template match="/">
    <xsl:for-each select="//paragraph">
    <xsl:value-of select="."/>

    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?
    annoyed tuna, Apr 20, 2005
    1. Advertisements

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

    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 Carlisle, Apr 20, 2005
    1. Advertisements

  3. Guest

    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?
    , Apr 20, 2005
  4. 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

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

    and your styleshet has

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

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

    David Carlisle, Apr 20, 2005
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Barry Anderberg
    Chris Barber
    Apr 8, 2004
  2. Angus Parvis
    Angus Parvis
    Aug 26, 2004
  3. Barry Anderberg
    Chris Barber
    Apr 8, 2004
  4. Wizfrog
    Joe Kesselman
    Jul 24, 2007
  5. Jim Higson
    Eric Amick
    Jul 25, 2004

Share This Page