abdera-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
Subject Re: extensionfactory to handle bad namespace
Date Tue, 06 Nov 2007 00:54:25 GMT
Will do; this is on my list of things to look at very soon.  Right now
I'm focusing on making some general performance improvements.

- James

Woody Anderson wrote:
> so this is my current solution:
> 
>             Reader reader = response.getReader();
>             String docStr = StreamUtils.getString( reader );
> 
>            docStr = docStr.replace( "http://purl.org/atom/ns#",
> 
> "http://www.w3.org/2005/Atom" );
>             Parser parser = ABDERA.getParser();
>             Document<Entry> doc =  parser.parse( new StringReader( docStr ) );
> 
> which works but is clearly a complete hack.
> if it becomes easier to alias this namespace or handle this with an
> extension factory, please let me know.
> -w
> 
> On 10/31/07, Woody Anderson <woody@xoopit.com> wrote:
>> ok. i tried to do this, but it seems i'm not understanding something
>> with regard to the getElementWrapper method.. and now the mimetype
>> (per Element?)
>>
>>     public class AliasNamespacesFactory implements ExtensionFactory {
>>         HashSet<String> _namespaces = new HashSet<String>();
>>         public AliasNamespacesFactory( Set<String> namespaces ) {
>>             _namespaces.addAll( namespaces );
>>         }
>>
>>         public <T extends Element> T getElementWrapper(Element internal) {
>>           // ????????
>>         }
>>
>>         public <T extends Base> String getMimeType(T base) {
>>             // ??????????
>>         }
>>
>>         public String[] getNamespaces() {
>>             return _namespaces.toArray( new String[ _namespaces.size() ] );
>>         }
>>
>>         public boolean handlesNamespace(String namespace) {
>>             return _namespaces.contains( namespace );
>>         }
>>     }
>>
>>
>> do i have to have a if/else to instantiate FOMEntry, FOMLink, etc.. ?
>> most of the constructors are protected, which makes that sort of a non-starter.
>>
>> FOMFactory seems to have a lot of methods, but these take objects that
>> i don't have at my disposal. And these seem much more geared toward
>> creation for population, not for cloning or refacing an existing
>> "Element".
>>
>> do i need to basically recreate the FOMFactory for myself? and
>> subsequently all of the objects?
>>
>> on a complete hack approach:
>> if i ask the ClientResponse for a reader and put the entire response
>> in a string replacing the namespace with the "correct" namespace. i
>> could just ask for the default parser and continue right?
>> i mean this would be ugly in the extreme, but it sounds only slightly
>> worse than recreating the entire FOM factory just to change broken-ns
>> to atom-ns.
>>
>> and the only other way i see to get in front of the system is to front
>> a stream reader via. createXMLStreamReader, but that seems tied up in
>> axiom.. which is an extra helping of confusing.
>>
>> thoughts?
>> -w
>>
>> On 10/31/07, James M Snell <jasnell@gmail.com> wrote:
>>> Ok, this is actually somewhat difficult right now but definitely
>>> possible.  What you'd need to do is create a custom ExtensionFactory
>>> implementation (that does not extend AbstractExtensionFactory) and use
>>> that to create the appropriate objects.  The getElementWrapper method is
>>> not required to return an instance of an actual ElementWrapper subclass.
>>>
>>> It would take a bit of work to do, because the internal element passed
>>> in to getElementWrapper would need to be used to create a new instance
>>> of the appropriate FOM impl.
>>>
>>> It's entirely possible that this could be made easier.
>>>
>>> - James
>>>
>>> Woody Anderson wrote:
>>>> hello,
>>>>
>>>> i'm getting an errant namespace in responses from various servers.
>>>>
>>>> e.g.
>>>> <?xml version="1.0" encoding="utf-8"?>
>>>> <entry xmlns="http://purl.org/atom/ns#">
>>>>   <title xmlns="http://purl.org/atom/ns#">Example Title</title>
>>>>   <summary xmlns="http://purl.org/atom/ns#">Example Text</summary>
>>>>   <content xmlns="http://purl.org/atom/ns#" mode="xml">
>>>>     <div xmlns="http://www.w3.org/1999/xhtml">Example Text</div>
>>>>   </content>
>>>>   <id xmlns="http://purl.org/atom/ns#">urn:lj:livejournal.com:atom1:username:number</id>
>>>>   <link xmlns="http://purl.org/atom/ns#" type="application/x.atom+xml"
>>>> rel="service.edit"
>>>> href="http://www.livejournal.com/interface/atom/edit/3" title="Example
>>>> Title"/>
>>>>   <link xmlns="http://purl.org/atom/ns#" type="text/html"
>>>> rel="alternate" href="http://username.livejournal.com/number.html"
>>>> title="Example Title"/>
>>>> </entry>
>>>>
>>>> i want to handle this as though it were a correctly namespaced entry.
>>>> all types of elements from this server comeback with this namespace,
>>>> so i need this for each of the model elements.
>>>>
>>>> I'm a bit confused about how i do this for all elements. I've been
>>>> looking at AbstractExtensionFactory.
>>>> and ExtensionFactory docs, but it is unclear what getElementWrapper()
>>>> is supposed to do to make it all "work".
>>>>
>>>> i would hope that it's fairly simple to consume this bogus namespace.
>>>>
>>>> i found an old example doing something *similar* that extended
>>>> FOMExtensionFactory (which no longer exists..) to handle an Atom03
>>>> feed. This example doesn't work anymore and was still pretty confusing
>>>> as it seemed to work for Feed only.
>>>>
>>>> is there a simple way to handle this errant ns?
>>>> thanks
>>>> -w
>>>>
> 

Mime
View raw message