You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Rubens Del Monte <ru...@soluzionautilities.com.br> on 2003/10/08 20:27:40 UTC

Node Info and PSVI in one parser

Hello,

   My problem is that I can´t acess both PSVI and the node´s value in the
same parse.

   In this code bellow, I can acess the node information but I could only
acess top-level PSVI with the XSModel returned.

XMLParserConfiguration config = new StandardParserConfiguration();

config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",
grammarPool);
            DOMParser parser = new DOMParser(config);

parser.setFeature("http://xml.org/sax/features/validation",true);

parser.setFeature("http://apache.org/xml/features/validation/schema",true);
            parser.parse(filename);
            doc = parser.getDocument();

            org.apache.xerces.impl.xs.psvi.XSModel model =
grammarPool.toXSModel();

   In this one, I can acess the PSVI but not the node’s value :

   DOMParser parser = new DOMParser();
   parser.setFeature("http://xml.org/sax/features/validation",true);

parser.setFeature("http://apache.org/xml/features/validation/schema",true);

parser.setProperty("http://apache.org/xml/properties/dom/document-class-name
","org.apache.xerces.dom.PSVIDocumentImpl");
   parser.parse(filename);
   doc = parser.getDocument();

   // only to test
   ElementPSVI elem = (ElementPSVI) node;
   System.out.println(node.getNodeName() + " : "+node.getNodeValue()); //
the output is always : “ node name : null”;


I could parse the document twice, using the normal way and the PSVI, but it
would take more time and resources…
Sorry to keep bothering you but I´ve read all the FAQ and went trought the
docs but I still haven´t found a way to solve this.

Thank´s

Rubens

RES: Node Info and PSVI in one parser

Posted by Rubens Del Monte <ru...@soluzionautilities.com.br>.
My test was wrong ! I used a loop to print all values, and everything was
null, but there was an if that shown only the element nodes, and the values
are in the text nodes…

It will work fine ! thanks max !

-----Mensagem original-----
De: Maksym Kovalenko [mailto:mkovalenko@marketswitch.com]
Enviada em: quarta-feira, 8 de outubro de 2003 15:40
Para: xerces-j-user@xml.apache.org
Assunto: Re: Node Info and PSVI in one parser

According to specification nodeValue is null for elements.
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#ID-F68D080
<http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#ID-F68D080
>

What did you expect to receive from getNodeValue()?

Max

Rubens Del Monte wrote:


Hello,
   My problem is that I can´t acess both PSVI and the node´s value in the
same parse.
   In this code bellow, I can acess the node information but I could only
acess top-level PSVI with the XSModel returned.
XMLParserConfiguration config = new StandardParserConfiguration();
            config.setProperty(
"http://apache.org/xml/properties/internal/grammar-pool"
<http://apache.org/xml/properties/internal/grammar-pool> ,grammarPool);
            DOMParser parser = new DOMParser(config);
            parser.setFeature( "http://xml.org/sax/features/validation"
<http://xml.org/sax/features/validation> ,true);
            parser.setFeature(
"http://apache.org/xml/features/validation/schema"
<http://apache.org/xml/features/validation/schema> ,true);
            parser.parse(filename);
            doc = parser.getDocument();

            org.apache.xerces.impl.xs.psvi.XSModel model =
grammarPool.toXSModel();
   In this one, I can acess the PSVI but not the node’s value :
   DOMParser parser = new DOMParser();
   parser.setFeature( "http://xml.org/sax/features/validation"
<http://xml.org/sax/features/validation> ,true);
   parser.setFeature( "http://apache.org/xml/features/validation/schema"
<http://apache.org/xml/features/validation/schema> ,true);
   parser.setProperty(
"http://apache.org/xml/properties/dom/document-class-name"
<http://apache.org/xml/properties/dom/document-class-name>
,"org.apache.xerces.dom.PSVIDocumentImpl");
   parser.parse(filename);
   doc = parser.getDocument();
   // only to test
   ElementPSVI elem = (ElementPSVI) node;
   System.out.println(node.getNodeName() + " : "+node.getNodeValue()); //
the output is always : “ node name : null”;
I could parse the document twice, using the normal way and the PSVI, but it
would take more time and resources…
Sorry to keep bothering you but I´ve read all the FAQ and went trought the
docs but I still haven´t found a way to solve this.
Thank´s
Rubens

--


  _____

Maksym Kovalenko
Software Engineer
Marketswitch Corporation
http://www.marketswitch.com <http://www.marketswitch.com/>
108 Powers Court, Suite 225
Dulles, VA 20166
Phone: +1 (703) 444-6750 ext. 302
Fax: +1 (703) 444-6812

RES: Node Info and PSVI in one parser

Posted by Rubens Del Monte <ru...@soluzionautilities.com.br>.
My test was wrong ! I used a loop to print all values, and everything was
null, but there was an if that shown only the element nodes, and the values
are in the text nodes…

It will work fine ! thanks max !

-----Mensagem original-----
De: Maksym Kovalenko [mailto:mkovalenko@marketswitch.com]
Enviada em: quarta-feira, 8 de outubro de 2003 15:40
Para: xerces-j-user@xml.apache.org
Assunto: Re: Node Info and PSVI in one parser

According to specification nodeValue is null for elements.
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#ID-F68D080
<http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#ID-F68D080
>

What did you expect to receive from getNodeValue()?

Max

Rubens Del Monte wrote:


Hello,
   My problem is that I can´t acess both PSVI and the node´s value in the
same parse.
   In this code bellow, I can acess the node information but I could only
acess top-level PSVI with the XSModel returned.
XMLParserConfiguration config = new StandardParserConfiguration();
            config.setProperty(
"http://apache.org/xml/properties/internal/grammar-pool"
<http://apache.org/xml/properties/internal/grammar-pool> ,grammarPool);
            DOMParser parser = new DOMParser(config);
            parser.setFeature( "http://xml.org/sax/features/validation"
<http://xml.org/sax/features/validation> ,true);
            parser.setFeature(
"http://apache.org/xml/features/validation/schema"
<http://apache.org/xml/features/validation/schema> ,true);
            parser.parse(filename);
            doc = parser.getDocument();

            org.apache.xerces.impl.xs.psvi.XSModel model =
grammarPool.toXSModel();
   In this one, I can acess the PSVI but not the node’s value :
   DOMParser parser = new DOMParser();
   parser.setFeature( "http://xml.org/sax/features/validation"
<http://xml.org/sax/features/validation> ,true);
   parser.setFeature( "http://apache.org/xml/features/validation/schema"
<http://apache.org/xml/features/validation/schema> ,true);
   parser.setProperty(
"http://apache.org/xml/properties/dom/document-class-name"
<http://apache.org/xml/properties/dom/document-class-name>
,"org.apache.xerces.dom.PSVIDocumentImpl");
   parser.parse(filename);
   doc = parser.getDocument();
   // only to test
   ElementPSVI elem = (ElementPSVI) node;
   System.out.println(node.getNodeName() + " : "+node.getNodeValue()); //
the output is always : “ node name : null”;
I could parse the document twice, using the normal way and the PSVI, but it
would take more time and resources…
Sorry to keep bothering you but I´ve read all the FAQ and went trought the
docs but I still haven´t found a way to solve this.
Thank´s
Rubens

--


  _____

Maksym Kovalenko
Software Engineer
Marketswitch Corporation
http://www.marketswitch.com <http://www.marketswitch.com/>
108 Powers Court, Suite 225
Dulles, VA 20166
Phone: +1 (703) 444-6750 ext. 302
Fax: +1 (703) 444-6812

Re: Node Info and PSVI in one parser

Posted by Maksym Kovalenko <mk...@marketswitch.com>.
According to specification nodeValue is null for elements.
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030609/core.html#ID-F68D080

What did you expect to receive from getNodeValue()?

Max

Rubens Del Monte wrote:

> Hello,
>
>  
>
>    My problem is that I can´t acess both PSVI and the node´s value in 
> the same parse.
>
>  
>
>    In this code bellow, I can acess the node information but I could 
> only acess top-level PSVI with the XSModel returned.
>
>  
>
> XMLParserConfiguration config = new StandardParserConfiguration();
>
>             
> config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",grammarPool);
>
>             DOMParser parser = new DOMParser(config);
>
>             
> parser.setFeature("http://xml.org/sax/features/validation",true);
>
>             
> parser.setFeature("http://apache.org/xml/features/validation/schema",true);
>
>             parser.parse(filename);
>
>             doc = parser.getDocument();
>
>            
>
>             org.apache.xerces.impl.xs.psvi.XSModel model = 
> grammarPool.toXSModel(); 
>
>  
>
>    In this one, I can acess the PSVI but not the node's value :
>
>  
>
>    DOMParser parser = new DOMParser();
>
>    parser.setFeature("http://xml.org/sax/features/validation",true);
>
>    
> parser.setFeature("http://apache.org/xml/features/validation/schema",true);
>
>    
> parser.setProperty("http://apache.org/xml/properties/dom/document-class-name","org.apache.xerces.dom.PSVIDocumentImpl");
>
>    parser.parse(filename);
>
>    doc = parser.getDocument();
>
>  
>
>    // only to test
>
>    ElementPSVI elem = (ElementPSVI) node;
>
>    System.out.println(node.getNodeName() + " : "+node.getNodeValue()); 
> // the output is always : " node name : null";
>
>  
>
>  
>
> I could parse the document twice, using the normal way and the PSVI, 
> but it would take more time and resources...
>
> Sorry to keep bothering you but I´ve read all the FAQ and went trought 
> the docs but I still haven´t found a way to solve this.
>
>  
>
> Thank´s
>
>  
>
> Rubens
>

-- 
------------------------------------------------------------------------

Maksym Kovalenko
Software Engineer
Marketswitch Corporation
http://www.marketswitch.com <http://www.marketswitch.com/>
108 Powers Court, Suite 225
Dulles, VA 20166
Phone: +1 (703) 444-6750 ext. 302
Fax: +1 (703) 444-6812