Re: Re: [xmlpull-user] Problems with namespace-prefixes Feature.

Aleksander Slominski <[email protected]> Fri, 07 Mar 2003 01:49:40 -0500
Newsgroups gmane.text.xml.xmlpull.devel
Message-ID <[email protected]>

vivek200120 wrote:

>  I use the kXml parser which adheres to the pull api..The setFeature
>() method implementation throws an exception for this feature 
>FEATURE_REPORT_NAMESPACE_ATTRIBUTES . 
>
it is not supported in kXML2

>I think this would be useful  .Right now I access namespace 
>attributes like this:
>
>/////
>int n=parser.getNamespaceCount(parser.getDepth());
>        
>        
>        for (int i=0;i<n;i++)
>         {
>         System.out.println(parser.getNamespacePrefix
>(i),parser.getNamespaceUri(i));
>         
>         
>         }
>         
> /////////
>above code works fine for me because I need to get the namespace 
>attributes of only the root element. 
>How do I get the namespace attributes otherwise? is there another 
>method? 
>
hi,

that code should work (though i have not tested it) to retrieve 
namespaces declared in current element:

 for (int i = getNamespaceCount(getDepth ())-1; i >= getNamespaceCount(getDepth ()-1)-1; i--) {
           System.out.println(parser.getNamespacePrefix(i),parser.getNamespaceUri(i));
 }

the key to understand this is to realize that getNamespaceCount() 
function returns index into namespace uri and prefix tables 
(getNamespacePrefix/Uri(i) returns element in table at index i) for 
_any_ given depth so you can see what namespaces uris/prefixes declared 
between any depth levels in your case between current element 
(getDepth()) and its parent (getDepth()-1).

HTH

alek

>
>Thanks
>Vivek
>
> 
>--- In [email protected], Aleksander Slominski <aslom@e...> 
>wrote:
>  
>
>>Sean C. Truman wrote:
>>
>>    
>>
>>>Trying
>>>
>>>MXParser pullDriver = new org.xmlpull.mxp1.MXParser();
>>>pullDriver.setFeature(pullDriver.FEATURE_PROCESS_NAMESPACES,true);
>>>pullDriver.setFeature
>>>      
>>>
>(pullDriver.FEATURE_REPORT_NAMESPACE_ATTRIBUTES,true);
>  
>
>>>And get the following error
>>>
>>>org.xmlpull.v1.XmlPullParserException: unknown feature 
>>>      
>>>
>http://xmlpull.org/v1/doc/features.html#report-namespace-prefixes
>  
>
>>>at org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:554)
>>>at test.test.<init>(test.java:19)
>>>at test.test.main(test.java:27)
>>>
>>>Am I doing something wrong?
>>>
>>>      
>>>
>>hi Sean,
>>
>>you are not doing anything wrong instead you have found bug in our 
>>documentation (thanks!) as this feature was supposed to be optional 
>>(this how unit tests check for it) and it is currently not 
>>    
>>
>implemented 
>  
>
>>in MXP1. i will fix documentation about it soon.
>>
>>also implementing it in MXP1 is on my TODO queue but i can not tell 
>>    
>>
>when 
>  
>
>>i may get around to have it done however i wonder why do you want 
>>    
>>
>to use 
>  
>
>>it? even if this feature is off you can still access all namespace 
>>declarations just you can not reproduce exact order of all 
>>    
>>
>attributes. 
>  
>
>>how important support for it is to you? let me know and i can move 
>>    
>>
>it to 
>  
>
>>higher priority TODO queue if necessary :-)
>>
>>thanks,
>>
>>alek
>>
>>-- 
>>"Mr. Pauli, we in the audience are all agreed that your theory is 
>>    
>>
>crazy. 
>  
>
>>What divides us is whether it is crazy enough to be true." Niels H. 
>>    
>>
>D. Bohr
>
>
>
>To unsubscribe from this group, send an email to:
>[email protected]
>
> 
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
>
>
>  
>

-- 
"Mr. Pauli, we in the audience are all agreed that your theory is crazy. 
What divides us is whether it is crazy enough to be true." Niels H. D. Bohr



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/LIgTpC/vN2EAA/xGHJAA/2U_rlB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/