You now can match on attributes too. The attributes: arguments can be any 
attribute specification object or just an ordinary dict or other association 
collection (nil values mean a key just must be present with any value).
 
And there is visitor pattern support so you don't have to define polymorphic 
extension methods on every node class or use a bunch of isWhatever testing 
messages when tree traversing.

> Sent: Friday, March 18, 2016 at 10:17 AM
> From: "Peter Uhnák" <i.uh...@gmail.com>
> To: "Pharo Users List" <pharo-users@lists.pharo.org>
> Subject: [Pharo-users] Generating custom classes based on attributes from XML 
> Document
> 
> I have a XML like this 
>  
> 
> <packagedElement xmi:type="uml:Class" xmi:id="EAID_4A" name="DCEdge" 
> isAbstract="true">
>     <!-- some stuff -->
> </packagedElement>
> <packagedElement xmi:type="uml:Association" xmi:id="EAID_46">
>     <!-- some stuff -->
> </packagedElement>
>  
> and I would like to generate UmlClass and UmlAssociation classes for this.
>  
> I could use XMLPluggableElementFactory, however that only allows me to 
> specify the target class only on the element's name, such as
>  
> 
> doc := (XMLDOMParser on: someXML)
> nodeFactory:
> (XMLPluggableElementFactory new
> elementClass: GenericElement;
> handleElement: 'packagedElement' withClass: UmlPackagedElement)
> parseDocument.
>  
> However I need better granularity, because I would like to have a different 
> class for 'packagedElement[xmi:type="uml:Class"]' and different class for 
> 'packagedElement[xmi:type="uml:Association"]'.
>  
> Of course I could use double visitors (so use the Pluggable stuff to get 
> UmlPackagedElement) and then make another pass on it to get the final classes,
>  
> however I would prefer to have to wanted class directly without the need to 
> go through intermediate representation.
>  
> Is there a way to do this?
>  
> Thanks,
> Peter
>  

Reply via email to