How to access XML tag name?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
25 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: How to access XML tag name?

stepharo
So I wonder why Fabrizio did OPAX do you have an idea?
You get a simple tree but it is worth?
I will finish my improvement on OPAX.

Stef

This class is a pluggable factory that can map elements to different
XMLElement subclasses based on the name and namespace information of
those elements. You have to create an instance, configure it to handle
certain elements with certain classes, and then inject your instance
into a DOM parser using #nodeFactory: before parsing. Here is an example
of its use:

     doc := (XMLDOMParser on: someXML)
         nodeFactory:
             (XMLPluggableElementFactory new
                 elementClass: GenericElement;
                 handleElement: 'user' withClass: UserElement;
                 handleElement: 'report' withClass: ReportElement;
                 handleElement: 'report' namespaceURI:
'urn:specialreprot' withClass: SpecialReportElement)
         parseDocument.

The #handleElementsMatchingClass*: forms try to match elements to the
specified classes based on the names of those classes when stripped of
any prefix (like XML) and "Element" suffix and converted to both camel
case and a hyphenated form. So this:
     XMLPluggableElementFactory new
         handleElementsMatchingClass: MYRootUserElement
         ....
will handle 'rootUser' and 'root-user' elements with the
MYRootUserElement class.

Reply | Threaded
Open this post in threaded view
|

Re: How to access XML tag name?

stepharo
In reply to this post by abergel
Ok I checked it and there is only one class in the package.

Stef

Le 13/3/16 16:27, Alexandre Bergel a écrit :

> Pastell is an implementation of XPath. But I had a look at it many years ago (when I was extracting data from srcML xml files, you remember? :-)
>
> Alexandre
>
>
>> On Mar 13, 2016, at 1:39 PM, stepharo <[hidden email]> wrote:
>>
>> Alex
>>
>> what Pastell brings compared to XPath?
>>
>> Stef
>>


Reply | Threaded
Open this post in threaded view
|

Re: How to access XML tag name?

stepharo
In reply to this post by Tudor Girba-2


Le 13/3/16 14:33, Tudor Girba a écrit :
> XPath is better than Pastell. That is why in Moose we now have XPath.\

Yes this is my impression and I checked the implementation and there is
only one class
extending XPath.

Stef

>
> Doru
>
>> On Mar 13, 2016, at 1:49 PM, stepharo <[hidden email]> wrote:
>>
>> Alex
>>
>> I saw that Pastell is only tagged for Pharo30 and has not metadata.
>> It would be good to revise it.
>>
>> Stef
>>
> --
> www.tudorgirba.com
> www.feenk.com
>
> "Every successful trip needs a suitable vehicle."
>
>
>
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: How to access XML tag name?

Tudor Girba-2
In reply to this post by stepharo
Hi,

I did OPAX :). At one point there was an effort around NodeFactory, and we chose to improve that one.

Cheers,
Doru

> On Mar 13, 2016, at 4:57 PM, stepharo <[hidden email]> wrote:
>
> So I wonder why Fabrizio did OPAX do you have an idea?
> You get a simple tree but it is worth?
> I will finish my improvement on OPAX.
>
> Stef
>
> This class is a pluggable factory that can map elements to different XMLElement subclasses based on the name and namespace information of those elements. You have to create an instance, configure it to handle certain elements with certain classes, and then inject your instance into a DOM parser using #nodeFactory: before parsing. Here is an example of its use:
>
>    doc := (XMLDOMParser on: someXML)
>        nodeFactory:
>            (XMLPluggableElementFactory new
>                elementClass: GenericElement;
>                handleElement: 'user' withClass: UserElement;
>                handleElement: 'report' withClass: ReportElement;
>                handleElement: 'report' namespaceURI: 'urn:specialreprot' withClass: SpecialReportElement)
>        parseDocument.
>
> The #handleElementsMatchingClass*: forms try to match elements to the specified classes based on the names of those classes when stripped of any prefix (like XML) and "Element" suffix and converted to both camel case and a hyphenated form. So this:
>    XMLPluggableElementFactory new
>        handleElementsMatchingClass: MYRootUserElement
>        ....
> will handle 'rootUser' and 'root-user' elements with the MYRootUserElement class.
>

--
www.tudorgirba.com
www.feenk.com

"Next time you see your life passing by, say 'hi' and get to know her."





Reply | Threaded
Open this post in threaded view
|

Re: How to access XML tag name?

stepharo


Le 13/3/16 18:46, Tudor Girba a écrit :
> Hi,
>
> I did OPAX :).

:)
So I'm doing a pass and cleaned it.
I created a small builder to generate subclasses and tags. I will
release it soon.
I will play with the FILMS xml to understand what can be a solution.

Then after I will check a bit more the pluggable.

> At one point there was an effort around NodeFactory, and we chose to improve that one.
>
> Cheers,
> Doru
>
>> On Mar 13, 2016, at 4:57 PM, stepharo <[hidden email]> wrote:
>>
>> So I wonder why Fabrizio did OPAX do you have an idea?
>> You get a simple tree but it is worth?
>> I will finish my improvement on OPAX.
>>
>> Stef
>>
>> This class is a pluggable factory that can map elements to different XMLElement subclasses based on the name and namespace information of those elements. You have to create an instance, configure it to handle certain elements with certain classes, and then inject your instance into a DOM parser using #nodeFactory: before parsing. Here is an example of its use:
>>
>>     doc := (XMLDOMParser on: someXML)
>>         nodeFactory:
>>             (XMLPluggableElementFactory new
>>                 elementClass: GenericElement;
>>                 handleElement: 'user' withClass: UserElement;
>>                 handleElement: 'report' withClass: ReportElement;
>>                 handleElement: 'report' namespaceURI: 'urn:specialreprot' withClass: SpecialReportElement)
>>         parseDocument.
>>
>> The #handleElementsMatchingClass*: forms try to match elements to the specified classes based on the names of those classes when stripped of any prefix (like XML) and "Element" suffix and converted to both camel case and a hyphenated form. So this:
>>     XMLPluggableElementFactory new
>>         handleElementsMatchingClass: MYRootUserElement
>>         ....
>> will handle 'rootUser' and 'root-user' elements with the MYRootUserElement class.
>>
> --
> www.tudorgirba.com
> www.feenk.com
>
> "Next time you see your life passing by, say 'hi' and get to know her."
>
>
>
>
>
>


12