I am messing around with Coldfusion 9, XMLValidate(), an XML document, and a handful of XML schemas as my test environment. These are all sample files I found in a tutorial. This is the error that I am getting:
[Error] :8:35: src-import.3.1: The namespace attribute, 'http://www.myTest.com/OrderTypes', of an <import> element information item must be identical to the targetNamespace attribute, 'http://www.myTest.com/Purchase', of the imported document.
The XML:
<?xml version="1.0" encoding="utf-8"?> <p:Purchase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.myTest.com/Purchase Main.xsd" xmlns:p="http://www.myTest.com/Purchase" xmlns:o="http://www.myTest.com/OrderTypes" xmlns:c="http://www.myTest.com/CustomerTypes" xmlns:cmn="http://www.myTest.com/CommonTypes"> <p:OrderDetail> <o:Item> <o:ProductName>Widget</o:ProductName> <o:Quantity>1</o:Quantity> <o:UnitPrice>3.42</o:UnitPrice> </o:Item> </p:OrderDetail> <p:PaymentMethod>Visa</p:PaymentMethod> <p:CustomerDetails> <c:Name>James</c:Name> <c:DeliveryAddress> <cmn:Line1>15 Some Road</cmn:Line1> <cmn:Line2>SomeTown</cmn:Line2> </c:DeliveryAddress> <c:BillingAddress> <cmn:Line1>15 Some Road</cmn:Line1> <cmn:Line2>SomeTown</cmn:Line2> </c:BillingAddress> </p:CustomerDetails> </p:Purchase>
The Main Schema:
<?xml version="1.0" encoding="utf-8"?> <xs:schema targetNamespace="http://www.ncdoc.navy.mil/Purchase" xmlns:pur="http://www.myTest.com/Purchase" xmlns:ord="http://www.myTest.com/OrderTypes" xmlns:cmn="http://www.myTest.com/CommonTypes" xmlns:cust="http://www.myTest.com/CustomerTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:import schemaLocation="OrderTypes.xsd" namespace="http://www.myTest.com/OrderTypes" /> <xs:import schemaLocation="CommonTypes.xsd" namespace="http://www.myTest.com/CommonTypes" /> <xs:import schemaLocation="CustomerTypes.xsd" namespace="http://www.myTest.com/CustomerTypes" /> <xs:element name="Purchase"> <xs:complexType> <xs:sequence> <xs:element name="OrderDetail" type="ord:OrderType" /> <xs:element name="PaymentMethod" type="cmn:PaymentMethodType" /> <xs:element ref="pur:CustomerDetails" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="CustomerDetails" type="cust:CustomerType" /> </xs:schema>
The CFM Validation Page:
<cfset
myResults=XMLValidate("test.xml", "Main.xsd")>
<cfoutput>
Did test.xml validate against Main.xsd? #myResults.status#<br><br>
</cfoutput>
Dump of myResults structure returned by XMLValidate<br>
<cfdump var="#myResults#">
So, the error states that the namespace attribute value in the import tag must match the targetNamespace attribute value in the document being imported. So, in the first import tag of the Main.xsd file I have this:
<xs:import schemaLocation="OrderTypes.xsd" namespace="http://www.myTest.com/OrderTypes" />
In the OrderTypes.xsd, which is the document being imported, I have this:
<xs:schema xmlns:cmn="http://www.myTest.com/CommonTypes" targetNamespace="http://www.myTest.com/OrderTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
From what I can see the namespace and the targetNamespace attribute values both match. I am not sure where it is getting the targetNamespace attribute value as stated in the error:
[Error] :8:35: src-import.3.1: The namespace attribute, 'http://www.myTest.com/OrderTypes', of an <import> element information item must be identical to the targetNamespace attribute, 'http://www.myTest.com/Purchase', of the imported document.
I get the same error for the other two import tags in the Main.xsd file. Thanks for any insight you may be able to provide.
Cheers!

New Topic/Question
Reply




MultiQuote




|