tracker issue : CF-3037925

select a category, or use search below
(searches all categories and all time range)
Title:

Bug 76040:The function xmlValidate() invariably returns "[Fatal Error] :1:1: Content is not allowed in prolog" when you pass the schema parameter as an URL

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/

Reporter/Name(from Bugbase): A. Bakia / Bakia (A. Bakia)

Created: 03/17/2009

Components: Language, Functions

Versions: 9.0

Failure Type: Unspecified

Found In Build/Fixed In Build: 0000 /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Win All

Vote Count: 0

Problem:

The function xmlValidate() invariably returns "[Fatal Error] :1:1: Content is not allowed in prolog" when you pass the schema parameter as an URL. That is, this happens even when the XML document is valid.

The functions works as required in every other case

 
Method:

Reference: http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_t-z_26.html

1) Save the following as C:\ColdFusionCentaur\wwwroot\XML_Validation\custorder.xml

<?xml version="1.0" encoding="UTF-8"?>
<order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://127.0.0.1:8500/XML_Validation/custorder.xsd" id="4323251" >
    <customer firstname="Philip" lastname="Cramer" accountNum="21"/>
    <items>
        <item id="43">
            <name>    Deluxe Carpenter&apos;s Hammer</name>
            <quantity>1</quantity>
            <unitprice>15.95</unitprice>
        </item>
        <item id="54">
            <name>    36&quot; Plastic Rake</name>
            <quantity>2</quantity>
            <unitprice>6.95</unitprice>
        </item>
        <item id="68">
            <name>    Standard paint thinner</name>
            <quantity>3</quantity>
            <unitprice>8.95</unitprice>
        </item>
    </items>
</order>

2) Save the following as C:\ColdFusionCentaur\wwwroot\XML_Validation\custorder.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <xs:element name="customer">
        <xs:complexType>
            <xs:attribute name="firstname" type="xs:string" use="required"/>
            <xs:attribute name="lastname" type="xs:string" use="required"/>
            <xs:attribute name="accountNum" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="name" type="xs:string"/>
    <xs:element name="quantity" type="xs:string"/>
    <xs:element name="unitprice" type="xs:string"/>
    <xs:element name="item">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="name"/>
                <xs:element ref="quantity"/>
                <xs:element ref="unitprice"/>
            </xs:sequence>
            <xs:attribute name="id" type="xs:integer" use="required">
            </xs:attribute>
        </xs:complexType>
    </xs:element>
    <xs:element name="items">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="item" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="order">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="customer"/>
                <xs:element ref="items"/>
            </xs:sequence>
            <xs:attribute name="id" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
</xs:schema>

3) Save the following as C:\ColdFusionCentaur\wwwroot\XML_Validation\xmlValidationTest.cfm

<cfset xmlDoc = arrayNew(1)>
<cfset xmlSchema = arrayNew(1)>

<!--- test paths for XML doc --->
<cfset xmlDoc[1] = "custorder.xml">
<cfset xmlDoc[2] = "C:\ColdFusionCentaur\wwwroot\XML_Validation\custorder.xml">
<cfset xmlDoc[3] = "http://localhost:8500/XML_Validation/custorder.xml">

<!--- test paths for schema --->
<cfset xmlSchema[1] = "custorder.xsd">
<cfset xmlSchema[2] = "C:\ColdFusionCentaur\wwwroot\XML_Validation\custorder.xsd">
<cfset xmlSchema[3] = "http://localhost:8500/XML_Validation/custorder.xsd">

<cfloop from="1" to="3" index="i">
	<cfloop from="1" to="3" index="j">
		<!--- validate test doc against test schema using various paths --->
		<cfset myResults=XMLValidate(xmlDoc[i],xmlSchema[j])>
		<cfoutput>
		<strong>XML doc path:</strong> #xmlDoc[i]#<br>
		<strong>schema path:</strong> #xmlSchema[j]#<br>
		Did custorder.xml validate against custorder.xsd? <strong>#myResults.status#</strong><br>
		<cfif arrayLen(myResults.fatalErrors)>
			<strong>Fatal error:</strong> <cfoutput>#myResults.fatalErrors[1]#</cfoutput><br>
		</cfif>
		</cfoutput>
		<br><hr><br>	
</cfloop>
</cfloop>

4) Run xmlValidationTest.cfm



Result:

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3037925

External Customer Info:
External Company:  
External Customer Name: Bakia
External Customer Email: 4E2913DC4455DE13992016B6
External Test Config: 03/17/2009

Attachments:

Comments: