You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Lin Guo <gu...@cs.cornell.edu> on 2004/12/09 16:37:54 UTC

how to retrieve psvi information from a parser

In xerces-java, it is as simple as:
 
----------------------------------------------------------------------
 
dbf.setNamespaceAware(true);
dbf.setValidating(true);
dbf.setAttribute("http://apache.org/xml/features/validation/schema", 
    Boolean.TRUE);
dbf.setAttribute("http://apache.org/xml/properties/dom/document-class-name", 
   "org.apache.xerces.dom.PSVIDocumentImpl");
          
Document doc = db.parse("person.xml");
Element documentElement = doc.getDocumentElement() ;
if (documentElement.isSupported("psvi", "1.0")){ 
    ElementPSVI psviElem = (ElementPSVI)doc.getDocumentElement();
    XSModel model = psviElement.getSchemaInformation();
    XSElementDeclaration decl = psviElem.getElementDeclaration();
-----------------------------------------------------------------------------
-----------
 
And in xerces-c, how can I do this to get an XSModel object(ptr)?
 
Thanks,
Lin

Re: how to retrieve psvi information from a parser

Posted by Alberto Massari <am...@progress.com>.
At 10.37 09/12/2004 -0500, Lin Guo wrote:
>In xerces-java, it is as simple as:
>
>----------------------------------------------------------------------
>
>dbf.setNamespaceAware(true);
>dbf.setValidating(true);
>dbf.setAttribute("http://apache.org/xml/features/validation/schema",
>     Boolean.TRUE);
>dbf.setAttribute("http://apache.org/xml/properties/dom/document-class-name",
>    "org.apache.xerces.dom.PSVIDocumentImpl");
>
>Document doc = db.parse("person.xml");
>Element documentElement = doc.getDocumentElement() ;
>if (documentElement.isSupported("psvi", "1.0")){
>     ElementPSVI psviElem = (ElementPSVI)doc.getDocumentElement();
>     XSModel model = psviElement.getSchemaInformation();
>     XSElementDeclaration decl = psviElem.getElementDeclaration();
>----------------------------------------------------------------------------------------
>
>And in xerces-c, how can I do this to get an XSModel object(ptr)?

In Xerces 2.6 you have two choices:
1) plug in your PSVIHandler object using setPSVIHandler(), and process the 
handleElementPSVI/handleAttributesPSVI callbacks
2) call setFeature(XMLUni::fgXercesDOMHasPSVIInfo) on the parser; in the 
generated DOM tree you can do

   DOMPSVITypeInfo* 
psviType=(DOMPSVITypeInfo*)elem->getInterface(XMLUni::fgXercescInterfacePSVITypeInfo);
   if(psviType)
   {
     PSVIItem::VALIDITY_STATE 
state=psviType->getNumericProperty(DOMPSVITypeInfo::PSVI_Validity);
     bool isNil=(psviType->getNumericProperty(DOMPSVITypeInfo::PSVI_Nil)!=0);
     const XMLCh* 
typeNS=psviType->getStringProperty(DOMPSVITypeInfo::PSVI_Type_Definition_Namespace);
     const XMLCh* 
typeName=psviType->getStringProperty(DOMPSVITypeInfo::PSVI_Type_Definition_Name);
     const XMLCh* 
memberTypeNS=psviType->getStringProperty(DOMPSVITypeInfo::PSVI_Member_Type_Definition_Namespace);
     const XMLCh* 
memberTypeName=psviType->getStringProperty(DOMPSVITypeInfo::PSVI_Member_Type_Definition_Name);
   }

Similarly for attributes (minus the isNil property).

Hope this helps,
Alberto 



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org