XML SAX dtd Validation Problem

Hi,
          I’m having problems getting an xml document to validate within Weblogic 8.1. I am trying to parse a document that references both a dtd and xsd. Both the schema and dtd reference need to be substituted so they use local paths. I specify the schema the parser should use and have created an entityResolver to change the dtd reference.
          When this runs as a standalone app from eclipse the file parses and validates without a problem. When deployed to the app server the process seems to be unable read the contents of the dtd. Its not that it cannot find the file (no FileNotFoundException is thrown but this can be created if I delete the dtd) rather it seems to find no declared elements.
          Initial thought was that the code didn’t have access to read the dtd from its location on disk, to check I moved the dtd to within the deployed war and reference as a resource. The problem still persists.
          Code Snippet:
          boolean isValid = false;
          try {
          // Create and configure factory
          SAXParserFactory factory = SAXParserFactoryImpl.newInstance();
          factory.setValidating(true);
          factory.setNamespaceAware(true);
          // To be notified of validation errors in the XML document,
          // add a custom error handler to the document builder
          PIMSFeedFileValidationHandler handler
          = new PIMSFeedFileValidationHandler();
          // Create and Configure Parser
          SAXParser parser = factory.newSAXParser();
          parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
          parser.setProperty(NAMESPACE_PROPERTY_KEY, getSchemaFilePath());
          // Set reader with entityResolver for dtd
          XMLReader xmlReader = parser.getXMLReader();
          xmlReader.setEntityResolver(new SAXEntityResolver(this.dtdPath));
          // convert file to URL, as it is a remote file
          URL url = super.getFile().toURL();
          // Open an input stream and parse
          InputStream is = url.openStream();
          xmlReader.setErrorHandler(handler);
          xmlReader.parse(new InputSource(is));
          is.close();
          // get the result of parsing the document by checking the
          // errorhandler's isValid property
          isValid = handler.isValid();
          if (!isValid) {
          LOGGER.warn(handler.getMessage());
          LOGGER.debug("XML file is valid XML? " + isValid);
          } catch (ParserConfigurationException e) {
          LOGGER.error("Error parsing file", e);
          } catch (SAXException e) {
          LOGGER.error("Error parsing file", e);
          } catch (IOException e) {
          throw new FeedException(e);
          return isValid;
          See stack trace below for a little more info.
          2005-01-28 10:24:09,217 [DEBUG] [file] - Attempting validation of file 'cw501205.wa1.xml' with schema at 'C:/pims-feeds/hansard/schema/hansard-v1-9.xsd'
          2005-01-28 10:24:09,217 [DEBUG] [file] - Entity Resolver is using DTD path file:C:/Vignette/runtime_services/8.1/install/common/nodemanager/
          VgnVCMServer/stage/pims-hansard/pims-hansard.war/WEB-INF/classes/com/morse/pims/cms/feed/sax/ISO-Entities.dtd
          2005-01-28 10:24:09,227 [DEBUG] [file] - Creating InputSource at: file:C:/Vignette/runtime_services/8.1/install/common/nodemanager/VgnVCMServer/stage/pims-hansard/pims-hansard.war/WEB-INF/classes/com/morse/pims/cms/feed/sax/ISO-Entities.dtd
          2005-01-28 10:24:09,718 [WARN ] [file] - org.xml.sax.SAXParseException: Element type "Hansard" must be declared.
          org.xml.sax.SAXParseException: Element type "Session" must be declared.
          org.xml.sax.SAXParseException: Element type "DailyRecord" must be declared.
          org.xml.sax.SAXParseException: Element type "Volume" must be declared.
          org.xml.sax.SAXParseException: Element type "Written" must be declared.
          org.xml.sax.SAXParseException: Element type "WrittenHeading" must be declared.
          org.xml.sax.SAXParseException: Element type "Introduction" must be declared.
          … continues for all the elements in the doc
          2005-01-28 10:24:10,519 [DEBUG] [file] - XML file is valid XML? false
          2005-01-28 10:24:10,519 [WARN ] [file] - Daily Part file 'cw501205.wa1.xml' was not valid XML and was not processed.
          Has anybody seen this behavior before with weblogic and if so how have you resolved the issue.
          Thanks in Advance
          Adam

It looks like you clicked on "Post" before you got around to explaining your problem. I don't see any error messages or any description of what was supposed to happen and what happened instead.
Now, I don't know anything about XML Schema, but just guessing at how that unique name feature might be designed, and just guessing that your unique name is actually in the <userId> element, I would suggest that this:
<xsd:unique name="un_name"> 
  <xsd:selector xpath="USER"/> 
  <xsd:field xpath="."/> 
</xsd:unique> is at fault because it doesn't mention the <userId> element anywhere.

Similar Messages

  • How to disable XML´s DTD validation in Weblogic10?

    Hello folks, we are trying to upgrade our server to Weblogic10, but it´s XML parser is validating XML´s DTD and ´cause we are behind a firewall we receive a error like:
    Tried all: ´6´ address, but could not connect over HTTP to server: 'www.w3.org', port: '80'
    Does anyone here known how to disable DTD validation in WL10?
    Regards,
    lottalava

    Well you can create non validating parser programatically .
    http://edocs.bea.com/wls/docs100/xml/programming.html#wp1069856
    i.e.
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setValidating(false);
    Hope this helps.

  • Oracle DTD Validation problem

    Hi All,
    I'm using the xmlparserv2.jar in the Oracle XML Schema Processor library (version 1.0) to validate my XML document. This is how I set the parser up:
    //createURL is a method to create the URL from the filename
    URL path = createURL(dtdFileName);
    //Create a new DOMParser
    DOMParser parser = new DOMParser();
    //Parse the external DTD first, to make sure the DTD is valid. Throws an XMLParseException
    //if the DTD is not valid.
    parser.parseDTD(path, rootName);
    DTD dtdFile = parser.getDoctype();
    //Set the parser properties to use the DTD file obtained
    parser.setPreserveWhitespace(true);
    parser.setValidationMode(XMLParser.DTD_VALIDATION);
    parser.setErrorStream(System.err);
    parser.setDoctype(dtdFile);
    //Do the validation by parsing the document. Throws an XMLParseException if there're any
    //validation error
    input = new BufferedInputStream(new ByteArrayInputStream(XMLString.getBytes()));
    parser.parse(input);
    The problem is that it complained that the XML document is not valid (while I know for sure it is!)...it doesn't seem like it's validating againts the DTD specified. I had no problem with the previous version (ver 0.9), so I'm wondering if I'm doing it right.
    Also, what's the difference between the xmlparserv2.jar in the XML Parser v2.0.2.9 and the xmlparserv2.jar in the XML Schema Processor v1.0.0.0?? What's should I be using either one of them?
    Thanks in advance,
    Cheers,
    Jin
    null

    When you go to get connection you have to set the ORACLE_SID enviroment variable or use the service name in the string to get connection.
    Joel Pérez

  • JDev 9.0.3_2: web.xml fails DTD validation

    Hi all,
    I just started using JDev 9.0.3_2 and found that it is trying to validate my web.xml when I build my Project.
    It is complaining about the <distributable> Tag inside my web.xml file. It should NOT be complaining about this, but it is obviously using either an outdated DTD or the wrong one.
    How can I either point JDev at the correct DTD or get it to stop attemting to validate web.xml?
    Thanks!
    Kevin Dougan

    I think I have figured out a workaround: It appears that JDeveloper is extremely picking about web.xml and validates it in a strict sense. You MUST put your elements in EXACTLY the same order as specified in the DTD, or it throws an error.
    However, that doesn't answer my original question: Is there a way to specify the DTD for web.xml (or other elements for that matter, Schema's aside for the moment) or at least turn off this form of validation? If not in the current release, is this coming in 9.0.4 or 9.0.5?
    Thanks again,
    Kevin

  • XML digital signature validation problem - ArrayIndexOutOfBoundsException

    Hello,
    During validation of XML signature ( boolean coreValidity = signature.validate(valContext); ) , I get error:
    javax.xml.crypto.dsig.XMLSignatureException: java.lang.ArrayIndexOutOfBoundsException
         at org.jcp.xml.dsig.internal.dom.DOMReference.transform(Unknown Source)
         at org.jcp.xml.dsig.internal.dom.DOMReference.validate(Unknown Source)
         at GenSig.verify(GenSig.java:313)
         at GenSig.main(GenSig.java:545)
    The problem happens when validation process is checking reference to a file, which size is bigger than 50 KB. The same file if it is smaller than 50KB - makes no problems.
    Can anyone tell, how to avoid this problem?
    P.s. I'm working on Java 1.6
    Here is the log:
    2009-06-18 08.59.53 com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver getInstance
    FINE: check resolvability by class com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver
    2009-06-18 08.59.53 com.sun.org.apache.xml.internal.security.utils.resolver.implementations.ResolverDirectHTTP engineCanResolve
    FINE: I was asked whether I can resolve adoc1200922024845.pdf
    2009-06-18 08.59.53 com.sun.org.apache.xml.internal.security.utils.resolver.implementations.ResolverDirectHTTP engineCanResolve
    FINE: I state that I can't resolve adoc1200922024845.pdf
    2009-06-18 08.59.53 com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver getInstance
    FINE: check resolvability by class com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver
    2009-06-18 08.59.53 com.sun.org.apache.xml.internal.security.utils.resolver.implementations.ResolverLocalFilesystem engineCanResolve
    FINE: I was asked whether I can resolve adoc1200922024845.pdf
    2009-06-18 08.59.53 com.sun.org.apache.xml.internal.security.utils.resolver.implementations.ResolverLocalFilesystem engineCanResolve
    FINE: I state that I can resolve adoc1200922024845.pdf
    2009-06-18 08.59.53 org.jcp.xml.dsig.internal.dom.DOMReference dereference
    FINE: URIDereferencer class name: org.jcp.xml.dsig.internal.dom.DOMURIDereferencer
    2009-06-18 08.59.53 org.jcp.xml.dsig.internal.dom.DOMReference dereference
    FINE: Data class name: org.jcp.xml.dsig.internal.dom.ApacheOctetStreamData
    javax.xml.crypto.dsig.XMLSignatureException: java.lang.ArrayIndexOutOfBoundsException
    javax.xml.crypto.dsig.XMLSignatureException: java.lang.ArrayIndexOutOfBoundsException
         at org.jcp.xml.dsig.internal.dom.DOMReference.transform(Unknown Source)
         at org.jcp.xml.dsig.internal.dom.DOMReference.validate(Unknown Source)
         at GenSig.verify(GenSig.java:313)
         at GenSig.main(GenSig.java:545)
    Caused by: java.lang.ArrayIndexOutOfBoundsException
         at java.lang.System.arraycopy(Native Method)
         at com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream.write(Unknown Source)
         at org.jcp.xml.dsig.internal.DigesterOutputStream.write(Unknown Source)
         at com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream.write(Unknown Source)
         at com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream.write(Unknown Source)
         at com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput.updateOutputStream(Unknown Source)
    <...>

    Well I came to "not nice"solution - instead of validating all XMLSignature with one standard function ( boolean coreValidity = signature.validate(valContext); ), I validate it in parts:
    1. Check if signature value is ok.: boolean sv = signature.getSignatureValue().validate(valContext);
    2 Start checking all references:
    A. if reference leads to whole file - then I read file and calculate digest value:
    MessageDigest md = MessageDigest.getInstance("SHA");
    md.update(buffer, 0, length); // buffer - bytes[] of file
    byte[] raw = md.digest(); // get digest valueB. if reference is only to some part of file (just to some XML element), then I validate it by reference: boolean refValid = r.validate(valContext);

  • ParserUtils: warning org.xml.sax.SAXParseException

    Hi, I am trying to deploy the samples from JSF_BETA. to Borland Enterprise Server(which uses Tomcat as a web-container), The "guessnumber" sample works absolutely fine but the "components" sample throws up the following error: Please note that all the samples from previous JSF versions work fine.
    "menu.jsp": ParserUtils: warning org.xml.sax.SAXParseException: Valid documents must have a <!DOCTYPE declaration.
    error:This absolute uri (http://java.sun.com/jsf/demo/components) cannot be resolved in either web.xml or the jar files deployed with this application
    C:\j2sdk1.4.2_01\bin\java -classpath "C:\Program Files\Borland\BES\lib\tomcat\jasper\jasper-runtime.jar;C:\Program Files\Borland\BES\lib\tomcat\jasper\jasper-compiler.jar;C:\Program Files\Borland\BES\lib\tomcat\common\ant.jar;C:\Program Files\Borland\BES\lib\tomcat\common\jasper-runtime.jar;C:\Program Files\Borland\BES\lib\tomcat\common\jasper-compiler.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-common.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-factory.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-resources.jar;C:\Program Files\Borland\BES\lib\tomcat\common\servlet.jar;C:\Program Files\Borland\BES\lib\xmlrt.jar;F:\WORK\JSF10BETA\temp4\classes;C:\Program Files\Borland\BES\lib\asrt.jar;C:\Program Files\Borland\BES\lib\lm.jar;C:\Program Files\Borland\BES\lib\xmlrt.jar;C:\Program Files\Borland\BES\lib\vbjorb.jar;C:\Program Files\Borland\BES\lib\vbejb.jar;C:\Program Files\Borland\BES\lib\vbsec.jar;C:\Program Files\Borland\BES\lib\beandt.jar;C:\Program Files\Borland\BES\lib\dx.jar;C:\Program Files\Borland\BES\lib\axis\axis-bes.jar;C:\Program Files\Borland\BES\lib\axis\axis-ant.jar;C:\Program Files\Borland\BES\SonicMQ\lib\sonic_Client.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-beanutils.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-collections.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-digester.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-logging.jar;F:\WORK\JSF10BETA\temp5\libraries\jsf-api.jar;F:\WORK\JSF10BETA\temp5\libraries\jsf-impl.jar;F:\WORK\JSF10BETA\temp5\libraries\jstl.jar;F:\WORK\JSF10BETA\temp5\libraries\standard.jar;C:\Program Files\Borland\BES\lib\tomcat\common\servlet.jar;C:\j2sdk1.4.2_01\demo\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.2_01\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.2_01\jre\javaws\javaws.jar;C:\j2sdk1.4.2_01\jre\lib\charsets.jar;C:\j2sdk1.4.2_01\jre\lib\ext\dnsns.jar;C:\j2sdk1.4.2_01\jre\lib\ext\ldapsec.jar;C:\j2sdk1.4.2_01\jre\lib\ext\localedata.jar;C:\j2sdk1.4.2_01\jre\lib\ext\sunjce_provider.jar;C:\j2sdk1.4.2_01\jre\lib\im\indicim.jar;C:\j2sdk1.4.2_01\jre\lib\im\thaiim.jar;C:\j2sdk1.4.2_01\jre\lib\jce.jar;C:\j2sdk1.4.2_01\jre\lib\jsse.jar;C:\j2sdk1.4.2_01\jre\lib\plugin.jar;C:\j2sdk1.4.2_01\jre\lib\rt.jar;C:\j2sdk1.4.2_01\jre\lib\sunrsasign.jar;C:\j2sdk1.4.2_01\lib\dt.jar;C:\j2sdk1.4.2_01\lib\htmlconverter.jar;C:\j2sdk1.4.2_01\lib\tools.jar" org.apache.jasper.JspC -d "F:/WORK/JSF10BETA/temp4/classes/Temporary_Files/.jsp/temp4app" -p "" -c menu_0002ejsp_jsp -uriroot "F:/WORK/JSF10BETA/temp4/temp4app" "F:/WORK/JSF10BETA/temp4/temp4app/menu.jsp"
    "menu.jsp": Invocation Error
    "index.jsp": ParserUtils: warning org.xml.sax.SAXParseException: Valid documents must have a <!DOCTYPE declaration.
    "ShowSource.jsp": ParserUtils: warning org.xml.sax.SAXParseException: Valid documents must have a <!DOCTYPE declaration.
    error:This absolute uri (http://java.sun.com/jstl/core) cannot be resolved in either web.xml or the jar files deployed with this application
    C:\j2sdk1.4.2_01\bin\java -classpath "C:\Program Files\Borland\BES\lib\tomcat\jasper\jasper-runtime.jar;C:\Program Files\Borland\BES\lib\tomcat\jasper\jasper-compiler.jar;C:\Program Files\Borland\BES\lib\tomcat\common\ant.jar;C:\Program Files\Borland\BES\lib\tomcat\common\jasper-runtime.jar;C:\Program Files\Borland\BES\lib\tomcat\common\jasper-compiler.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-common.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-factory.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-resources.jar;C:\Program Files\Borland\BES\lib\tomcat\common\servlet.jar;C:\Program Files\Borland\BES\lib\xmlrt.jar;F:\WORK\JSF10BETA\temp4\classes;C:\Program Files\Borland\BES\lib\asrt.jar;C:\Program Files\Borland\BES\lib\lm.jar;C:\Program Files\Borland\BES\lib\xmlrt.jar;C:\Program Files\Borland\BES\lib\vbjorb.jar;C:\Program Files\Borland\BES\lib\vbejb.jar;C:\Program Files\Borland\BES\lib\vbsec.jar;C:\Program Files\Borland\BES\lib\beandt.jar;C:\Program Files\Borland\BES\lib\dx.jar;C:\Program Files\Borland\BES\lib\axis\axis-bes.jar;C:\Program Files\Borland\BES\lib\axis\axis-ant.jar;C:\Program Files\Borland\BES\SonicMQ\lib\sonic_Client.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-beanutils.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-collections.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-digester.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-logging.jar;F:\WORK\JSF10BETA\temp5\libraries\jsf-api.jar;F:\WORK\JSF10BETA\temp5\libraries\jsf-impl.jar;F:\WORK\JSF10BETA\temp5\libraries\jstl.jar;F:\WORK\JSF10BETA\temp5\libraries\standard.jar;C:\Program Files\Borland\BES\lib\tomcat\common\servlet.jar;C:\j2sdk1.4.2_01\demo\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.2_01\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.2_01\jre\javaws\javaws.jar;C:\j2sdk1.4.2_01\jre\lib\charsets.jar;C:\j2sdk1.4.2_01\jre\lib\ext\dnsns.jar;C:\j2sdk1.4.2_01\jre\lib\ext\ldapsec.jar;C:\j2sdk1.4.2_01\jre\lib\ext\localedata.jar;C:\j2sdk1.4.2_01\jre\lib\ext\sunjce_provider.jar;C:\j2sdk1.4.2_01\jre\lib\im\indicim.jar;C:\j2sdk1.4.2_01\jre\lib\im\thaiim.jar;C:\j2sdk1.4.2_01\jre\lib\jce.jar;C:\j2sdk1.4.2_01\jre\lib\jsse.jar;C:\j2sdk1.4.2_01\jre\lib\plugin.jar;C:\j2sdk1.4.2_01\jre\lib\rt.jar;C:\j2sdk1.4.2_01\jre\lib\sunrsasign.jar;C:\j2sdk1.4.2_01\lib\dt.jar;C:\j2sdk1.4.2_01\lib\htmlconverter.jar;C:\j2sdk1.4.2_01\lib\tools.jar" org.apache.jasper.JspC -d "F:/WORK/JSF10BETA/temp4/classes/Temporary_Files/.jsp/temp4app" -p "" -c ShowSource_0002ejsp_jsp -uriroot "F:/WORK/JSF10BETA/temp4/temp4app" "F:/WORK/JSF10BETA/temp4/temp4app/ShowSource.jsp"
    "ShowSource.jsp": Invocation Error
    "tabbedpanes3.jsp": ParserUtils: warning org.xml.sax.SAXParseException: Valid documents must have a <!DOCTYPE declaration.
    "demo-test.jsp": ParserUtils: warning org.xml.sax.SAXParseException: Valid documents must have a <!DOCTYPE declaration.
    "repeater.jsp": ParserUtils: warning org.xml.sax.SAXParseException: Valid documents must have a <!DOCTYPE declaration.
    error:This absolute uri (http://java.sun.com/jstl/core) cannot be resolved in either web.xml or the jar files deployed with this application
    C:\j2sdk1.4.2_01\bin\java -classpath "C:\Program Files\Borland\BES\lib\tomcat\jasper\jasper-runtime.jar;C:\Program Files\Borland\BES\lib\tomcat\jasper\jasper-compiler.jar;C:\Program Files\Borland\BES\lib\tomcat\common\ant.jar;C:\Program Files\Borland\BES\lib\tomcat\common\jasper-runtime.jar;C:\Program Files\Borland\BES\lib\tomcat\common\jasper-compiler.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-common.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-factory.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-resources.jar;C:\Program Files\Borland\BES\lib\tomcat\common\servlet.jar;C:\Program Files\Borland\BES\lib\xmlrt.jar;F:\WORK\JSF10BETA\temp4\classes;C:\Program Files\Borland\BES\lib\asrt.jar;C:\Program Files\Borland\BES\lib\lm.jar;C:\Program Files\Borland\BES\lib\xmlrt.jar;C:\Program Files\Borland\BES\lib\vbjorb.jar;C:\Program Files\Borland\BES\lib\vbejb.jar;C:\Program Files\Borland\BES\lib\vbsec.jar;C:\Program Files\Borland\BES\lib\beandt.jar;C:\Program Files\Borland\BES\lib\dx.jar;C:\Program Files\Borland\BES\lib\axis\axis-bes.jar;C:\Program Files\Borland\BES\lib\axis\axis-ant.jar;C:\Program Files\Borland\BES\SonicMQ\lib\sonic_Client.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-beanutils.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-collections.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-digester.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-logging.jar;F:\WORK\JSF10BETA\temp5\libraries\jsf-api.jar;F:\WORK\JSF10BETA\temp5\libraries\jsf-impl.jar;F:\WORK\JSF10BETA\temp5\libraries\jstl.jar;F:\WORK\JSF10BETA\temp5\libraries\standard.jar;C:\Program Files\Borland\BES\lib\tomcat\common\servlet.jar;C:\j2sdk1.4.2_01\demo\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.2_01\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.2_01\jre\javaws\javaws.jar;C:\j2sdk1.4.2_01\jre\lib\charsets.jar;C:\j2sdk1.4.2_01\jre\lib\ext\dnsns.jar;C:\j2sdk1.4.2_01\jre\lib\ext\ldapsec.jar;C:\j2sdk1.4.2_01\jre\lib\ext\localedata.jar;C:\j2sdk1.4.2_01\jre\lib\ext\sunjce_provider.jar;C:\j2sdk1.4.2_01\jre\lib\im\indicim.jar;C:\j2sdk1.4.2_01\jre\lib\im\thaiim.jar;C:\j2sdk1.4.2_01\jre\lib\jce.jar;C:\j2sdk1.4.2_01\jre\lib\jsse.jar;C:\j2sdk1.4.2_01\jre\lib\plugin.jar;C:\j2sdk1.4.2_01\jre\lib\rt.jar;C:\j2sdk1.4.2_01\jre\lib\sunrsasign.jar;C:\j2sdk1.4.2_01\lib\dt.jar;C:\j2sdk1.4.2_01\lib\htmlconverter.jar;C:\j2sdk1.4.2_01\lib\tools.jar" org.apache.jasper.JspC -d "F:/WORK/JSF10BETA/temp4/classes/Temporary_Files/.jsp/temp4app" -p "" -c repeater_0002ejsp_jsp -uriroot "F:/WORK/JSF10BETA/temp4/temp4app" "F:/WORK/JSF10BETA/temp4/temp4app/repeater.jsp"
    "repeater.jsp": Invocation Error
    "result-set.jsp": ParserUtils: warning org.xml.sax.SAXParseException: Valid documents must have a <!DOCTYPE declaration.
    error:This absolute uri (http://java.sun.com/jsf/demo/components) cannot be resolved in either web.xml or the jar files deployed with this application
    C:\j2sdk1.4.2_01\bin\java -classpath "C:\Program Files\Borland\BES\lib\tomcat\jasper\jasper-runtime.jar;C:\Program Files\Borland\BES\lib\tomcat\jasper\jasper-compiler.jar;C:\Program Files\Borland\BES\lib\tomcat\common\ant.jar;C:\Program Files\Borland\BES\lib\tomcat\common\jasper-runtime.jar;C:\Program Files\Borland\BES\lib\tomcat\common\jasper-compiler.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-common.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-factory.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-resources.jar;C:\Program Files\Borland\BES\lib\tomcat\common\servlet.jar;C:\Program Files\Borland\BES\lib\xmlrt.jar;F:\WORK\JSF10BETA\temp4\classes;C:\Program Files\Borland\BES\lib\asrt.jar;C:\Program Files\Borland\BES\lib\lm.jar;C:\Program Files\Borland\BES\lib\xmlrt.jar;C:\Program Files\Borland\BES\lib\vbjorb.jar;C:\Program Files\Borland\BES\lib\vbejb.jar;C:\Program Files\Borland\BES\lib\vbsec.jar;C:\Program Files\Borland\BES\lib\beandt.jar;C:\Program Files\Borland\BES\lib\dx.jar;C:\Program Files\Borland\BES\lib\axis\axis-bes.jar;C:\Program Files\Borland\BES\lib\axis\axis-ant.jar;C:\Program Files\Borland\BES\SonicMQ\lib\sonic_Client.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-beanutils.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-collections.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-digester.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-logging.jar;F:\WORK\JSF10BETA\temp5\libraries\jsf-api.jar;F:\WORK\JSF10BETA\temp5\libraries\jsf-impl.jar;F:\WORK\JSF10BETA\temp5\libraries\jstl.jar;F:\WORK\JSF10BETA\temp5\libraries\standard.jar;C:\Program Files\Borland\BES\lib\tomcat\common\servlet.jar;C:\j2sdk1.4.2_01\demo\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.2_01\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.2_01\jre\javaws\javaws.jar;C:\j2sdk1.4.2_01\jre\lib\charsets.jar;C:\j2sdk1.4.2_01\jre\lib\ext\dnsns.jar;C:\j2sdk1.4.2_01\jre\lib\ext\ldapsec.jar;C:\j2sdk1.4.2_01\jre\lib\ext\localedata.jar;C:\j2sdk1.4.2_01\jre\lib\ext\sunjce_provider.jar;C:\j2sdk1.4.2_01\jre\lib\im\indicim.jar;C:\j2sdk1.4.2_01\jre\lib\im\thaiim.jar;C:\j2sdk1.4.2_01\jre\lib\jce.jar;C:\j2sdk1.4.2_01\jre\lib\jsse.jar;C:\j2sdk1.4.2_01\jre\lib\plugin.jar;C:\j2sdk1.4.2_01\jre\lib\rt.jar;C:\j2sdk1.4.2_01\jre\lib\sunrsasign.jar;C:\j2sdk1.4.2_01\lib\dt.jar;C:\j2sdk1.4.2_01\lib\htmlconverter.jar;C:\j2sdk1.4.2_01\lib\tools.jar" org.apache.jasper.JspC -d "F:/WORK/JSF10BETA/temp4/classes/Temporary_Files/.jsp/temp4app" -p "" -c result_0002dset_0002ejsp_jsp -uriroot "F:/WORK/JSF10BETA/temp4/temp4app" "F:/WORK/JSF10BETA/temp4/temp4app/result-set.jsp"
    "result-set.jsp": Invocation Error
    "tabbedpanes.jsp": ParserUtils: warning org.xml.sax.SAXParseException: Valid documents must have a <!DOCTYPE declaration.
    error:This absolute uri (http://java.sun.com/jsf/demo/components) cannot be resolved in either web.xml or the jar files deployed with this application
    C:\j2sdk1.4.2_01\bin\java -classpath "C:\Program Files\Borland\BES\lib\tomcat\jasper\jasper-runtime.jar;C:\Program Files\Borland\BES\lib\tomcat\jasper\jasper-compiler.jar;C:\Program Files\Borland\BES\lib\tomcat\common\ant.jar;C:\Program Files\Borland\BES\lib\tomcat\common\jasper-runtime.jar;C:\Program Files\Borland\BES\lib\tomcat\common\jasper-compiler.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-common.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-factory.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-resources.jar;C:\Program Files\Borland\BES\lib\tomcat\common\servlet.jar;C:\Program Files\Borland\BES\lib\xmlrt.jar;F:\WORK\JSF10BETA\temp4\classes;C:\Program Files\Borland\BES\lib\asrt.jar;C:\Program Files\Borland\BES\lib\lm.jar;C:\Program Files\Borland\BES\lib\xmlrt.jar;C:\Program Files\Borland\BES\lib\vbjorb.jar;C:\Program Files\Borland\BES\lib\vbejb.jar;C:\Program Files\Borland\BES\lib\vbsec.jar;C:\Program Files\Borland\BES\lib\beandt.jar;C:\Program Files\Borland\BES\lib\dx.jar;C:\Program Files\Borland\BES\lib\axis\axis-bes.jar;C:\Program Files\Borland\BES\lib\axis\axis-ant.jar;C:\Program Files\Borland\BES\SonicMQ\lib\sonic_Client.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-beanutils.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-collections.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-digester.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-logging.jar;F:\WORK\JSF10BETA\temp5\libraries\jsf-api.jar;F:\WORK\JSF10BETA\temp5\libraries\jsf-impl.jar;F:\WORK\JSF10BETA\temp5\libraries\jstl.jar;F:\WORK\JSF10BETA\temp5\libraries\standard.jar;C:\Program Files\Borland\BES\lib\tomcat\common\servlet.jar;C:\j2sdk1.4.2_01\demo\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.2_01\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.2_01\jre\javaws\javaws.jar;C:\j2sdk1.4.2_01\jre\lib\charsets.jar;C:\j2sdk1.4.2_01\jre\lib\ext\dnsns.jar;C:\j2sdk1.4.2_01\jre\lib\ext\ldapsec.jar;C:\j2sdk1.4.2_01\jre\lib\ext\localedata.jar;C:\j2sdk1.4.2_01\jre\lib\ext\sunjce_provider.jar;C:\j2sdk1.4.2_01\jre\lib\im\indicim.jar;C:\j2sdk1.4.2_01\jre\lib\im\thaiim.jar;C:\j2sdk1.4.2_01\jre\lib\jce.jar;C:\j2sdk1.4.2_01\jre\lib\jsse.jar;C:\j2sdk1.4.2_01\jre\lib\plugin.jar;C:\j2sdk1.4.2_01\jre\lib\rt.jar;C:\j2sdk1.4.2_01\jre\lib\sunrsasign.jar;C:\j2sdk1.4.2_01\lib\dt.jar;C:\j2sdk1.4.2_01\lib\htmlconverter.jar;C:\j2sdk1.4.2_01\lib\tools.jar" org.apache.jasper.JspC -d "F:/WORK/JSF10BETA/temp4/classes/Temporary_Files/.jsp/temp4app" -p "" -c tabbedpanes_0002ejsp_jsp -uriroot "F:/WORK/JSF10BETA/temp4/temp4app" "F:/WORK/JSF10BETA/temp4/temp4app/tabbedpanes.jsp"
    "tabbedpanes.jsp": Invocation Error
    "imagemap.jsp": ParserUtils: warning org.xml.sax.SAXParseException: Valid documents must have a <!DOCTYPE declaration.
    error:This absolute uri (http://java.sun.com/jsf/demo/components) cannot be resolved in either web.xml or the jar files deployed with this application
    C:\j2sdk1.4.2_01\bin\java -classpath "C:\Program Files\Borland\BES\lib\tomcat\jasper\jasper-runtime.jar;C:\Program Files\Borland\BES\lib\tomcat\jasper\jasper-compiler.jar;C:\Program Files\Borland\BES\lib\tomcat\common\ant.jar;C:\Program Files\Borland\BES\lib\tomcat\common\jasper-runtime.jar;C:\Program Files\Borland\BES\lib\tomcat\common\jasper-compiler.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-common.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-factory.jar;C:\Program Files\Borland\BES\lib\tomcat\common\naming-resources.jar;C:\Program Files\Borland\BES\lib\tomcat\common\servlet.jar;C:\Program Files\Borland\BES\lib\xmlrt.jar;F:\WORK\JSF10BETA\temp4\classes;C:\Program Files\Borland\BES\lib\asrt.jar;C:\Program Files\Borland\BES\lib\lm.jar;C:\Program Files\Borland\BES\lib\xmlrt.jar;C:\Program Files\Borland\BES\lib\vbjorb.jar;C:\Program Files\Borland\BES\lib\vbejb.jar;C:\Program Files\Borland\BES\lib\vbsec.jar;C:\Program Files\Borland\BES\lib\beandt.jar;C:\Program Files\Borland\BES\lib\dx.jar;C:\Program Files\Borland\BES\lib\axis\axis-bes.jar;C:\Program Files\Borland\BES\lib\axis\axis-ant.jar;C:\Program Files\Borland\BES\SonicMQ\lib\sonic_Client.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-beanutils.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-collections.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-digester.jar;F:\WORK\JSF10BETA\temp5\libraries\commons-logging.jar;F:\WORK\JSF10BETA\temp5\libraries\jsf-api.jar;F:\WORK\JSF10BETA\temp5\libraries\jsf-impl.jar;F:\WORK\JSF10BETA\temp5\libraries\jstl.jar;F:\WORK\JSF10BETA\temp5\libraries\standard.jar;C:\Program Files\Borland\BES\lib\tomcat\common\servlet.jar;C:\j2sdk1.4.2_01\demo\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.2_01\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\j2sdk1.4.2_01\jre\javaws\javaws.jar;C:\j2sdk1.4.2_01\jre\lib\charsets.jar;C:\j2sdk1.4.2_01\jre\lib\ext\dnsns.jar;C:\j2sdk1.4.2_01\jre\lib\ext\ldapsec.jar;C:\j2sdk1.4.2_01\jre\lib\ext\localedata.jar;C:\j2sdk1.4.2_01\jre\lib\ext\sunjce_provider.jar;C:\j2sdk1.4.2_01\jre\lib\im\indicim.jar;C:\j2sdk1.4.2_01\jre\lib\im\thaiim.jar;C:\j2sdk1.4.2_01\jre\lib\jce.jar;C:\j2sdk1.4.2_01\jre\lib\jsse.jar;C:\j2sdk1.4.2_01\jre\lib\plugin.jar;C:\j2sdk1.4.2_01\jre\lib\rt.jar;C:\j2sdk1.4.2_01\jre\lib\sunrsasign.jar;C:\j2sdk1.4.2_01\lib\dt.jar;C:\j2sdk1.4.2_01\lib\htmlconverter.jar;C:\j2sdk1.4.2_01\lib\tools.jar" org.apache.jasper.JspC -d "F:/WORK/JSF10BETA/temp4/classes/Temporary_Files/.jsp/temp4app" -p "" -c imagemap_0002ejsp_jsp -uriroot "F:/WORK/JSF10BETA/temp4/temp4app" "F:/WORK/JSF10BETA/temp4/temp4app/imagemap.jsp"
    "imagemap.jsp": Invocation Error

    It looks like the XML parser provided by the server is having problems with resolving URIs to resources that are within a JAR file. In addition, the JSF web applications have JSTL 1.1 bundled into them, so if the server is running a version of Tomcat 4.x (instead of 5.x) you'll have problems with the JSTL tag libraries -- which the guessNumber demo does not use but the components demo does.
    Craig

  • SAX Parser XML Validation Problems

    Hi,
    I’m having problems getting an xml document to validate within Weblogic 8.1. I am trying to parse a document that references both a dtd and xsd. Both the schema and dtd reference need to be substituted so they use local paths. I specify the schema the parser should use and have created an entityResolver to change the dtd reference.
    When this runs as a standalone app from eclipse the file parses and validates without a problem. When deployed to the app server the process seems to be unable read the contents of the dtd. Its not that it cannot find the file (no FileNotFoundException is thrown but this can be created if I delete the dtd) rather it seems to find no declared elements.
    Initial thought was that the code didn’t have access to read the dtd from its location on disk, to check I moved the dtd to within the deployed war and reference as a resource. The problem still persists.
    Code Snippet:
    boolean isValid = false;
    try {
         // Create and configure factory
    SAXParserFactory factory = SAXParserFactoryImpl.newInstance();
    factory.setValidating(true);
    factory.setNamespaceAware(true);
    // To be notified of validation errors in the XML document,
    // add a custom error handler to the document builder
    PIMSFeedFileValidationHandler handler
    = new PIMSFeedFileValidationHandler();
         // Create and Configure Parser
    SAXParser parser = factory.newSAXParser();
    parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
    parser.setProperty(NAMESPACE_PROPERTY_KEY, getSchemaFilePath());
         // Set reader with entityResolver for dtd
    XMLReader xmlReader = parser.getXMLReader();
    xmlReader.setEntityResolver(new SAXEntityResolver(this.dtdPath));
    // convert file to URL, as it is a remote file
    URL url = super.getFile().toURL();
    // Open an input stream and parse
    InputStream is = url.openStream();
    xmlReader.setErrorHandler(handler);
    xmlReader.parse(new InputSource(is));
    is.close();
    // get the result of parsing the document by checking the
    // errorhandler's isValid property
    isValid = handler.isValid();
    if (!isValid) {
    LOGGER.warn(handler.getMessage());
    LOGGER.debug("XML file is valid XML? " + isValid);
    } catch (ParserConfigurationException e) {
    LOGGER.error("Error parsing file", e);
    } catch (SAXException e) {
    LOGGER.error("Error parsing file", e);
    } catch (IOException e) {
    throw new FeedException(e);
    return isValid;
    See stack trace below for a little more info.
    2005-01-28 10:24:09,217 [DEBUG] [file] - Attempting validation of file 'cw501205.wa1.xml' with schema at 'C:/pims-feeds/hansard/schema/hansard-v1-9.xsd'
    2005-01-28 10:24:09,217 [DEBUG] [file] - Entity Resolver is using DTD path file:C:/Vignette/runtime_services/8.1/install/common/nodemanager/
    VgnVCMServer/stage/pims-hansard/pims-hansard.war/WEB-INF/classes/com/morse/pims/cms/feed/sax/ISO-Entities.dtd
    2005-01-28 10:24:09,227 [DEBUG] [file] - Creating InputSource at: file:C:/Vignette/runtime_services/8.1/install/common/nodemanager/VgnVCMServer/stage/pims-hansard/pims-hansard.war/WEB-INF/classes/com/morse/pims/cms/feed/sax/ISO-Entities.dtd
    2005-01-28 10:24:09,718 [WARN ] [file] - org.xml.sax.SAXParseException: Element type "Hansard" must be declared.
    org.xml.sax.SAXParseException: Element type "Session" must be declared.
    org.xml.sax.SAXParseException: Element type "DailyRecord" must be declared.
    org.xml.sax.SAXParseException: Element type "Volume" must be declared.
    org.xml.sax.SAXParseException: Element type "Written" must be declared.
    org.xml.sax.SAXParseException: Element type "WrittenHeading" must be declared.
    org.xml.sax.SAXParseException: Element type "Introduction" must be declared.
    … continues for all the elements in the doc
    2005-01-28 10:24:10,519 [DEBUG] [file] - XML file is valid XML? false
    2005-01-28 10:24:10,519 [WARN ] [file] - Daily Part file 'cw501205.wa1.xml' was not valid XML and was not processed.
    Has anybody seen this behavior before with weblogic and if so how have you resolved the issue.
    Thanks in Advance
    Adam

    Hi David,
    I have checked the ejb-jar.xml file and there is no duplicate values in it and the other things is that the same application is been deployed on OAS 10G and websphere and its working fine. In the forum someone has replied to a similar problem that there is bug in Weblogic 10.3 and its CR no 376292. I am not sure about it, does anyone any information about it.
    Thanks and Regards
    Deepak Dani

  • Strange problem when validating XML agains DTD file.

    Dear experts,
    I'm write a simple code snippet that validates my XML file agains a given DTD.
    It allways report the following error:
    org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
         at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
         at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)Althought, my xml file is OK with Xmlspy.
    My code is:
    System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                             "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          factory.setNamespaceAware(true);
          factory.setValidating(true);
          factory.setAttribute(
              "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
              "http://www.w3.org/2001/XMLSchema");
          factory.setAttribute(
              "http://java.sun.com/xml/jaxp/properties/schemaSource", SchemaUrl);
          DocumentBuilder builder = factory.newDocumentBuilder();
          Validator handler = new Validator();
          builder.setErrorHandler(handler);
          builder.parse(new java.io.FileInputStream(new java.io.File(XmlDocumentUrl)));And here are the xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE capsule SYSTEM "c:/SampleFiles/capsule.dtd">
    <capsule>
         <header>
              <name>Capsule 1</name>
              <author>Author</author>
              <company>Company</company>
              <last-save-time>Fri Apr 01 14:59:21 GMT+07:00 2005</last-save-time>
              <description>description</description>
         </header>
         <datasets>
              <dataset type="input">
                   <name>dataset1</name>
                   <description></description>
                   <columns>
                        <column type="fromsource">
                             <name>partno</name>
                             <data-type>varchar</data-type>
                             <length>80</length>
                             <precision/>
                             <scale/>
                             <allow-null>false</allow-null>
                             <default-value/>
                        </column>
                        <column type="notfromsource">
                             <name>balanceonhand</name>
                             <data-type>integer</data-type>
                             <length/>
                             <precision/>
                             <scale/>
                             <allow-null>false</allow-null>
                             <default-value/>
                        </column>
                   </columns>
                   <rule>LET a=update; LET b=employye set salary = 100; print a + b</rule>
                   <!--output: update employee set salary = 100-->
                   <command>inmemory (getvalue_dataset("dataset1".rule))</command>
                   <params>
                        <param>
                             <name/>
                             <type/>
                        </param>
                   </params>
              </dataset>
         </datasets>
    </capsule>What I can do now? Change my xml file?
    Please provide some hints.
    Thanks in advance.

    I tried to remove the DOCTYPE, but the problem stayed the same.
    Thanks.

  • Regarding validating XML against DTD

    hello,
    In my project I am receiving xml via HTTP post request
    and this XML needs to be validated against a DTD in a remote server.
    e.g. assume the xml to be
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE PUSH SYSTEM "http:\\whatever:xx\whatever\sms.dtd">
    <PUSH ICP="Partenaire" ADM="UtilisateurChezPartenaire" VERSION="1.0">
    </PUSH>
    the java code uses Xerces parser
          DOMParser parser = new DOMParser();
          parser.setFeature("http://xml.org/sax/features/validation", true);
          parser.setProperty(
                             "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
                             "http:\\whatever:xx\whatever\sms.dtd"");
          parser.parse("c://localcopy/sms.xml");this Works fine.
    But in some case I receive xml file without any !DOCTYPE declaration
    (but is still needs to be validated against the same DTD as its mentioned in the business rules)
    in such case how can the XML be validated against the DTD.
    am I extected to add the
    <!DOCTYPE PUSH SYSTEM "http:\\whatever:xx\whatever\sms.dtd">
    to every XML via some XSLT script or is there a direct way of
    validating a xml that has no DOCTYPE reference to a DTD
    (the assumption is the DTD location is known beforehand)

    ok, i managed to solve the problem my self, using Transformer makes the job easier.
    here is the code for anyone who might run into the same problem.#
         public void whatEver(){
              try{
                   DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
                   DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
                   Document xmlDocument = dBuilder.parse(new FileInputStream("c://a.xml"));
                   DOMSource source = new DOMSource(xmlDocument);
                   //StringWriter writer = new StringWriter();
                   StreamResult result = new StreamResult("c://a.xml");
                   TransformerFactory tf = TransformerFactory.newInstance();
                   Transformer transformer = tf.newTransformer();
                   transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "./transformations/Push_Gateway.dtd");
                   //TransformerFactory transformerFactory = TransformerFactory.newInstance();
                   //Transformer newtransformer = transformerFactory.newTransformer();
                   transformer.transform(source, result);
              catch(Exception e){
                   e.printStackTrace();
         }the above code reads the a.xml file and adds/removes the DOCTYPE as specified in the transformer.setOutputProperty method and the same xml file is updated, this way different DTD could be referenced by the same xml and validated. this saves the process of adding/removing DOCTYPE via xslt.

  • Parse xml file with validating againat dtd

    i have a xlm file looks like:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE map SYSTEM "map.dtd">
    <map width="20" height="15" goal="25" name="eXtreme Labyrinth of Dooom">
    <random-item type='lantern' amount='5' />
    <random-item type='health' amount='10' />
    <tile x="14" y="0" type="wall">
    <renderhint>wall:rock,cracked</renderhint>
    </tile>
    <tile x="15" y="0" type="wall" />
    <tile x="16" y="0" type="floor">
    <renderhint>floor:marble,cracked</renderhint>
    </tile>
    <tile x="17" y="0" type="floor">
    <renderhint>floor:stone,rubble</renderhint>
    </tile>
    <tile x="18" y="0" type="floor" />
    <tile x="0" y="1" type="floor" />
    <tile x="1" y="1" type="floor" startlocation="1" />
    <tile x="2" y="1" type="floor" />
    <tile x="3" y="1" type="floor">
    <item type="treasure">Bar of Silver</item>
    <renderhint>floor:stone,blood</renderhint>
    </tile>
    <tile x="4" y="1" type="wall" />
    <tile x="5" y="1" type="wall" />
    <tile x="6" y="1" type="wall">
    <renderhint>wall:bricks,cracked</renderhint>
    </tile>
    </map>and a dtd document like:
    <!ELEMENT map (random-item+, tile+)>
    <!ATTLIST map
    width CDATA #REQUIRED
    height CDATA #REQUIRED
    goal CDATA #REQUIRED
    name CDATA #REQUIRED
    <!ELEMENT random-item EMPTY>
    <!ATTLIST random-item
    type (armour|health|sword|treasure|lantern) #REQUIRED
    amount CDATA #REQUIRED
    <!ELEMENT tile (item|renderhint)*>
    <!ATTLIST tile
    x CDATA #REQUIRED
    y CDATA #REQUIRED
    type (exit|floor|wall) #REQUIRED
    startlocation CDATA #IMPLIED
    <!ELEMENT item (#PCDATA)>
    <!ATTLIST item
    type (armour|health|sword|treasure|lantern) #REQUIRED
    <!ELEMENT renderhint (#PCDATA)>i need to validate the xml file against the dtd document and parse it to java using DOM.
    Can anyone give ma any suggestions on how to do it?
    thank you

    i have started my coding like:
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.*;
    import org.xml.sax.SAXException;
    import java.io.*;
    class loadxml
        public static void main(String[] args)
         try {
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              factory.setValidating(true);
              factory.setIgnoringElementContentWhitespace(true);
              DocumentBuilder parser = factory.newDocumentBuilder();
              Document doc = parser.parse(new File("hallways.xml"));
              loadxml load = new loadxml();
              load.parseNode(doc);
         } catch (ParserConfigurationException e) {
              e.printStackTrace();
         } catch (SAXException e) {
              e.printStackTrace();
         } catch (IOException e) {
              e.printStackTrace();
        public void parseNode (Node node) throws IOException
               // here is where i have problem with
    }since in my xml file, i have got ATTLIST, this ready confuses me when i try to coding it.
    Can anyone help me, please.
    Thank you.
    Edited by: mujingyue on Mar 12, 2008 3:10 PM

  • XML validation problem

    hi,
    i am trying to validate an xml document against a schema document abnd am getting some strange validation errors. i am using xerces to parse. here are my java classes:-
    //---------------------------------------- class Validation-------------------------------------------//
    import org.apache.xerces.parsers.DOMParser;
    public class Validation {
    public static void main(String[] args)
    try
    DOMParser parser = new DOMParser();
    parser.setFeature("http://xml.org/sax/features/validation", true);
    parser.setProperty(
    "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation","country.xsd");
    ErrorChecker errors = new ErrorChecker();
    parser.setErrorHandler(errors);
    parser.parse("country.xml");
    } // end try
    catch (Exception e)
    System.out.print("Problem parsing the file.");
    } // end catch          
    } // end main
    } // end class Validation
    //----------------------------------------- class ErrorHandler -----------------------------------------//
    import org.xml.sax.*;
    public class ErrorChecker implements ErrorHandler
    public void warning(SAXParseException exception)
    //Ignore warnings
    public void error(SAXParseException e)
    // A validity error.
    System.out.println("Vaidation error: " + e.getMessage());     
    public void fatalError(SAXParseException e)
    // A well-formedness error
    System.out.println("Fatal error: " + e.getMessage());
    } // end class ErrorChecker
    and here is my xml document, called "country.xml":-
    <?xml version="1.0"?>
    <country
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="country.xsd">
    <name>France</name>
    <pop>59.7</pop>
    </country>
    and my schema, called "country.xsd":-
    <?xml version="1.0"?>
    <xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="country">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="name" type="xs:string"/>
    <xs:element name="pop" type="xs:decimal"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    and here are the validation errors that are caught when i try to parse the xml document:-
    Vaidation error: Document is invalid: no grammar found.
    Vaidation error: Document root element "country", must match DOCTYPE root "null".
    could anyone please shed any light on these validation errors? any help much appreciated.
    thanks,
    ramsey

    I managed to get it working with the DOM parser. Just in case anyone else has this problem in the future and checks this thread, here is the solution. The problem basically came down to me using
    parser.setFeature("http://apache.org/xml/features/validation", true);
    instead of
    parser.setFeature("http://xml.org/sax/features/validation", true);
    When you replace the word "xml" with "sax" in the above it seems to work. So, basically all you need is:-
    // enable validation in pipeline
    parser.setFeature("http://xml.org/sax/features/validation", true);
    // set validator to schema validation
    parser.setFeature("http://apache.org/xml/features/validation/schema", true);
    And, if you haven't given the schema location inside the XML document itself, then you also need something like the following:-
    // this feature needs to be set to true if the schema
    // location is NOT hardcoded into the xml document
    parser.setProperty("
    http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", "country.xsd");
    Thanks for all your help dvohra09, you definitely pointed me in the right direction of looking into the setFeatures() method in more detail.

  • XML validation: how to check ALL validation problem for XHTML

    I have a lot of documents in HTML format (not very good) that I would like to convert in XML (XHTML). I know it is not so easy and I would use this strategy in a Java program:
    1. Try to check the well-formness and validation with a XML parser (SAX or Xerces)
    2. If not valid: try to individuate ALL the problems the file has (*and not only the first one that halts the processing process*)
    3. Try to transform the HTML to a validable XHTML with some approach: regular expression or other methods
    So the questions I do to you are the following:
    1. What XML parser do you think is the best for this purposes? SAX or Xerces?
    2. How can I understand what are all the validation problems in the file and not only the first one (If I remember well XML parsers halt the parsing process at the first error...)?
    3. How can I transform the HTML to a valid XHTML? I have only to use RegEx or is there other tools to do this for XHTML and HTML problem?
    Thanks
    r
    Edited by: robertobat on Feb 21, 2009 7:09 PM

    >
    1. Neither of them. (Disregarding the fact that SAX and Xerces aren't in the same category and don't cover all the possibilities.I would say SAX default implementation in JRE and SAX parser in Xerces.
    2. I think you have "valid" and "well-formed" confused. And HTML isn't a dialect of XML so the idea of trying to use an XML parser to handle HTML isn't a good idea.I know very well what is the difference between valid and well-formed but I've used "validation" to represent all the conversion problem. But you are right. I'm convincing myself that using a XML parser as the first step is not a good idea.
    3. Well, this is the real question, isn't it? Those other two were just a waste. Don't screw about with regex, for one thing it doesn't work well for hierarchical structures and for another you won't finish in a finite time. Just use an HTML parser which can produce a DOM, like TagSoup for example. Or run them through HTMLTidy. You could also submit them to one of the internet sites which will validate XHTML for you.I've seen Tidy and its capability to convert an HTML to a XHTML and I think it is better then TagSoup because I have to implement this mechanism in a production environment and I want to use only open source projects that have a very long story and that are strong. But I'll see TagSoup as you say.
    I cannot use an Internet service to convert millions of private documents.

  • Org.xml.sax.SAXParseException: File "..\contents.dtd" not found.

    I have an xml file that has to be parsed in my application, without changing the XML. I don't have the dtd that is mentioned in the XML file.
    The code i am using to parse the xml into a Document is
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(false);
    System.out.println("Factory=" + factory.isValidating());
    DocumentBuilder builder = factory.newDocumentBuilder();
    builder.setEntityResolver(new XMLResolver());
    System.out.println("DocBuilder=" + builder.isValidating());
    Document doc = builder.parse(xml.getInputStream());
    System.out.println("doc=" + doc);
    if (doc == null) {
    return;
    The XML file is
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE contentspace SYSTEM "..\contents.dtd" [
    ]>
    <contentspace validdtd="0.0.2">
    <emscombicategory emscombisubtype="EMSCOLLECTION">
    <default name="lugares" description="lugares"/>
    <emscombi>
    <default name="alemania" description="Alemania"/>
    <commondetails copyrightowner="TME" copyright="COPYRIGHTED" price="" validfrom="" validto="" provider="terramobile" globalcontentid="ECOLL"/>
    <previewedbinarycontent preview="alemania.GIF">
    <binarycontent binarydata="alemania.OTA"/>
    </previewedbinarycontent>
    <emsringtone>
    <default name="alema" description="Himno de Alemania"/>
    <commondetails copyrightowner="TME" copyright="FREE" price="" validfrom="" validto="" provider="terramobile" globalcontentid="TMEEMEL"/>
    <previewedbinarycontent preview="alema.WAV">
    <binarycontent binarydata="alema.OTA"/>
    </previewedbinarycontent>
    <ringtonedetails composer="Tradicional" performer="Tradicional"/>
    </emsringtone>
    <emspicture>
    <default name="birra" description="Cerveza alemana"/>
    <commondetails copyrightowner="TME" copyright="COPYRIGHTED" price="" validfrom="" validto="" provider="terramobile" globalcontentid="TMEEPM"/>
    <emspicturedetails width="32" height="32">
    <previewedbinarycontent preview="birra.GIF">
    <binarycontent binarydata="birra.OTA"/>
    </previewedbinarycontent>
    </emspicturedetails>
    </emspicture>
    </emscombi>
    </emscombicategory>
    </contentspace>
    When i run this through it throws an exception with the message
    org.xml.sax.SAXParseException: File "..\contents.dtd" not found.
    I thought by setting factory.setValidating(false) it would not read the DTD, but it does.
    Is there any way to make the document model NOT attempt to read the DTD ???

    setValidating(false) has no effect on checking against the DTD.
    create your own EntityResolver rather than using new XMLResolver(): in this resolver divert the call to the DTD on an empty XML document.
    i have shown how to do so in another thread, just run a search on this forum (this hint is valid for any question btw)

  • XML DTD Validation

    Hello,
    In my application I need to perform some XML validation against an DTD file.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE Properties SYSTEM "MyFile.dtd">
    <Properties>
    <Property name="a" value="a1"/>
    </Properties> Both XML file and the DTD are located in the same folder.
    What I need, is to perform the XML validation against the DTD file from another location(more precisely, a DTD located in my application's jar) instead of the DTD from the same folder as XML file.
    The reason for this is because the remote DTD file is most probably outdated.
    This is how I do the validation curentlly:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    builder.setErrorHandler(new org.xml.sax.ErrorHandler()
    Document xmlDocument = builder.parse(destinationXMLFile.toURI().toString());
    DOMSource source = new DOMSource(xmlDocument);
    StreamResult result = new StreamResult(System.out);
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer transformer = tf.newTransformer();
    transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "MyFile.dtd");
    transformer.transform(source, result);Someone any idea?
    Thanks,
    johnny

    Unusual but if you need this way your application just must to implement EntityResolver that always points to resource DTD.
    []s

  • Xml schema validation problem

    Hi All
    How to tackle this xml schema validation problem
    i am using the sample code provided by ORacle technet for xml
    schema validation in the Oracle database(817).
    The sample code works perfectly fine.
    Sample as provided by http://otn.oracle.com/tech/xml/xdk_sample/archive/xdksample_093001.zip.
    It works fine for normal xml files validated against
    xml schema (xsd)
    but in this case my validation is failing . Can you let me know why
    I have this main schema
    Comany.xsd
    ===========
    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.company.org"
    xmlns="http://www.company.org"
    elementFormDefault="qualified">
    <xsd:include schemaLocation="Person.xsd"/>
    <xsd:include schemaLocation="Product.xsd"/>
    <xsd:element name="Company">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="Person" type="PersonType" maxOccurs="unbounded"/>
    <xsd:element name="Product" type="ProductType" maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    ================
    which includes the following 2 schemas
    Product.xsd
    ============
    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <xsd:complexType name="ProductType">
    <xsd:sequence>
    <xsd:element name="Type" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    ==============
    Person.xsd
    ===========
    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <xsd:complexType name="PersonType">
    <xsd:sequence>
    <xsd:element name="Name" type="xsd:string"/>
    <xsd:element name="SSN" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    =================
    now when i try to validate a xml file against Company.xsd
    it throws an error saying unable to find Person.xsd.
    no protocol error
    Now where do i place these 2 schemas(.xsd files) Person & product
    so that the java schemavalidation program running inside Oracle
    database can locate these files
    Rgrds
    Sushant

    Hi Jinyu
    This is the java code loaded in the database using loadjava called by a wrapper oracle stored procedure
    import oracle.xml.parser.schema.*;
    import oracle.xml.parser.v2.*;
    import java.net.*;
    import java.io.*;
    import org.w3c.dom.*;
    import java.util.*;
    import oracle.sql.CHAR;
    import java.sql.SQLException;
    public class SchemaUtil
    public static String validation(CHAR xml, CHAR xsd)
    throws Exception
    //Build Schema Object
    XSDBuilder builder = new XSDBuilder();
    byte [] docbytes = xsd.getBytes();
    ByteArrayInputStream in = new ByteArrayInputStream(docbytes);
    XMLSchema schemadoc = (XMLSchema)builder.build(in,null);
    //Parse the input XML document with Schema Validation
    docbytes = xml.getBytes();
    in = new ByteArrayInputStream(docbytes);
    DOMParser dp = new DOMParser();
    // Set Schema Object for Validation
    dp.setXMLSchema(schemadoc);
    dp.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    dp.setPreserveWhitespace (true);
    StringWriter sw = new StringWriter();
    dp.setErrorStream (new PrintWriter(sw));
    try
    dp.parse (in);
    sw.write("The input XML parsed without errors.\n");
    catch (XMLParseException pe)
    sw.write("Parser Exception: " + pe.getMessage());
    catch (Exception e)
    sw.write("NonParserException: " + e.getMessage());
    return sw.toString();
    This is the code i used initially for validating a xml file against single xml schema (.xsd) file
    In the above code could u tell how to specify the second schema validation code for the incoming xml.
    say i create another Schemadoc for the 2nd xml schema.
    something like this with another parameter(CHAR xsd1) passing to the method
    byte [] docbytes1 = xsd1.getBytes();
    ByteArrayInputStream in1 = new ByteArrayInputStream(docbytes1);
    XMLSchema schemadoc1 = (XMLSchema)builder.build(in1,null);
    DOMParser dp = new DOMParser();
    How to set for the 2nd xml schema validation in the above code or can i combine 2 xml schemas.
    How to go about it
    Rgrds
    Sushant

Maybe you are looking for