Documentbuilder and VerifyError

Hi,
I'm a beginner in programming java and xml. So i have maybe a simple question!
In my code, I get an VerifyError and I don't know how to handle this one! Can anybody help!? Thanks!!
public void create() {
try {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setErrorHandler(handler);
document = builder.parse(xmlFile);
catch (FactoryConfigurationError e) {
// unable to get a document builder factory
catch (ParserConfigurationException e) {
// parser was unable to be configured
catch (SAXException e) {
// parsing error
catch (IOException e) {
// i/o error
java.lang.VerifyError: Cannot inherit from final class
     at java.lang.ClassLoader.defineClass0(Native Method)
     at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
     at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
     at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
     at org.apache.xerces.impl.XMLNSDocumentScannerImpl.createContentDispatcher(Unknown Source)
     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.<init>(XMLDocumentFragmentScannerImpl.java:249)
     at org.apache.xerces.impl.XMLDocumentScannerImpl.<init>(XMLDocumentScannerImpl.java:245)
     at org.apache.xerces.impl.XMLNSDocumentScannerImpl.<init>(Unknown Source)
     at org.apache.xerces.parsers.IntegratedParserConfiguration.createDocumentScanner(Unknown Source)
     at org.apache.xerces.parsers.DTDConfiguration.<init>(DTDConfiguration.java:367)
     at org.apache.xerces.parsers.StandardParserConfiguration.<init>(StandardParserConfiguration.java:198)
     at org.apache.xerces.parsers.IntegratedParserConfiguration.<init>(Unknown Source)
     at org.apache.xerces.parsers.IntegratedParserConfiguration.<init>(Unknown Source)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
     at java.lang.Class.newInstance0(Class.java:306)
     at java.lang.Class.newInstance(Class.java:259)
     at org.apache.xerces.util.ObjectFactory.newInstance(ObjectFactory.java:266)
     at org.apache.xerces.util.ObjectFactory.findJarServiceProvider(ObjectFactory.java:360)
     at org.apache.xerces.util.ObjectFactory.createObject(ObjectFactory.java:185)
     at org.apache.xerces.util.ObjectFactory.createObject(ObjectFactory.java:120)
     at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
     at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
     at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(DocumentBuilderImpl.java:102)
     at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(DocumentBuilderFactoryImpl.java:88)
     at verwaltungsprog.xmlParser.Data_XML_Parser.create(Data_XML_Parser.java:49)
     at verwaltungsprog.xmlParser.Data_XML_Parser.<init>(Data_XML_Parser.java:35)
     at verwaltungsprog.xmlParser.Data_XML_Parser.main(Data_XML_Parser.java:132)

"replace xercesImpl.jar under %Tomcat_Home%/common/endorsed with the one included with Xalan-Java."
http://xml.apache.org/xalan-j/samples.html

Similar Messages

  • WAR files (Tomcat) and deployment descriptor

    Hello,
    I am currently writing a small utility to package a web application for Jakarta Tomcat as a .war file.
    I have a functional version that imports the deployment descriptor web.xml, but I'd like to make it possible for the user to edit or create from scratch that file. I use the DOM API to make a logical model of my web.xml, but the parser won't accept the external dtd definition :
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    Here is my parser :
    private void parse(File in) {
    try {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setValidating(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    document = builder.parse(in); (((*)))
    catch (...)
    }//parse
    ---------------------------------------------It seems I have no further controls on DocumentBuilder and DocumentBuilderFactory.
    The builder.parse call generates this exception :
    java.net.NoRouteToHostException: Operation timed out: no further information
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at org.apache.crimson.parser.Resolver.resolveEntity(Resolver.java:389)The problem seems to be located in DOM's DefaultHandler entity resolver, but I don't ee clearly what to do.
    Thanks for helping.

    Hi,
    I already tried every combination of settings with
    DocumentBuilderFactory.setNamespaceAware
    DocumentBuilderFactory.setValidating
    DocumentBuilderFactory.setCoalescing
    DocumentBuilderFactory.ExpandEntityReferencesI had the same result. Here is the exact dump :
    java.net.NoRouteToHostException: Operation timed out: no further information
            at java.net.PlainSocketImpl.socketConnect(Native Method)
            at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:312)
            at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:125)
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:112)
            at java.net.Socket.<init>(Socket.java:273)
            at java.net.Socket.<init>(Socket.java:100)
            at sun.net.NetworkClient.doConnect(NetworkClient.java:50)
            at sun.net.www.http.HttpClient.openServer(HttpClient.java:331)
            at sun.net.www.http.HttpClient.openServer(HttpClient.java:517)
            at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
            at sun.net.www.http.HttpClient.<init>(HttpClient.java:277)
            at sun.net.www.http.HttpClient.New(HttpClient.java:289)
            at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
    .java:379)
            at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:472)
            at org.apache.crimson.parser.Resolver.resolveEntity(Resolver.java:389)
            at org.apache.crimson.parser.ExternalEntity.getInputSource(ExternalEntit
    y.java:88)
            at org.apache.crimson.parser.Parser2.pushReader(Parser2.java:2986)
            at org.apache.crimson.parser.Parser2.externalParameterEntity(Parser2.jav
    a:2721)
            at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1154)
            at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:488)
            at org.apache.crimson.parser.Parser2.parse(Parser2.java:304)
            at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:433)
            at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl
    .java:179)
            at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:161)
            at DOMView.main(DOMView.java:96)This shows that the entity resolver tries to access the distant DTD, so I tried to implement myself the EntityResolver interface, but I didn't well understood
    what to do with that InputStream it has to return.

  • XML parsing with DocumentBuilder

    Hi,
    I use to parse an XML document using DocumentBuilder and Document objects.
    When i have within my XML document the following line :
    <value>MY_VALUE</toto>
    How can i get the value "MY_VALUE" using Node objects without searching elements by tag name or criteria ???
    Chris

    Parse document with dom4j parser and get the tag value with xpath.
    http://www.dom4j.org/guide.html

  • DocumentBuilderFactory and my applet

    I am creating an applet that will read an XML file and parse the file to grab some info. I created the project in netbeans and i'm using the java.xml.parsers.DocumentBuilder and java.xml.parsers.DocumentBuilderFactory classes to do the work. When i run the applet and the config file is found it is read in just fine in the browser but i get a dozen errors in my server log saying "No route matches "/META-INF/services/javax.xml.parsers.DocumentBuilderFactory" with {:method=>:get}". This is bad because it makes the web app think an error occurred and it will spam our error email address. Is there something wrong with how i'm creating my applet or is this an issue with the web application?
    Thank you,
    Austin

    Appetviewer fails on my applet:
    runrun sun.applet.Main Pancet.class
    Set uncaught java.lang.Throwable
    Set deferred uncaught java.lang.Throwable
    >
    VM Started:
    The application exited
    yet it ran fine when I created it in JBuilder. Does
    appletviewer require a "main" method? No.
    My applet does
    implement "runnable". Does the fact that I haven't
    yet coaxed Mozilla into accepting the latest java
    plugin have barring on the problem (this would seem
    unlikely to me)? No, don't think so. Sounds like an uncaught exception to me. Maybe a security exception? What's the applet doing?

  • Error creating AIR file

    When I try to Publish to AIR file,
    Error Creating AIR file.
    The swf file specified as root content is missing.
    error is shown.
    When I run the Publish Project from the Project Panel in Flash CS4,
    The same error as earlier is obtained:
    Error Creating AIR file.
    The swf file specified as root content is missing.
    and:
    VerifyError: Error #1014: Class flash.filesystem::File could not be found.
        at global$init()
    my application has a TextArea control in the library added to stage via actionscript (2 textarea instances).
    2 folders in applicationStorageDrectory with a database in one.The other folder will get populated with files at runtime only.
    Am I missing some thing?
    Please help me.

    I solved it.
    I changed the .fla to a new folder and things works fine.
    The reason I suppose is with the project settings in the project panel in flash.
    So this time didn't add any project to the project panel.
    Thank You.

  • Urgent: How to get value from Element Node?

    Hi All,
    I have an xml like below:
    <?xml version="1.0"?>     
    <Accounts>
    <Account rowid="1">
    <Account_Id>1</Account_Id>
    <Customer_Id>1</Customer_Id>
    <Account_Type>SB</Account_Type>
    <Balance>1000.00</Balance>
    </Account>
    <Account rowid="2">
    <Account_Id>2</Account_Id>
    <Customer_Id>1</Customer_Id>
    <Account_Type>CD</Account_Type>
    <Balance>1000.00</Balance>
    </Account>
    </Accounts>
    I am trying to get the value in the Account_Id element, but I am getting null everytime. Here is my code:
    import com.sun.org.apache.xerces.internal.impl.xs.dom.DOMParser;
    DOMParser parser = new DOMParser();
    parser.parse("D:\\Temp\\PCORDBMS\\"+tableName+".xml");
    Document doc = parser.getDocument();
    NodeList nodes = doc.getElementsByTagName("Account");
    for(int i=0;i<nodes.getLength();i++) {
    Node fc=nodes.item(i).getFirstChild();
    System.out.println(fc.getNodeValue());
    I think, since fc node is of the type Element - getNodeValue() is not returning the value. I also tried getting child nodes, getting attributes for fc & then getNodeValue.
    Am I missing something? Appreciate your help.
    Thanks,
    Niranjan

    Hi Niranjan,
    I used the JAXP DocumentBuilder and DocumentBuilderFactory classes. I use JSE 5.
    Here's the complete code that works for me:
    package com.trfsol.domtester;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    public class DomTester {
         * @param args
         public static void main(String[] args) {
              String filename = "C:\\Java workspaces\\Eclipse\\Workspace\\Test\\test.xml";
              try {
                   // Parse XML file
                   DocumentBuilderFactory factory =
                        DocumentBuilderFactory.newInstance();
                   DocumentBuilder parser = factory.newDocumentBuilder();
                   Document document = parser.parse(filename);
                   // Get all "Account" nodes
                   NodeList accountNodes = document.getElementsByTagName("Account");
                   // Iterate over nodes
                   for (int index = 0; index < accountNodes.getLength(); index ++) {
                        NodeList childNodes = accountNodes.item(index).getChildNodes();
                        for (int subIndex = 0; subIndex < childNodes.getLength(); subIndex ++) {
                             Node childNode = childNodes.item(subIndex);
                             System.out.println(childNode.getTextContent());
              catch (Exception e) {
                   System.err.println("Exception: " + e.getMessage());
    Regards, Ronald

  • Validating a digital signature in an xml

    Hi,
    Im working on validating a digital signature from an xml file . Im using the below code to get the value of signature node from the xml file.
    NodeList nl = doc.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature");
    I'm getting it as nodelist object . When i try to get the length of the signature element it says 0 and hence it throws me an exception .
    I have to pass this nodeliest object to validate the xml file. Im attaching the xml file as well as the progarm to validate the xml file . Can somebody help me on this.
    Validate.java
    import javax.xml.crypto.*;
    import javax.xml.crypto.dsig.*;
    import javax.xml.crypto.dom.*;
    import javax.xml.crypto.dsig.dom.DOMValidateContext;
    import javax.xml.crypto.dsig.keyinfo.*;
    import java.io.File;
    import java.io.FileInputStream;
    import java.security.*;
    import java.util.Collections;
    import java.util.Iterator;
    import java.util.List;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.NodeList;
    * This is a simple example of validating an XML
    * Signature using the JSR 105 API. It assumes the key needed to
    * validate the signature is contained in a KeyValue KeyInfo.
    public class Validate {
    public static void main(String[] args) throws Exception {
    try
    File file = new File("c:\\test.xml");
    // Instantiate the document to be validated
         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         DocumentBuilder db = dbf.newDocumentBuilder();
         dbf.setNamespaceAware(true);
         //Document doc = dbf.newDocumentBuilder().parse(new FileInputStream("C://signature.xml"));
    Document doc = db.parse(file);
         // Find Signature element
    NodeList nl = doc.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature");
    System.out.println("the nodelist value is"+nl);
              if (nl.getLength() == 0) {
         throw new Exception("Cannot find Signature element");
         // Create a DOM XMLSignatureFactory that will be used to unmarshal the
         // document containing the XMLSignature
         XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
         // Create a DOMValidateContext and specify a KeyValue KeySelector
    // and document context
         //DOMValidateContext valContext = new DOMValidateContext
         // (new KeyValueKeySelector(), nl.item(0));
         DOMValidateContext valContext = new DOMValidateContext
    (new KeyValueKeySelector(), nl.item(0));
              // unmarshal the XMLSignature
         XMLSignature signature = fac.unmarshalXMLSignature(valContext);
         // Validate the XMLSignature (generated above)
         boolean coreValidity = signature.validate(valContext);
         // Check core validation status
         if (coreValidity == false) {
         System.err.println("Signature failed core validation");
         boolean sv = signature.getSignatureValue().validate(valContext);
         System.out.println("signature validation status: " + sv);
         // check the validation status of each Reference
         Iterator i = signature.getSignedInfo().getReferences().iterator();
         for (int j=0; i.hasNext(); j++) {
              boolean refValid =
              ((Reference) i.next()).validate(valContext);
              System.out.println("ref["+j+"] validity status: " + refValid);
         } else {
         System.out.println("Signature passed core validation");
    catch (Exception e)
         e.printStackTrace();
    * KeySelector which retrieves the public key out of the
    * KeyValue element and returns it.
    * NOTE: If the key algorithm doesn't match signature algorithm,
    * then the public key will be ignored.
    private static class KeyValueKeySelector extends KeySelector {
         public KeySelectorResult select(KeyInfo keyInfo,
    KeySelector.Purpose purpose,
    AlgorithmMethod method,
    XMLCryptoContext context)
    throws KeySelectorException {
    if (keyInfo == null) {
              throw new KeySelectorException("Null KeyInfo object!");
    SignatureMethod sm = (SignatureMethod) method;
    List list = keyInfo.getContent();
    for (int i = 0; i < list.size(); i++) {
              XMLStructure xmlStructure = (XMLStructure) list.get(i);
         if (xmlStructure instanceof KeyValue) {
    PublicKey pk = null;
    try {
    pk = ((KeyValue)xmlStructure).getPublicKey();
    } catch (KeyException ke) {
    throw new KeySelectorException(ke);
    // make sure algorithm is compatible with method
    if (algEquals(sm.getAlgorithm(), pk.getAlgorithm())) {
    return new SimpleKeySelectorResult(pk);
    throw new KeySelectorException("No KeyValue element found!");
    //@@@FIXME: this should also work for key types other than DSA/RSA
         static boolean algEquals(String algURI, String algName) {
    if (algName.equalsIgnoreCase("DSA") &&
              algURI.equalsIgnoreCase(SignatureMethod.DSA_SHA1)) {
              return true;
    } else if (algName.equalsIgnoreCase("RSA") &&
    algURI.equalsIgnoreCase(SignatureMethod.RSA_SHA1)) {
              return true;
    } else {
              return false;
    private static class SimpleKeySelectorResult implements KeySelectorResult {
         private PublicKey pk;
         SimpleKeySelectorResult(PublicKey pk) {
         this.pk = pk;
         public Key getKey() { return pk; }
    test.xml
    <?xml version="1.0" encoding="UTF-8"?><Signature XMLNS="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><Reference URI="#CWRT"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>VWmTb6knCBXhNjDLp6w5aX79AW4=</DigestValue></Reference><Reference URI="js/weatherData.js"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>aRyqMcnVA7UsxHaq3VPjIzKnR30=</DigestValue></Reference><Reference URI="js/accuweather.js"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>NKBau43TGuOTSwOiFLtC7xgeUxk=</DigestValue></Reference><Reference URI="js/location.js"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>SNowBnKItayjP8hVg2a+qlrNnl4=</DigestValue></Reference><Reference URI="index.html"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>ImhqtDT/KgYLUMwhzBjxo7kX16c=</DigestValue></Reference><Reference URI="images/bg_fade_current.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>6YBFwLJdH7wLSLwgheOzTgLxe0g=</DigestValue></Reference><Reference URI="images/setdefault.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>VD9Ay9DjNvHoCt4QpWI6H5gHo84=</DigestValue></Reference><Reference URI="images/bg_portrait.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>eMNhpeowX/LaxFhZ0choyWoGdnU=</DigestValue></Reference><Reference URI="images/form_bg.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>xRsfhpWI8R21vXcPd73EJ0SPg4c=</DigestValue></Reference><Reference URI="images/nav_hourly_off.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>7tBjRZQ6PC5uVRg8J5bAFTmBS4s=</DigestValue></Reference><Reference URI="images/bg_landscape.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>nTZ9DoZPW1UgjEvE3WfSBt3DdYA=</DigestValue></Reference><Reference URI="images/nav_maps_off.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>ywLUlQ+DCMuybGr2YLYDQx85jJw=</DigestValue></Reference><Reference URI="images/nav_graph_off.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>853j9KcFEpuI5c8e5+0TEpmU33U=</DigestValue></Reference><Reference URI="images/label_forecast.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>2feKnZklWElbyqItqq5Q1bZRtn4=</DigestValue></Reference><Reference URI="images/bg_fade_content_wide.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>GDFP4Tcu96NBOCo9qRw7K25l8as=</DigestValue></Reference><Reference URI="images/btn_getlocation.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>sJajd6TTV4VyB2ibMRl8hM4cV+8=</DigestValue></Reference><Reference URI="images/bg_fade_home.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>joxnBor/RV5uvqc+SiNU613+W6U=</DigestValue></Reference><Reference URI="images/label_hourly.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>uinbV5pKm/XFwNsBjI21m0tYkhs=</DigestValue></Reference><Reference URI="images/wxicons/33.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>X8HvsFhHLUr3624myAcox9QyagQ=</DigestValue></Reference><Reference URI="images/wxicons/37.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>ldJztK5xrBf3UOyRkSN9zFAootc=</DigestValue></Reference><Reference URI="images/wxicons/13.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>bAah/tMqPUVrXis2iiOZLYo4jRw=</DigestValue></Reference><Reference URI="images/wxicons/16.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>UZ2CKfWZN/FCLnILVz8bIXWlRAA=</DigestValue></Reference><Reference URI="images/wxicons/19.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>jRL/Ea5Dcj7DpvKOHnqGvUmpw4Q=</DigestValue></Reference><Reference URI="images/wxicons/18.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>76si6qIfm8bAPKBRIQCQScg0Mow=</DigestValue></Reference><Reference URI="images/wxicons/44.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>HkCAXti0I181Pjqkw2QNTjXN6/8=</DigestValue></Reference><Reference URI="images/wxicons/08.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>OAvQ6xMeMXCFznUUMZyL1frgJQk=</DigestValue></Reference><Reference URI="images/wxicons/20.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>BavTiifJ1XKhQx/AO4Y2PywHi+w=</DigestValue></Reference><Reference URI="images/wxicons/12.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>NNVCA+3eTGXWUXGjO1G4qoPPDaU=</DigestValue></Reference><Reference URI="images/wxicons/36.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>5Wy7pMJKjwc+fdL0+ez3OrhZ/WY=</DigestValue></Reference><Reference URI="images/wxicons/32.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>GrhBWg3ODd19NHkdaEyuzUDYGaQ=</DigestValue></Reference><Reference URI="images/wxicons/25.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>kVSt7ZBsrGBlnRp2mnNd4jzbjdc=</DigestValue></Reference><Reference URI="images/wxicons/29.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>CHkrsHgL9qFAKCgxQfGOaBgCg+A=</DigestValue></Reference><Reference URI="images/wxicons/17.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>SxQBu2aYDFDTD1N6XXcL/Z9r2G0=</DigestValue></Reference><Reference URI="images/wxicons/05.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>UR0ntm9xdDzhcq9m+EqdcDRhk5I=</DigestValue></Reference><Reference URI="images/wxicons/06.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>XUKHRCVRhhgG7M44QlhzFKulVf0=</DigestValue></Reference><Reference URI="images/wxicons/40.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>0vBrc/yiUz4pE8epTER19nblmCA=</DigestValue></Reference><Reference URI="images/wxicons/41.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>y5a8jOOsS/qPhcEMQV3Aufb/aNE=</DigestValue></Reference><Reference URI="images/wxicons/Thumbs.db"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>pch5wjLWZAPSgNO09d1x7SMayY=</DigestValue></Reference><Reference URI="images/wxicons/14.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>QoLGKWD8MVS0XxCvkvweDmYg1U=</DigestValue></Reference><Reference URI="images/wxicons/42.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>D9K0JzNNrtpryfckrNQNS87y1BQ=</DigestValue></Reference><Reference URI="images/wxicons/43.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>qlRMGFaqLYTej/k3k1wAGL+GWxM=</DigestValue></Reference><Reference URI="images/wxicons/04.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>a2ftn992/Hl3y1wp9IzsLSSqDdk=</DigestValue></Reference><Reference URI="images/wxicons/30.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>6Ad7HYjHxySf33JzQdS/oDTgcno=</DigestValue></Reference><Reference URI="images/wxicons/23.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>LsAfryFOtLhgviUgiOXM3z4lBAA=</DigestValue></Reference><Reference URI="images/wxicons/07.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>bV4gju3kZ780HDNOVP2lHE1TDW4=</DigestValue></Reference><Reference URI="images/wxicons/22.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>AeFmuHupwwVszEvbV94o0rngpCQ=</DigestValue></Reference><Reference URI="images/wxicons/01.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>6DsWdqkV1/ub3FaeUeXvxsQxckA=</DigestValue></Reference><Reference URI="images/wxicons/21.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>Z4W51hSrbkM5N91/F9xwDJwABb0=</DigestValue></Reference><Reference URI="images/wxicons/38.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>Jfl9KECyaQ68D0Fq2iyAHubQYJE=</DigestValue></Reference><Reference URI="images/wxicons/35.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>c1SmObYV0bMJwveQBuyOk/aHjoY=</DigestValue></Reference><Reference URI="images/wxicons/39.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>apdCy1y7Bhx4c8j8xZKpw9sLiHQ=</DigestValue></Reference><Reference URI="images/wxicons/34.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>RlUoSL1kyNF/LNHglKJojfidqDo=</DigestValue></Reference><Reference URI="images/wxicons/24.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>rp274RE36TIQ/cJqykbC1pfma64=</DigestValue></Reference><Reference URI="images/wxicons/31.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>4T9iGJPK46NYQtmGWyvMhFXqefg=</DigestValue></Reference><Reference URI="images/wxicons/15.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>V/kRSkl8RuSLp5XHkK+Ev2qkA/Q=</DigestValue></Reference><Reference URI="images/wxicons/02.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>LnzYacHZQ8dWbBsfY/xIBFf+FhY=</DigestValue></Reference><Reference URI="images/wxicons/26.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>L/fdXr1GduUly+gZoqoHtjSEeug=</DigestValue></Reference><Reference URI="images/wxicons/11.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>5tlEUU8jkLu69GjxyKrj/dlCBnE=</DigestValue></Reference><Reference URI="images/wxicons/03.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>eVam0Q5Ns+f0ivmOFlayoQjFJuQ=</DigestValue></Reference><Reference URI="images/btn_severe_on.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>xkpq8N5rnVv2QUOOPEC3t2UZ3io=</DigestValue></Reference><Reference URI="images/bg_fade_prefs.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>mGtHZB8HWR4Kr46E9ibtgPqkSjg=</DigestValue></Reference><Reference URI="images/btn_previous.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>tYsSyliuIQHfoqX8Ljjd514gjiY=</DigestValue></Reference><Reference URI="images/btn_search.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>Xs3TiHv5GVKqvqKcH4QQTLGeL5M=</DigestValue></Reference><Reference URI="images/nav_calendar_on.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>km6Jeefk1pbxhKPuKdX0tAikn20=</DigestValue></Reference><Reference URI="images/bg_fade_location.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>dsoQD4U3FStFnFCn9IU8XZOnbZ8=</DigestValue></Reference><Reference URI="images/logo_leaf.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>AI6UYnx1653B/rX71hqlXRYayK0=</DigestValue></Reference><Reference URI="images/radar.jpg"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>IEaZz7VDYcwgBHJhTFttbNpSr8=</DigestValue></Reference><Reference URI="images/btn_done.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>VZYygwwnJmzSykTWnC3UMjx7UVU=</DigestValue></Reference><Reference URI="images/Thumbs.db"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>aXryLm/7bU2iLfP6mwM96Q7iFfk=</DigestValue></Reference><Reference URI="images/btn_plus.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>apIaI0Q/XpYkQIZgrE8y4KDpe34=</DigestValue></Reference><Reference URI="images/label_calendar.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>Ek3gLnM9lZCvsJrn49FinTEFoc=</DigestValue></Reference><Reference URI="images/btn_severe_off.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>rMRQheIr8WGukddQsbW79yPUa68=</DigestValue></Reference><Reference URI="images/bg_fade_about_wide.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>exAFOiVOEx5VKUopSxkbRc3RTLc=</DigestValue></Reference><Reference URI="images/btn_removelocation.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>BAAQeIMdUoZumMexhxIJFLOXy8M=</DigestValue></Reference><Reference URI="images/label_weathermap.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>QLd8kSOk/dq9/PtPl3hycoufBGw=</DigestValue></Reference><Reference URI="images/space.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>lPyPvOmX8EoCzEM8iIruq8hfHIE=</DigestValue></Reference><Reference URI="images/btn_magnify.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>3lSDkwWlIMufqacsbJ8dShiDvPc=</DigestValue></Reference><Reference URI="images/btn_next.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>5l3/6rRyibJQXlQdSfopJ4Q9e3o=</DigestValue></Reference><Reference URI="images/bg_fade_current_wide.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>klPlC3aqn33AAxtAzDCksik4CXo=</DigestValue></Reference><Reference URI="images/nav_hourly_on.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>oW7HwXpGfcEz6q1UEixc48IuEf0=</DigestValue></Reference><Reference URI="images/btn_shrink.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>/6ORP54At9CAqkQno9aCvbXCF2E=</DigestValue></Reference><Reference URI="images/bg_cal_date.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>g10327Jhy+CE2XXE62b6Ea6cUZg=</DigestValue></Reference><Reference URI="images/key.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>anFOcEcBGzbkeEsfKJ7+y3S2Y0E=</DigestValue></Reference><Reference URI="images/degree_f.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>QtJd4lj3Gaqm59G0J6TT87N9jLk=</DigestValue></Reference><Reference URI="images/bg_fade_about.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>rYYhIG+rT3f8jPqSuzC65g2BRuE=</DigestValue></Reference><Reference URI="images/degree_c.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>0AwnOwXF+1iAySDhG6u+WKGzmEE=</DigestValue></Reference><Reference URI="images/nav_maps_on.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>B7IsyllFvqC+hrxow9QlM+IdDkQ=</DigestValue></Reference><Reference URI="images/label_graph.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>8dKb7eEM6PKj2NqpJmTIA6d4OZw=</DigestValue></Reference><Reference URI="images/bg_fade_nav.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>0gR7yxY7kUde+5gnApaniAR70c4=</DigestValue></Reference><Reference URI="images/nav_forecast_off.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>T6cSnzVZ6+NYmcJkSxagrBG34VA=</DigestValue></Reference><Reference URI="images/bg_fade_content.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>eAAeix95CFcyTRFP0L37wCTiCT4=</DigestValue></Reference><Reference URI="images/nav_calendar_off.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>+7NYqrzg6E42x4bcSmI7oR+06Ok=</DigestValue></Reference><Reference URI="images/nav_graph_on.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>IuDRMdZ5SGeHtOUrIO6N8Kz2ug0=</DigestValue></Reference><Reference URI="images/logo_accu.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>/uv3wU6UomVHWqNw6FnQYutp19g=</DigestValue></Reference><Reference URI="images/nav_forecast_on.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>x+QqY/MePBUZryW4TH5q+IF1G+g=</DigestValue></Reference><Reference URI="config.xml"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>xo9qqZXg+0DwkCx8Kks9jgMLaLA=</DigestValue></Reference><Reference URI="css/accuweather.css"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>wIZ0bV7p0RmG7GEQzl9GoN+MMEs=</DigestValue></Reference><Reference URI="icon.png"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>vReEx8PURNyRoFZDvLHfXSAW5U=</DigestValue></Reference></SignedInfo><SignatureValue>H6RxXxj0OfpZuhbNHUkm048kZ1uzlGUwQV4TadOvFJ0VKHIyjTcJgzx7ApSUmCTjg/5JaRufBjAzihXmd7UTkq+aVm8smRgHpr3puz0w2wKGhPizO0dz4qfw3U7lqV6eLgSDakRj1jnFgqcMVHI+0k5vvYeVxgUVi6bz2b+IbM=</SignatureValue><Object Id="CWRT"><SignatureProperties xmlns:dsp="http://www.w3.org/2009/xmldsig-properties" ><SignatureProperty Id="profile"><dsp:Profile URI="http://www.w3.org/ns/widgets-digsig#profile" /></SignatureProperty><SignatureProperty Id="role"><dsp:Role URI="http://www.w3.org/ns/widgets-digsig#role-distributor" /></SignatureProperty><SignatureProperty Id="identifier"><dsp:Identifier>{247220a7-f378-4151-83d3-6be32024c0ae}</dsp:Identifier></SignatureProperty></SignatureProperties></Object><KeyInfo><X509Data><X509Certificate>MIICzDCCAjWgAwIBAgIBADANBgkqhkiG9w0BAQUFADArMRAwDgYDVQQKEwdSRCBD
    ZXJ0MRcwFQYDVQQDEw5SRCBDZXJ0aWZpY2F0ZTAeFw0wNDExMTUxMjQyMDZaFw0z
    NzA5MjMxMjQyMDZaMCsxEDAOBgNVBAoTB1JEIENlcnQxFzAVBgNVBAMTDlJEIENl
    cnRpZmljYXRlMIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDLRF+r1FGGkCwT
    rb420kbnAps7gi1yYUcXYUdWeFTuBeQe5eW46Y+LWaA8HMlDdoHRB0FgASisYcFa
    gwno9+oFf4AJka4H1gWEs5XTGwAA1s0d8XGh7W7Dt9F5FZij8F7/9Pi6+FhhxZFI
    f1DD+yry9D7+Sp+BgdNALe4XOpf25QIBA6OCAQAwgf0wDAYDVR0TBAUwAwEB/zAL
    BgNVHQ8EBAMCAoQwHQYDVR0OBBYEFFi/kuGzxhVpjGxe9ZwlxC3fH9jFMFMGA1Ud
    IwRMMEqAFFi/kuGzxhVpjGxe9ZwlxC3fH9jFoS+kLTArMRAwDgYDVQQKEwdSRCBD
    ZXJ0MRcwFQYDVQQDEw5SRCBDZXJ0aWZpY2F0ZYIBADBsBgNVHSAEZTBjMGEGBFUd
    IAAwWTATBggrBgEFBQcCARYHaHR0cDovLzBCBggrBgEFBQcCAjA2GjRGb3IgUiZE
    IHVzYWdlIG9ubHkuIFRoaXMgY2VydGlmaWNhdGUgaXMgbm90IHRydXN0ZWQuMA0G
    CSqGSIb3DQEBBQUAA4GBAHGB4RQMAgBdeT2hxfOr6f2nA/dZm+M5yX5daUtZnET9
    Ed0A9sazLawfN2G1KFQT9kxEParAyoAkpbMAsRrnRz/9cM3OHgFm/NiKRnf50DpT
    7oCx0I/65mVD2kt+xXE62/Ii5KPnTufIkPi2uLvURCia1tTS8JmJ8dtxDGyQt8BR</X509Certificate></X509Data></KeyInfo></Signature>

    >
    // Instantiate the document to be validated
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    dbf.setNamespaceAware(true);
    Document doc = db.parse(file);Your problem is that you've instantiated the DocumentBuilder before you've made the factory namespace aware. As a result, does not know against which namespace it is parsing the XML file.
    Change the lines of code to have the factory be namespace-aware before you instantiate the DocumentBuilder and then parse the class. You'll get past your "node not found" error to receive a number of other errors which you need to correct.
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    Document doc = dbf.newDocumentBuilder().parse(file);As a practice when generating an XML document, you should try to validate it inside an IDE like Netbeans/Eclipse before trying to do anything with the document to ensure you've not only got a well-formed XML document, but also one that is "schema-conformant. Your XML signature is not (the Object element cannot come before the KeyInfo element, and the SignatureProperty element is missing the required Target attribute); as a result your Signature element will fail to pass validation even if your code is correct. A cursory review of the XML Signature specs and its XSD is always helpful: [http://www.w3.org/TR/xmldsig-core/].
    Finally, please use the {code} tag for source-code to make it readable. Thanks.
    Arshad Noor
    StrongAuth, Inc.

  • Implementing DOM Interface with existing Java classes

    I had planned on using some tree-like Java classes as a Document Object Model, which would give me access to all sorts of XML and DOM tools like parsers and XSLT transformers. Initially, I thought all that would be neccessary is to implement all the DOM Interfaces in org.w3c.dom and then I would have a set of classes that conformed to DOM Level 1. It was my understanding that interfaces such as DOMImplementation and Document would interface with various XML tools, allowing creation of a class that implements Document and then Document would have its various factory methods that know how to create the various DOM nodes such as Element, Attr, Text, NamedNodeMap, NodeList, etc.
    The problem I'm seeing now is that the JAXP specification (which is what the latest Xerces and Xalan tools conform to) has something called a DocumentBuilder and DocumentBuilderFactory that appear to be necessary to tell the framework what type of class to instantiate that implements the Document DOM interface. Those appear to have a lot of methods that deal with parsing of XML documents and I didn't really want to write or even subclass any existing Parsers in order to get the functionality of traversing and transforming a set of classes that implement the DOM interface.
    Am I missing something here? Is it possible to plug in any (set of classes for) DOMImplementation and get them to work with the various DOM and XML tools out there?
    Is there an easier way to allow parts of an application access to internal data structures but have the more generic tools or APIs, such as XSL transformers, access that same set of classes as a DOM with the generic DOM interface methods?
    Can someone provide me with some guidance here? I'm in the process of finalizing some design on a system and need to know if this is possible or if I need to alter my design.
    Thanks.

    If I understand you correctly, I think I am working on a similar issue. I am unhappy with the methods given by the DOM for retrieving data from the XML file and for building a file. Our software has a bunch of code that uses these classes and it is extremely ugly. My solution was to create a facade on top of the DOM model. Essentially I have some simple classes that store all the pertinent info (for me) about the XML structure. Essentially that is the element or attribute name, its values and in the case of the element, it's children. This makes it easier for me to build and retreive the data. What I then built was a loader class and a builder class. The loader takes an XML file and parses it in using the DOM classes and builds a structure using my classes and returns the root element. The builder takes a root element and creates a DOM object out of it. This frees me of having to code around the DOM classes all over the place and makes it simple to upgrade our XML code if the DOM changes or a better DOM is released. I am using factories to facilitate this and allow me to have loaders for specific types of XML documents so that I can have a class for each which further simplifies the XML related tasks of other developers on my team.

  • Exception using JAXP transformer on non-default DOM

    Hi!
    I have a problem with the JAXP integration of my own DOM implementation. I've written a compressed core level 1 DOM implementation and integrated it into JAXP by writing a DocumentBuilder and a DocumentBuilderFactory class. Although not 100% of all DOM methods are implemented completely, it works fine for typical xml documents. I can read in a xml document using JAXP by setting the DocumentBuilderFactory setting to my implementation:
    System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "ddom.jaxp.DDocumentBuilderFactory");
    But if I try to use a Transformer on the document, I get a NoSuchMethodException:
    Exception in thread "main" java.lang.NoSuchMethodError
         at org.apache.xpath.DOM2Helper.getNamespaceOfNode(DOM2Helper.java:348)
         at org.apache.xml.utils.TreeWalker.startNode(TreeWalker.java:281)
         at org.apache.xml.utils.TreeWalker.traverse(TreeWalker.java:119)
         at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:320)
         at ddom.DTreeTester.write(DTreeTester.java:59)
         at ddom.DTreeTester.main(DTreeTester.java:76)
    Unfortunately there is no source code available for JAXP, so I can't really figure what's going wrong. From the exception it is obvious that the Transformer is trying to figure out the namespace before it crashes. As my implementation ony implements DOM level 1 at the moment there is no support for namespaces. But of course this is reported by my DocumentBuilder class, so no calls to such methods hould occur.
    I just wanted to use the identity transformation to produce some nice output files. I would be very happy if anyone could help me with this problem.
    Mathias

    I tried to get more info on the DOM2Helper class, but only found lots of deprecated APIs. There seems to be some work done on internal APIs dealing with that class. Search for "DOM2Helper" in this page http://xml.apache.org/xalan-j/readme.html
    Maybe you just need to get a newer version of Xalan.

  • Attribute order changed

    Hello all!
    I'm developing a webapplication with JSP technology.
    i have to manage xml files, change and rewrite them.
    i use those pakage for manage and edit xml files :
    "javax.xml.parsers.DocumentBuilder and DocumentBuilderFactory"
    and that one for rewrite in a file:
    "javax.xml.transform"
    Now the problem is that the xml file edited had a particular element attribute order. the file rewrited change this order into an alphabetical order.
    i want to mantein the previous order.
    Is that possible? how?
    Thanks!

    No you get over it. The spec doesn't say it, but it is clearly an oversight by engineers more concerned with computer consuming XML then humans. One of the big selling points is that it is human readable and editable, this goes right against that.
    Now that XML is more of a standard, programming languages and other things are being generated using it. Configuration files and all sorts of things. Consider you have a tag like <function name="" comment="" >
    Suppose comment becomes really long while name is very short. Right now XSLT will reverse these attributes..now comment comes before the name and the file becomes unreadable....XML is used by humans too!
    The spec also doesn't say you need it or not. Java and the rest of the community have actively decided to be like you, a complete dick, for no reason and not support it. Just lazying coding for no reason. I guess maybe open standards are a bad way to go huh? Man up and have the right attitude...no reason not to make it an option other then total disregard for other peoples real world ( not virtual specification ) problems.

  • How to store xml data fragments, that will not be queried?

    Hello,
    Delphi Client application communicates with Java Server application via XML messages. Client sends XML message over HTTP Post method. Java Servlet gets XML message, parses it, performs requested action (select/insert/update/delete), generates resulting response and sends it back to the Client.
    I use Oracle DB XE 10.2.
    For example: Client sends a request to the server, to append certain Order with new Product info:
    Request:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <Request OrderID="123123123" Action="NewProduct">
    - <Product TempProdID="2" ProdName="L01" VisualID="1" Amount="1" TechClass="1" TechSubject="1" TechVersion="0" TechName="TestTech" ElemOk="0">
    <Modified UserID="XXX" UserGroup="XXX" GroupLevel="0" />
    - <QuickInfo>
    <ProdIcon Format="PNG"
    Encoding="Base64">iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAA
    lC+aJAAAAA3RSTlP////6yOLMAAAAvElEQVR42u3aQQ6EIAwAQP7/afe0
    mo1mBVur0emJgwGmRDFNWwvH9I153OpjyoisefqXW3afm4WypP+MgomvT
    z8AAAAAAAAAAAAAAMAzAClzAWQAdvexfqATEKmA/Fm0rYs5ozvoAWyWj4
    ZqJ9efQKR8BJAHOPEdKAAc/lLdAhC/K68EBG+JWwAixfABgF8Jf6MAAAA
    AAAAAAAAAAAAALwRUGgAAAAAAsgGJ3cfVrcfFl2jiIZzV+V7Zd/8BOtNi
    0MnJ58oAAAAASUVORK5CYII=
    </ProdIcon>
    <Parameters />
    </QuickInfo>
    - <TechProduct CurVer="1" MinVer="1" TotalItems="330" ItemNodeSize="55074">
    - <SubItem Class="TPlGraph" BindID="00B9C004">
    <PropList />
    - <SubItem Ident="Profiles" Class="TProfileList" Child="1" BindID="0188598C">
    <PropList />
    - <SubItem Class="TPlProfile" Child="1" BindID="018CA6CC">
    - <PropList>
    <Property PropIdent="ProfBaze0X" ValText="0" />
    <Property PropIdent="ProfBaze0Y" ValText="990" />
    <Property PropIdent="ProfBaze1X" ValText="990" />
    <Property PropIdent="ProfHier0" ValText="0" />
    - <Property PropIdent="InBorder" ValIdent="None" ValText="N&#279;ra">
    <ExtValue ColIdent="ItemCode" Value="None" />
    <ExtValue ColIdent="Type" Value="" />
    <ExtValue ColIdent="Filter" Value="" />
    <ExtValue ColIdent="Width" Value="0" />
    <ExtValue ColIdent="TechCall" Value="" />
    </Property>
    </PropList>
    </SubItem>
    </SubItem>
    </SubItem>
    </TechProduct>
    </Product>
    </Request>
    I use DOM parsers to parse the received requests, extract certain info and insert it into relational tables using standart SQL queries.
    My question is: what is the best way to store XML data fragments, that are not required to be saved relationally? I need to save the content of node <TechProduct> from the above example to relational table's column. There will be no need to query this column, no need to use relational views. I will use it only when Client application will request to modify certain order's product. Then I will have to send back the same <TechProduct> node via XML response.
    So what column type do I have to use? CLOB? XMLType? Is it better to use object types? Do I have to register XML Schema for better performance? The size of the fragment can be ~2MB.
    Thanks for your help
    Message was edited by:
    Kichas

    Thank you for reply,
    As you suggested, I will use XMLType storage as CLOB (without XML Schema).
    As I mentioned before, I use Java Servlet, deployed on Tomcat WebServer, to receive XML messages from Client application via HTTP POST method.
    I use these libs to get the XML payload and parse it into a Document:
    import org.w3c.dom.*;
    import org.xml.sax.InputSource;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    And here is the code:
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try {
    // get the XML payload and parse it into a Document
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    Document dom;
    InputSource input = new InputSource(request.getInputStream());
    dom = docBuilder.parse(input);
    catch(Exception ex) {
    System.out.println("Exception thrown in XmlService");
    ex.printStackTrace();
    throw new ServletException(ex);
    I create a relational table, that contains XMLType column:
    CREATE TABLE xwarehouses (
    warehouse_id NUMBER,
    warehouse_spec XMLTYPE)
    XMLTYPE warehouse_spec STORE AS CLOB;
    Now I want to insert all DOM Document into XMLType column. So I do like this:
    import oracle.xdb.XMLType;
    String SQLTEXT = "INSERT INTO XWAREHOUSES (WAREHOUSE_ID, WAREHOUSE_SPEC) VALUES (?, ?)";
    XMLType xml = XMLType.createXML(con,dom);
    PreparedStatement sqlStatement = con.prepareStatement(SQLTEXT);
    sqlStatement.setInt(1,2);
    sqlStatement.setObject(2,xml);
    sqlStatement.execute();
    sqlStatement.close();
    dom is the Document, that I got from HTTP Request input stream.
    My servlet throws an exception:
    java.lang.NoClassDefFoundError: oracle/xml/parser/v2/XMLParseException
    at XmlService.GetMatListServiceHandler.processRequest(GetMatListServiceHandler.java:111)
    at XmlService.XmlServiceHandler.handleRequest(XmlServiceHandler.java:43)
    at XmlService.XmlServiceServlet.doPost(XmlServiceServlet.java:69)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    why does he needs oracle.xml.parser.v2.XMLParseException? I don't use Oracle parser? Does this code line throws the exception (I am not able to debug my code, because I have not configured JDeveloper to be able to use Remote Debuging):
    XMLType xml = XMLType.createXML(con,dom);
    Does it reparses the given dom Document or what?. When I deploy xmlparserv2.jar to Tomcat, everything is ok, application inserts XML data into XMLType column.
    Is there another way to insert the whole org.w3c.dom Document or Document fragment (that is already parsed) into XMLType column. Can you provide any sample code?
    The Document may contain national symbols, so they should be correctly stored and then later retrieved.
    Many thanks.

  • Writting file in xml format

    Hello guys,
    I am just wondering if i can write to a text file in xml format:
    For example if i want to save the following:
    Avisha 00/06/2000
    The text file should show:
    <record>
    <name>Avisha</name>
    <DOB00/06/200</DOB>
    </record>
    I think i probably needs to use some sort of XML schema, i never done it before and i would appriciate your help.
    Thanks,

    corlettk wrote:
    thomas.behr wrote:
    Well, for simple cases, such as your example, just create an appropriate String and write that to your file.
    For more complex cases, create a org.w3c.dom.Document (using DocumentBuilder and DocumentBuilderFactory), create the appropriate structure and use a javax.xml.transform.Transformer (created via TransformerFactory) to convert your Document from a DOMSource to StreamResult.I'm not a fan of the DOM solution... It's slow and very memory hungry... Goog for small datasets.
    @OP If you can, I recommend using an XMLBinder (like [XML-Beans|http://xmlbeans.apache.org/] jusr for example) to both read and write all your XML.Errr, XMLBeans and the like will still be using DOM under the covers, so the memory issue is still as relevant as before. Happily, this turns out to be "not as much as you probably think" anyway. So the decision is a design one. Do you have schemas for this XML? You don't? Ah well, a binding framework's out of the question anyway. What are you doing with it? ("Processing it" isn't an answer). Where is it coming from? ("my codez" isn't an answer). What format need it be in? ("XML format" isn't an answer)
    Building a DOM tree and serializing it isn't necessarily all that stupid an idea

  • Validating with a Schema

    I know this should not be difficult, but I cannot really find an easy answer to validating an XML document against a schema. I have an XML document that I can validate against a schema within Netbeans. I want to write some Java code that will validate the XML document against the schema at runtime before I start reading the data. Can someone provide me with a simple straightforward answer? Does the XML document have to have the "xsi:schemaLocation" or can I define that at code time?
    I am currently using the DocumentBuilderFactory, DocumentBuilder, and Document to load the XML into a DOM document so that I can read the data.
    Thanks

    http://forum.java.sun.com/thread.jsp?forum=34&thread=288059

  • How to parse an PL/SQL type to XML format in ORACLE8

    I've got a PL/SQL type ( table/records/...) and I want to set it to XML format :
    I've got
    TYPE return_row IS record (
    value_1 NUMBER(2),
    value_2 VARCHAR2(30));
    TYPE return_test IS TABLE OF return_row
    INDEX BY BINARY_INTEGER;
    VARCHAR2 XMLformat;
    And I want to set into XMLformat the value of return_test parsed to XML.

    I only
    need to know how to change a inputstream (instance of
    an online xml file) to a Node. If your want to create a Node, maybe you're thinking DOM (as apposed to SAX) and you should take a look at the API for:
    - DocumentBuilderFactory
    - DocumentBuilder
    and the
    Document parse(...)
    method family. They all return a Document, which is a type of Node.

  • I thought I understood XML ........

    Hi, Can anyone help me out here. Although I understand about XML and have written al lot of stuff to process XML, it was in a language that came out of a company based in Redmond :).
    I take one look at the Java stuff and get very confused.
    I want to export the Preferences of an application to a file, which using is easily done using the standard package and this produces a "stream". Before I send the contents to a file I want to delete some of the nodes in the preferences as they are specific to that instance of the application. I would therefore like to edit the XML before it is written. I would normally make a XML Document object from the XML in the stream and make my changes to that, finally sending the content of the document to a file. Easy enough I thinks, and it is in the other language.
    In java I try to make a document with a DocumentBuilderFactory and DocumentBuilder and when I try to run the program I get an UnknownHostException because the computer involved cannot connect to the internet and download the DTD specified in the XML Stream. The offending line is part of the exported XML cannot be remove as I will also want it in the final output for when it is imported again.
    I have seen all sorts of articles about different packages, parsers and the like and I am now totally confused. I did try making a custom entity resolver but that didnt work either. I tried to use the SAX parser but could not work out how to make that give me a document.I'm not even sure this is the right thing to do.
    Can someone point me to where this might be explained in simple terms because I really am totally confused now.
    Thanks
    Terry

    Ok first, sorry if I was appearing to "have a sly go" at Java, I was actually trying to infer that it was my lack of knowledge and inability to get my head around this rather than anything "wrong" with java. I spent 15 years learning the other stuff and so if I didn't understand that side of things then I should have given up and become a road sweeper. I've only spent 3 months on this in a serious way.
    Anyway that said I am still confused by all the different parsers and things and there are lots of examples out there but none I have found really explain why I would want to use a particular parser or what I can do with them etc.
    Ok back to my original problem, this is the code and its just a little piece of prototype so please ignore any redundant imports or improper exception handling and that sort of error,
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package xxxx.xxxxxxx.xxxx.xxx;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    import java.io.PrintWriter;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import java.util.prefs.BackingStoreException;
    import java.util.prefs.Preferences;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    public class GlobalData {
        private Preferences prefs;
        public void setPreference() throws SAXException, ParserConfigurationException, IOException {
            prefs = Preferences.systemNodeForPackage(GlobalData.class);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            //OutputStream out = System.out;
            try {
                // prefs.exportSubtree(out);
                prefs.exportSubtree(baos);
            } catch (IOException ex) {
                Logger.getLogger(GlobalData.class.getName()).log(Level.SEVERE, null, ex);
            } catch (BackingStoreException ex) {
                Logger.getLogger(GlobalData.class.getName()).log(Level.SEVERE, null, ex);
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setValidating(false);
            DocumentBuilder builder = factory.newDocumentBuilder();
            EntityResolver customEntityResolver = new DummyEntityResolver();
            builder.setEntityResolver(customEntityResolver);
            Document xDoc = builder.parse(bais);
            //System.out.println(xDoc.toString());
        public static void main(String[] args) {
            GlobalData test = new GlobalData();
            try {
                test.setPreference();
            } catch (ParserConfigurationException ex) {
                Logger.getLogger(GlobalData.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SAXException ex) {
                Logger.getLogger(GlobalData.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(GlobalData.class.getName()).log(Level.SEVERE, null, ex);
    public class DummyEntityResolver implements EntityResolver{
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            return null;
    }I thought I got it right but obviously not.
    When it hits the parse then I get the UnknownHostException just the same as without the custom EntityResolver.
    If you can help I would be grateful.
    Thanks
    Terry

Maybe you are looking for