Product: CF 7 BugHunt User: Anonymous
[Switch Product] CFUG: None

Add and View Bug Comments at the bottom of the Element.
Title: XmlValidate using a complex schema BugID: 1363 Date Opened: 11-May-07
Created By:
David Logwood
Type: Tag Element/Element: XmlValidate
Severity: Unexpected Results Status: New/Unvalidated
Adobe BugID:

Description of bug:
Comments:
--->

A D D     Y O U R     C O M M E N T S     T O     T H I S     B U G

Please login to add comments to a bug


C O M M E N T S

Comment display is being revamped. We apologize for the delay.

Click on this to respond to the current comment Comment   [Steven Erat]   [Friday, May 11, 2007 11:10 AM]
David,

It would be very helpful if you could please post a very simple, complete code example including the example schema and its associated schemas to be imported such that it reproduces the problem as you see it. You're probably working with a large complex example, but for verification purposes it would be great to have something simple that I can easily run to see the problem.

Thanks very much,
Steven Erat
ColdFusion QA
Adobe
Click on this to respond to the current comment Comment   [David Logwood]   [Monday, May 14, 2007 11:23 AM]
Steven,

I will be happy to e-mail you a zip file with the schemas, a sample xml file and the code I am using to validate.
Click on this to respond to the current comment Not Reproducible   [Steven Erat]   [Wednesday, May 16, 2007 10:26 PM]
I reproduced this problem in pure Java, outside of ColdFusion. The error occurs in Apache Xerces, and in the case of ColdFusion the exception just bubbles up.

This is the error produced:

Validating C:/testValidation/test.xml against schema C:/testValidation/Base_30.xsd
Press Control+C to abort.
Press any key to continue . . .
Exception in thread "main" org.xml.sax.SAXParseException: src-import.1.1: The namespace attribute 'http://www.nato.int/namespace/ipiwg/3.0/200504#
information item must not be the same as the targetNamespace of the schema it exists in.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:2525)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees(XSDHandler.java:847)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:569)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:552)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:519)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:485)
at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:206)
at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:594)
at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:610)
at ValidateXML.main(ValidateXml.java:18)

========
JAVA
========
import java.io.*;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.*;
import org.xml.sax.SAXException;

public class ValidateXML {

public static void main(String[] args) throws SAXException, IOException {

// 1. Lookup a factory for the W3C XML Schema language
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

// 2. Compile the schema.
// Here the schema is loaded from a java.io.File, but you could use
// a java.net.URL or a javax.xml.transform.Source instead.
File schemaLocation = new File(args[1]);
Schema schema = factory.newSchema(schemaLocation);

// 3. Get a validator from the schema.
Validator validator = schema.newValidator();

// 4. Parse the document you want to check.
Source source = new StreamSource(args[0]);

// 5. Check the document
try {
validator.validate(source);
System.out.println(args[0] + " is valid.");
}
catch (SAXException ex) {
System.out.println(args[0] + " is not valid because ");
System.out.println(ex.getMessage());
}

}

}

==================
RUN (execute as bat file and pass the full path of the xmldoc and schema in that order)
=================
@echo off
echo Validating %1 against schema %2
echo Press Control+C to abort.
pause

SETLOCAL

set JAVA_HOME="C:\j2sdk1.4.2_05"
set CLASSPATH=C:\CFusionMX7\lib\xercesImpl.jar;C:\CFusionMX7\lib\xalan.jar;C:\CFusionMX7\lib\xml-apis.jar
set PATH=.;%JAVA_HOME%\bin\;%PATH%

java -classpath %CLASSPATH% ValidateXML %1 %2

ENDLOCAL
pause

 


Sponsored by TeraTech - © 2003-2017 www.teratech.com