I have the impression that I should also look at

������ XMLPluggableElementFactory new handleElement: 'NOM' withClass: AAAName.

Because it looks like that I inject my nodes inside the dom

Am I correct?


Le 12/3/16 21:59, Tudor Girba a ��crit��:
Hi,

My original work only survived for the XMLDOMParser. See this example:
http://ws.stfx.eu/NK2WLSW99X10
(paste this in Spotter :))

For an XMLDOMParser, you can say that you want to instantiate a node in the DOM with an custom instance. For example, here I instantiate <NOM> with AAAName:


You are looking for something a bit different. In a way you want to associate the triggering of a specific handler when some XPath like expression is being matched for the current element. I think something like this should go in the main implementation.

Cheers,
Doru



On Mar 12, 2016, at 9:33 AM, stepharo <stepharo@free.fr> wrote:

This is more complex than that.
Because I would like to have a visitor generated from the token I give.

And this
�� ��start
�� ��character
�� ��end

does not really help me.

Because in SAXHandler I have
�� �� �� ��start
�� �� �� �� �� ��where I should store the properties
�� �� �� same in characters:
�� �� �� �� �� ��to store the name
�� �� �� end
�� �� �� �� �� ��where I should invoke the visitor

Now it means that I should only store the information for the tag I want.
Does anybody already did that and publish it?
I know doru did that in the past.
I will try.

Stef



Le 11/3/16 14:17, Blondeau Vincent a ��crit :
Hi,

The qualified name in function startElement: aQualifiedName attributes: aDictionary, will be FILMS��and after FILM and after TITRE,...etc...
So, you have to tell to your shouldVisit: method to accept TITRE too and get in and after you��should implement characters: to get the content on the tag.

Vincent

-----Message d'origine-----
De : Pharo-users [mailto:pharo-users-bounces@lists.pharo.org] De la part de
stepharo
Envoy�� : vendredi 11 mars 2016 14:04
�� : Any question about pharo is welcome
Objet : [Pharo-users] How to access XML tag name?

Hi

Yesterday I started to hack a smart SAX handler. The idea is that I want to just
specify the tags I want to visit and the SAX handler should invoke (generated)
visit methods. Like that I can easily get visitors on XML domain.

Here is an example of what I did.

�� �� ��| h |
�� �� ��h := SmartSAXHandler new
�� �� �� �� �� �� �� �� ��visitor: (MyFilmVisitor new visitTags: #(FILM ROLE));
�� �� �� �� �� �� �� �� ��on: FileSystem workingDirectory / 'FILMS.XML'.
�� �� ��h parseDocument.
�� �� ��^ h



SmartSAXHAndler >> startElement: aQualifiedName attributes: aDictionary

�� �� ��(visitor shouldVisit: aQualifiedName)
�� �� �� �� ��ifTrue: [
�� �� �� �� �� �� �� �� ��visitor
�� �� �� �� �� �� �� �� �� �� ��perform: (visitor createdVisitSelector: aQualifiedName)
�� �� �� �� �� �� �� �� �� �� ��with: aQualifiedName
�� �� �� �� �� �� �� �� �� �� ��with: aDictionary
�� �� �� �� ��]


Object subclass: #GenericTagSAXVisitor
�� �� ��instanceVariableNames: 'visitTag visitTags'
�� �� ��classVariableNames: ''
�� �� ��category: 'SmartXMLHandler'


GenericTagSAXVisitor>>visitTags: aCollection
�� �� ��"set the tags that will lead to a call to a visitTag:with: method in the visitor"

�� �� ��visitTags := aCollection collect: [ :each | each asLowercase ].
�� �� ��self createVisitMethods.

and in a subclass the visit* methods automatically generated


Now I could not get when I have a <TITRE>Vertigo</TITRE> where I can get the
Vertigo information.
I redefined several methods of SAXhandler but without success.


<?xml version="1.0" encoding="iso-8859-1"?>
<FILMS>
�� ��<FILM annee="1958">
�� �� ��<TITRE>Vertigo</TITRE>
�� �� ��<GENRE>Drame</GENRE>
�� �� ��<PAYS>USA</PAYS>
�� �� ��<MES idref="3"/>
�� �� ��<ROLES>
�� �� �� ��<ROLE>
�� �� �� �� ��<PRENOM>James</PRENOM>
�� �� �� �� ��<NOM>Stewart</NOM>
�� �� �� �� ��<INTITULE>John Ferguson</INTITULE>
�� �� �� ��</ROLE>
�� �� �� ��<ROLE>
�� �� �� �� ��<PRENOM>Kim</PRENOM>
�� �� �� �� ��<NOM>Novak</NOM>
�� �� �� �� ��<INTITULE>Madeleine Elster</INTITULE>
�� �� �� ��</ROLE>
�� �� ��</ROLES>
�� �� ��<RESUME>Scottie Ferguson, ancien inspecteur de police, est sujet
au vertige depuis qu'il a vu mourir son
�� collegue. Elster, son ami, le charge de surveiller sa femme,
Madeleine, ayant des tendances
�� suicidaires. Amoureux de la jeune femme Scottie ne remarque pas le
piege qui se trame autour
�� de lui et dont il va etre la victime... </RESUME>
�� ��</FILM>

!!!*************************************************************************************
"Ce message et les pi��ces jointes sont confidentiels et r��serv��s �� l'usage exclusif de ses��destinataires. Il peut ��galement ��tre prot��g�� par le secret professionnel. Si vous recevez ce��message par erreur, merci d'en avertir imm��diatement l'exp��diteur et de le d��truire. L'int��grit�� du��message ne pouvant ��tre assur��e sur Internet, la responsabilit�� de Worldline ne pourra ��tre��recherch��e quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour��maintenir cette transmission exempte de tout virus, l'exp��diteur ne donne aucune garantie �� cet����gard et sa responsabilit�� ne saurait ��tre recherch��e pour tout dommage r��sultant d'un virus��transmis.

This e-mail and the documents attached are confidential and intended solely for the addressee; it��may also be privileged. If you receive this e-mail in error, please notify the sender immediately and��destroy it. As its integrity cannot be secured on the Internet, the Worldline liability cannot be��triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable��for any damages resulting from any virus transmitted.!!!"



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

"We can create beautiful models in a vacuum.
But, to get them effective we have to deal with the inconvenience of reality."