Hello!

I've written a small program to parse xml files. It's for a university project, every 
xml file has the same structure so please don't wonder why my code looks so bad ;-)
The problem is that the following if loop doesn't extract the value:
if (node.getNodeName().equals("rdf:li")) {
   Element element = (Element)node;
   if (element.hasAttribute("xml:lang")) {
     System.out.println(node.getNodeValue());
   }
}

When I say node.getNodeName() it tells me the correct Name, but NodeValue() just tells 
null. It shouldn't do that.
The part of the xml file looks like this:
<dc:title>
   <rdf:Alt>
      <rdf:li xml:lang="en">Convergence of some two-level overlapping domain 
decomposition preconditioners with smoothed aggregation coarse spaces�
      </rdf:li>
   </rdf:Alt>
</dc:title>

Do you have a clue what's wrong with it? Could it be a Xerces bug?
I've attached the full source and the xml file.
Thanks in advance for your help.

Greetings, 
Christian Meyer
// package dom;

import java.io.Serializable;
import java.lang.*;
import java.util.*;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.apache.xerces.parsers.DOMParser;

import ui.DOMParserSaveEncoding;


public class DOMTest {

  public static void arbeite(NodeList nodes) {
    int len = (nodes != null) ? nodes.getLength() : 0;
//    System.out.println(len);
    for (int i=0; i < len; i++) {
      Node node = nodes.item(i);
      switch (node.getNodeType()) {
        case Node.DOCUMENT_NODE: {
           System.out.println("Document Node " + node.getNodeName() );
//           arbeite(node.getChildNodes());
           break;
        }
        case Node.ELEMENT_NODE: {

          if (node.getNodeName().equals("rdf:Description")) {
            if (node.getParentNode().getNodeName().equals("rdf:li") && 
node.getParentNode().getParentNode().getNodeName().equals("rdf:Bag")) {
              Element element = (Element)node;
              System.out.println(element.getAttribute("vCard:FN")); // for testing
              ArrayList authors = new ArrayList();
              authors.add(element.getAttribute("vCard:FN"));
            }
          }

          if (node.getNodeName().equals("rdf:li")) {
            if (node.getParentNode().getNodeName().equals("rdf:Alt") && 
node.getParentNode().getParentNode().getNodeName().equals("dc:identifier")) {
              Element element = (Element)node;
              System.out.println(element.getAttribute("rdf:resource")); // for testing
              ArrayList fullTextSrc = new ArrayList();
              fullTextSrc.add(element.getAttribute("rdf:resource"));
            }
          }

          if (node.getNodeName().equals("rdf:Description")) {
            if (node.getParentNode().getNodeName().equals("dcq:created")) {
              Element element = (Element)node;
              System.out.println(element.getAttribute("rdf:value")); // for testing
              String dateCreated = element.getAttribute("rdf:value");
            }
          }

          if (node.getNodeName().equals("rdf:Description")) {
            if (node.getParentNode().getNodeName().equals("dcq:modified")) {
              Element element = (Element)node;
              System.out.println(element.getAttribute("rdf:value")); // for testing
              String dateModified = element.getAttribute("rdf:value");
            }
          }

         if (node.getNodeName().equals("rdf:li")) {
           Element element = (Element)node;
           if (element.hasAttribute("xml:lang")) {
              System.out.println(node.getNodeValue());
           }
         }

           arbeite(node.getChildNodes());
           break;
        }

        default: {
//          System.out.println("Default");
        }
      }
    }
  }
/*
 public static String getAuthor1() {
   return author1;
 }

 public static String getAuthor2() {
   return author2;
 }

 public static String getFullTextSrc() {
   return fullTextSrc;
 }

 public static String getDateModified() {
   return dateModified;
 }

 public static String getDateCreated() {
   return dateCreated;
 }

 public static String getTitle() {
   return title;
 }
*/
  public static void main(String[] argv) {
    String filename=argv[0];
    String DEFAULT_PARSER_NAME = "org.apache.xerces.parsers.DOMParser";
    DOMParserSaveEncoding parser;

    try {
    parser = new DOMParserSaveEncoding();
//    ef.resetErrors();
//    parser.setErrorHandler(ef);
    parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion";, 
false); // otherwise parser.getCurrentNode() == null
    parser.setFeature("http://apache.org/xml/features/continue-after-fatal-error";, 
true);
    parser.setFeature("http://apache.org/xml/features/allow-java-encodings";, true);
    parser.parse(filename);
    Document document = parser.getDocument();
    NodeList nodes = document.getChildNodes();
    arbeite(nodes);
  } catch (Exception ex) {
     System.err.println(ex.getMessage());
     ex.printStackTrace();
  }
    
  }

//  ErrorStorer ef;
}
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema";
         xmlns:dc="http://dublincore.org/documents/dces#";
         xmlns:dcq="http://dublincore.org/documents/dcmes-qualifiers#";
         xmlns:mathnet="http://www.ams.org/msc/";
         xmlns:vCard="http://www.dstc.edu.au/Research/Projects/rdf/draft-iannella-vcard-rdf-00.txt";>

<rdf:Description rdf:about="http://www.ukoln.ac.uk/metadata/resources/dc/datamodel/WD-dc-rdf/";>

<dc:title>
   <rdf:Alt>
      <rdf:li xml:lang="en">Convergence of some two-level overlapping domain decomposition preconditioners with smoothed aggregation coarse spaces 
      </rdf:li>
   </rdf:Alt>
</dc:title>

<dc:rights>
   <rdf:Description rdfs:label=
       "Copyright: The author(s) agree, that this abstract
        may be stored as full text and distributed
        as such by abstracting services."/>
</dc:rights>

<dc:creator rdf:ID="Creator">
  <rdf:Bag>
    <rdf:li>
     <rdf:Description
          rdf:ID="Creator_1"
          vCard:FN="Caroline Lasser"
          rdfs:label="Caroline Lasser"
          vCard:EMAIL="[EMAIL PROTECTED]"
          vCard:URL="http://www-m3.mathematik.tu-muenchen.de/m3/classer/index.de.html";
          vCard:ORG="Zentrum Mathematik der Technischen Universität München">
     <rdf:type rdf:resource="http://purl.org/dc/terms/1.0/Person"/>
     <vCard:N>
       <rdf:Description vCard:Family="Lasser"
                        vCard:Given="Caroline"/>
     </vCard:N>
     </rdf:Description>
    </rdf:li>
    <rdf:li>
     <rdf:Description
          rdf:ID="Creator_2"
          vCard:FN="Andrea Toselli"
          rdfs:label="Andrea Toselli"
          vCard:EMAIL="[EMAIL PROTECTED]"
          vCard:URL="http://www.sam.math.ethz.ch/~toselli/";
          vCard:ORG="Seminar for Applied Mathematics, ETH Zürich">
     <rdf:type rdf:resource="http://purl.org/dc/terms/1.0/Person"/>
     <vCard:N>
       <rdf:Description vCard:Family="Toselli"
                        vCard:Given="Andrea"/>
     </vCard:N>
     </rdf:Description>
    </rdf:li>
  </rdf:Bag>
</dc:creator>

<dc:contributor>
  <rdf:Description rdfs:label="Michael Kaplan"
                   vCard:FN="Michael Kaplan"
                   vCard:EMAIL="[EMAIL PROTECTED]"
                   vCard:TEL="+49-89-289-24209">
     <rdf:type rdf:resource="http://purl.org/dc/terms/1.0/Person"/>
     <vCard:N>
       <rdf:Description vCard:Family="Kaplan"
                        vCard:Given="Michael"/>
     </vCard:N>
  </rdf:Description>
</dc:contributor>

<dc:language>
  <rdf:Description rdf:value="en" rdfs:label="English				">
    <rdfs:isDefinedBy rdf:resource="http://www.ietf.org/rfc/rfc1766.txt?number=1766"/>
  </rdf:Description>
</dc:language>

<dc:identifier>
  <rdf:Alt>
    <rdf:li rdf:resource="http://www-lit.ma.tum.de/veroeff/quel/010.65012.pdf"/>
    <rdf:li rdf:resource="http://www-lit.ma.tum.de/veroeff/quel/010.65012.ps.gz"/>
    <rdf:li rdf:resource="http://triton.mathematik.tu-muenchen.de/~kaplan/smagg.ps"/>
  </rdf:Alt>
</dc:identifier>

<dcq:issued>
  <rdf:Description rdf:value="2001-09"
                   rdfs:label="September 2001">
    <rdfs:isDefinedBy rdf:resource="http://www.uic.edu/year2000/datefmt.html"/>
    <rdf:type rdf:resource="http://purl.org/dc/terms/1.0/Point"/>
  </rdf:Description>
</dcq:issued>

<dcq:created>
  <rdf:Description rdf:value="2001-09-07"
                   rdfs:label="07 September 2001">
    <rdfs:isDefinedBy rdf:resource="http://www.uic.edu/year2000/datefmt.html"/>
    <rdf:type rdf:resource="http://purl.org/dc/terms/1.0/Point"/>
  </rdf:Description>
</dcq:created>

<dcq:modified>
  <rdf:Description rdf:value="2001-09-26"
                   rdfs:label="26 September 2001">
    <rdfs:isDefinedBy rdf:resource="http://www.uic.edu/year2000/datefmt.html"/>
    <rdf:type rdf:resource="http://purl.org/dc/terms/1.0/Point"/>
  </rdf:Description>
</dcq:modified>

<dc:type rdf:resource="http://MathNet.preprints.org/SCHEME1.0#Preprint"/>

<mathnet:primarySubject>
  <rdf:Alt>
    <rdf:li>
      <rdf:Description rdf:value="65F10"  rdfs:label="Numerical analysis, Numerical linear algebra, Iterative methods for linear systems [See also 65N22]">
       <rdf:type rdf:resource="http://purl.org/dc/terms/1.0/Classification"/>
       <rdfs:isDefinedBy>
      <rdf:Description rdfs:label="Mathematical Subject Classification Scheme (MSC2000)">
            <rdf:value rdf:resource="http://www.ams.org/msc/"/>
         </rdf:Description>
       </rdfs:isDefinedBy>
    </rdf:Description>
    </rdf:li>
  </rdf:Alt>
</mathnet:primarySubject>

<mathnet:secondarySubject>
  <rdf:Alt>
    <rdf:li>
      <rdf:Description rdf:value="65N22"  rdfs:label="Numerical analysis, Partial differential equations, boundary value problems, Solution of discretized equations [See also 65Fxx, 65Hxx]">
        <rdf:type rdf:resource="http://purl.org/dc/terms/1.0/Classification"/>
        <rdfs:isDefinedBy>
          <rdf:Description rdfs:label="Mathematical Subject Classification Scheme (MSC2000)">
          <rdf:value rdf:resource="http://www.ams.org/msc/"/>
          </rdf:Description>
        </rdfs:isDefinedBy>
      </rdf:Description>
    </rdf:li>
   </rdf:Alt>
 </mathnet:secondarySubject>

<mathnet:Subject>
  <rdf:Alt>
    <rdf:li>
      <rdf:Description rdf:value="65F10"  rdfs:label="Numerical analysis, Numerical linear algebra, Iterative methods for linear systems [See also 65N22]">
       <rdf:type rdf:resource="http://purl.org/dc/terms/1.0/Classification"/>
       <rdfs:isDefinedBy>
      <rdf:Description rdfs:label="Mathematical Subject Classification Scheme (MSC2000)">
         <rdf:value rdf:resource="http://www.ams.org/msc/"/>
         </rdf:Description>
       </rdfs:isDefinedBy>
       </rdf:Description>
    </rdf:li>
    <rdf:li>
      <rdf:Description rdf:value="65N22"  rdfs:label="Numerical analysis, Partial differential equations, boundary value problems, Solution of discretized equations [See also 65Fxx, 65Hxx]">
       <rdf:type rdf:resource="http://purl.org/dc/terms/1.0/Classification"/>
       <rdfs:isDefinedBy>
      <rdf:Description rdfs:label="Mathematical Subject Classification Scheme (MSC2000)">
         <rdf:value rdf:resource="http://www.ams.org/msc/"/>
         </rdf:Description>
       </rdfs:isDefinedBy>
       </rdf:Description>
    </rdf:li>
  </rdf:Alt>
</mathnet:Subject>

<dcq:abstract>
  <rdf:Description>
    <dc:language>
      <rdf:Description rdf:value="en"
                       rdfs:label="English				">
      </rdf:Description>
    </dc:language>
    <rdf:value resource= "http://www-lit.ma.tum.de/veroeff/html/010.65012.html#Abstract"; />
  </rdf:Description>
</dcq:abstract>

<dc:subject>
  <rdf:Description>
    <rdfs:label rdf:parseType="Literal">domain decomposition; overlapping Schwarz methods; preconditioning; smoothed aggregation   </rdfs:label>
  </rdf:Description>
</dc:subject>

</rdf:Description>

</rdf:RDF>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to