Professional Web Applications Themes

external entity references in XML - Coldfusion - Advanced Techniques

I can't seem to figure out how to use relative external references in my xml files I have three files test.cfm, test.xml, and test2.xml all in the same directory. test.xml delares an external entity reference like the following <!ENTITY test SYSTEM "test2.xml"> I call XmlP(expandpath('test.xml')) from test.cfm which should open the xml file. For some reason I can't declare the entity that way. CFDump just returns "[unknown type]". It does work correctly if I delare the reference as follows ../../../path/to/file/test2.xml http://localhost/test2.xml c:\path\to\file\test2.xml The problem is that I don't want to have to reference that "path/to/file" because that will change once ...

  1. #1

    Default external entity references in XML

    I can't seem to figure out how to use relative external references in my xml
    files

    I have three files test.cfm, test.xml, and test2.xml all in the same directory.

    test.xml delares an external entity reference like the following

    <!ENTITY test SYSTEM "test2.xml">

    I call XmlP(expandpath('test.xml')) from test.cfm which should open the
    xml file.

    For some reason I can't declare the entity that way. CFDump just returns
    "[unknown type]".

    It does work correctly if I delare the reference as follows

    ../../../path/to/file/test2.xml
    http://localhost/test2.xml
    c:\path\to\file\test2.xml

    The problem is that I don't want to have to reference that "path/to/file"
    because that will change
    once I go from my local machine to the Development server to the Live server.

    Any ideas where the reference actually starts out from and how to properly use
    the relative reference
    without having to refer to the path?

    JohnEric Guest

  2. #2

    Default Re: external entity references in XML

    Couldn't you just use <!ENTITY test SYSTEM "./test2.xml"> ??

    That would make it relative while still pointing to the current directory.

    cheers
    efecto747 Guest

  3. #3

    Default Re: external entity references in XML

    I would have thought that should work but, I tried it and it didn't.
    JohnEric Guest

  4. #4

    Default Re: Possible Bug? external entity references in XML

    Looking into the issue I am having a bit more I think that the behavior that I
    am seeing is a bug.

    I have the following files in a directory of my website.

    test.cfm
    <cfoutput>#expandpath('test.xml')#</cfoutput><br>
    <cffile action="read" file="#expandpath('test.xml')#" variable="theXML">
    <cfset theXMLDoc = XmlP(theXml)>
    <cfdump var="#theXMLDoc#" />

    <cfoutput>
    Structure: #isStruct(theXMLDoc)#<br>
    XMLDoc: #isXmlDoc(theXMLDoc)#<br>
    IsXML: #isXML(theXML)#<br>
    </cfoutput>


    test.xml
    <!DOCTYPE cfxml [
    <!ENTITY test SYSTEM "./test2.xml">
    ]>
    <cfxml>
    &test;
    </cfxml>

    test2.xml
    <test2>
    <xmlnode>content</xmlnode>
    </test2>


    Then when I bring up test.cfm the call to isXmlDoc returns "NO" and the call
    to isXML throws the following error

    An error occured while reading an XML doent.
    C:\CFusionMX\runtime\bin\test2.xml (The system cannot find the file specified)

    The error occurred in test.cfm: line 9

    7 : Structure: #isStruct(theXMLDoc)#<br>
    8 : XMLDoc: #isXmlDoc(theXMLDoc)#<br>
    9 : IsXML: #isXML(theXML)#<br>
    10 : </cfoutput>

    Browser Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12)
    Gecko/20050915 Firefox/1.0.7
    Date/Time 26-Oct-05 11:06 AM
    Stack Trace
    at cftest2ecfm1013804749.runPage(test.cfm:9)

    coldfusion.xml.XmlIOException: An error occured while reading an XML doent.
    at coldfusion.xml.XmlValidator.isWellFormed(XmlValida tor.java:205)
    at coldfusion.xml.XmlProcessor.IsXML(XmlProcessor.jav a:71)
    at coldfusion.runtime.CFPage.IsXml(CFPage.java:334)



    The error refers to not being able to find the file
    C:\CFusionMX\runtime\bin\test2.xml. So instead of looking relative to the path
    of the file calling the xml or the xml file itself, ColdFusion is looking
    relative to the path of execution for the server. That would also explain why
    it works correctly when I use three ../ and then go back up my directory
    structure.

    Is this a problem with the server, or with the java implementation? And if so
    where do I report it?

    JohnEric Guest

Similar Threads

  1. Replies: 1
    Last Post: February 17th, 03:18 AM
  2. Replies: 2
    Last Post: August 16th, 02:38 AM
  3. Replies: 0
    Last Post: December 20th, 07:27 PM
  4. CFFORM XML character entity references
    By HairyDude in forum Coldfusion - Advanced Techniques
    Replies: 5
    Last Post: November 10th, 01:00 AM
  5. [BUG] REXML 2.7.1 External Entity Parsing
    By Paul Duncan in forum Ruby
    Replies: 1
    Last Post: September 5th, 01:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139