You forgot that parser casted to PSVIProvider is still a parser, so you it for parsing first of all :-)

http://xml.apache.org/xerces2-j/faq-xs.html#faq-6
Here's excerpt
Within the scope of the methods handling the start and end of an element, i.e. org.xml.sax.ContentHandler.startElement (..), an application can use the PSVIProvider to retrieve the PSVI related to that element and its attributes.

You should use parser for parsing, and within content handler methods use parser casted to PSVIProvider to extract PSVI info (as xni faq #6 says)


Huzefa Hakimi wrote:
This faq page does not tell how to proceed further. As
in there it says that you get PSVIProvider instance
(by casting SAXParser) but than how do tell after that
which is the document to be parsed. Lets for example
prv. if one uses this code to parse the Document
validated against a schema: 

reader =
XMLReaderFactory.createXMLReader(vendorClass);
            
// register content handler           
reader.setContentHandler(contentHandler);
            
// register error handler
reader.setErrorHandler(errHandler);
            
// set the corresponding features of the SAX parser
reader.setFeature("http://xml.org/sax/features/namespaces",
true);
           
reader.setFeature("http://xml.org/sax/features/namespace-prefixes",
true);
            
           
reader.setFeature("http://xml.org/sax/features/validation",
true);
           
reader.setFeature("http://apache.org/xml/features/validation/schema",
true);

// create input source from xml document
InputSource inputSource = new InputSource(xmlURI);
reader.parse(inputSource);

......

Later for this code if one tries to retrieve Schema
Information than would be using PSVI to get handler to
XSModel. Right? So for this he would have something
similar to: 

....

SAXParserFactory factory = new
org.apache.xerces.jaxp.SAXParserFactoryImpl();
       
factory.setFeature("http://xml.org/sax/features/namespaces",
true);
       
factory.setFeature("http://xml.org/sax/features/namespace-prefixes",
true);
       
factory.setFeature("http://xml.org/sax/features/validation",
true); 
       
factory.setFeature("http://apache.org/xml/features/validation/schema",
true);
        
SAXParser parser = factory.newSAXParser();
PSVIProvider psvi = (PSVIProvider)parser;

But ones he cast parser to PSVIProvider how to proceed
from here to next stage so that he can specify the
document to be parsed and correspondingly get  the
Schema Information too. 

Sorry for this niche queries.

Huzefa
--- Maksym Kovalenko <[EMAIL PROTECTED]>
wrote:
  
http://xml.apache.org/xerces2-j/faq-xs.html

Huzefa Hakimi wrote:

    
Hello everybody,

Sorry if this has been covered in previous threads.

I am trying to gather information about all element
ans its type for XML Schema against which XML
      
Document
    
is validated. I am using SAX parser to parse XML
documents as have to walk to large documents.
      
Xerces
    
documentation says that you can use PSVI for this,
      
but
    
was not getting how to proceed further having this
PSVIParser instance;  

import org.apache.xerces.impl.xs.psvi.PSVIProvider;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

...

SAXParserFactory factory =
SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
PSVIProvider psviProvider = (PSVIProvider)parser;

In above where do we really point that which XML
document its going to parse. 


Can you please help in getting proceeded from this
step.

Thanks in advance

Huzefa

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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

      
-- 

    
------------------------------------------------------------------------
  
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


    


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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

  

--

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

Reply via email to