XPath Advanced query (contains, text()...) implemented?

Got a problem you cannot solve? Try here.
Damien
Posts: 14
Joined: Wed Dec 02, 2015 10:36 am

XPath Advanced query (contains, text()...) implemented?

Postby Damien » Wed Dec 02, 2015 11:35 am

Hi,
I m testing install aware X3 for my company, before decide to buy it or not.
I m currently testing some XPath queries, but I cant make some work.
I need to find a node if text contains something. I also tried with equals comparaison.

This is my InstallAware "human readable" code:

Code: Select all

Evaluate Query //Client[@Name="LePicard"]/Peripherique[contains(text(),"bbb")]/@Id on XML file $InstallerFilesPath$\Clients_Peripheriques.xml, get result into variable SelectedDeviceId as type Full XML String

and

Code: Select all

Evaluate Query //Client[@Name="LePicard"]/Peripherique[text()="bbb"]/@Id on XML file $InstallerFilesPath$\Clients_Peripheriques.xml, get result into variable SelectedDeviceId as type Full XML String


Equality works well with parameters:

Code: Select all

Evaluate Query //Client[@Name="LePicard"]/Peripherique[@TerminalName="bbb"]/@Id on XML file $InstallerFilesPath$\Clients_Peripheriques.xml, get result into variable SelectedDeviceId as type Full XML String

but not contains

Code: Select all

Evaluate Query //Client[@Name="LePicard"]/Peripherique[contains(@TerminalName,"bbb")]/@Id on XML file $InstallerFilesPath$\Clients_Peripheriques.xml, get result into variable SelectedDeviceId as type Full XML String

So are contains(), text() or other w3C recommandation xpath functions implemented?
Or if there is a different query to do this, how can I do it?

Thanks.

There is my XML code sample:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<Clients>
   <Client Name="Neolis">
      <Peripherique Id="1" TerminalName="Tab01" Type="Tablette">Tab01 - Tablette</Peripherique>
      <Peripherique Id="2" TerminalName="Tab02" Type="Tablette">Tab02 - Tablette</Peripherique>
      <Peripherique Id="3" TerminalName="Siege" Type="Serveur">Siege - Serveur</Peripherique>
   </Client>
   <Client Name="Boucheron">
      <Peripherique Id="4" TerminalName="Terminal 01" Type="Tablette">Terminal 01 - Tablette</Peripherique>
      <Peripherique Id="5" TerminalName="Terminal 02" Type="Tablette">Terminal 02 - Tablette</Peripherique>
      <Peripherique Id="6" TerminalName="Siege Boucheron" Type="Serveur">Siege Boucheron - Serveur</Peripherique>
   </Client>
   <Client Name="LePicard">
      <Peripherique Id="7" TerminalName="Tablette 01" Type="Tablette">Tablette 01 - Tablette</Peripherique>
      <Peripherique Id="8" TerminalName="Tablette 02" Type="Tablette">Tablette 02 - Tablette</Peripherique>
      <Peripherique Id="9" TerminalName="Maison Mere" Type="Serveur">Maison Mere - Serveur</Peripherique>
      <Peripherique Id="10" TerminalName="bbb" Type="Serveur">bbb</Peripherique>
   </Client>
</Clients>

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: XPath Advanced query (contains, text()...) implemented?

Postby FrancescoT » Wed Dec 02, 2015 2:42 pm

Dear Damien,

unfortunately xpath functions cannot be used.

You may alternatively use;
(copy and paste within the script editor the code below)

Code: Select all

~InstallAware Clipboard Data~
~MessageBox~
~{A6B0B67B-52C7-4AAA-A0D4-192BDFC44DA5}~
~~
~$XML_PATH$~
~0~
~1~
~~
~Evaluate XPath Query~
~{A71A5A87-B7C5-4E59-8252-B5C73716B7A3}~
~$SUPPORTDIR$\XMLFile2.xml~
~//Client[@Name="LePicard"]/Peripherique/@TerminalName~
~XML_PATH~
~2~
~Set Variable~
~{A62FEEB6-FB31-4BE3-B049-C8DEAFBBEBD7}~
~XML_PATH$MYAH$MYAH$FALSE~
~~


The above snippet returns the following node value (where each result is delineated with the $NEWLINE$ pre-defined variable);
Tablette 01
Tablette 02
Maison Mere
bbb


Finally you can use the "Parse String" command to split the value returned or alternatively you may use the IF statement, to operate a conditional evaluation based on the presence of a specific value.

Hope this helps you.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

Damien
Posts: 14
Joined: Wed Dec 02, 2015 10:36 am

Re: XPath Advanced query (contains, text()...) implemented?

Postby Damien » Thu Dec 03, 2015 9:55 am

Ok, thanks it help me .

I want to ask you something else i saw when i did comparaison:
I got a value from listbox (from XPATH Query), and when I compared it in a foreach loop on the same XPATH Query, nothing was matching with equality, or contains. I spend few hours to finaly write output in a file, and understand the selected value on the listbox contains the $NEWLINE$ var, and not the item on the foreach iteration.

So, is there a way to prevent this, to only get the real value? or should I parse listbox ouput var?

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: XPath Advanced query (contains, text()...) implemented?

Postby FrancescoT » Thu Dec 03, 2015 12:30 pm

Dear Damien,

I am not quite sure to follow your question.

In case you are referring to the "value format" returned from a Listbox, this depends on the listbox's items selection.
If multiple values are returned these will be delineated with the $NEWLINE$ pre-defined variable.

Hope this helps you.
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

Damien
Posts: 14
Joined: Wed Dec 02, 2015 10:36 am

Re: XPath Advanced query (contains, text()...) implemented?

Postby Damien » Tue Dec 15, 2015 6:11 am

Sorry, i was not working last week.

The listbox is not in multi select mode.
The listbox items : item1$NEWLINE$item2$NEWLINE$item3

Code: Select all

Set variable SelectedItem to   // listBox variable output
Set variable Item to item1 // at runtime I select item1 in listbox
Set variable Equality to false

if SelectedItem equals Item
   Set Equality to true
end
MessageBox: Selected Item, Select Item : $SelectedItem$  $NEWLINE$ $SelectedItem$ equals $Item$ : $Equality$


I really dont understand why this is implemented like this, the selected item must not contain the separator on single select... Or did I missed a listbox option?

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: XPath Advanced query (contains, text()...) implemented?

Postby FrancescoT » Tue Dec 15, 2015 11:59 am

Dear Damien,

for example, you should instead;

Code: Select all

Set Variable SELECTED_VALUES to
Set Variable LISTBOXVALUES to DSN1$NEWLINE$DSN2$NEWLINE$DSN3$NEWLINE$DSN4
Display Dialog: prereq, wait for dialog to return (modal) // Display the Dialog with the ListBox
 
Comment: ListBox selection is returned to SELECTED_VALUES variable!
MessageBox: Debug, ListBox selection:$NEWLINE$$SELECTED_VALUES$
 
Set Variable ITEMS_SELECTED to 0
Set Variable EQUALITY to FALSE
 
for each Element ELEMENT in $NEWLINE$ delimited Collection of $SELECTED_VALUES$ do
 ITEMS_SELECTED = $ITEMS_SELECTED$ + 1
 if Variable ELEMENT Equals DSN2
   Set Variable EQUALITY to TRUE
 end
next
 
MessageBox: Debug, ITEMS_SELECTED = $ITEMS_SELECTED$$NEWLINE$EQUALITY = $EQUALITY$
 
Terminate Installation


The same code snippet as InstallAware Clipboard format

Code: Select all

~InstallAware Clipboard Data~
~Terminate Install~
~{598254F2-48CE-43CC-9810-523170007C17}~
~Comment~
~{EFC3F6E6-FB30-4939-9625-28D62F0F5DAA}~
~~
~MessageBox~
~{61CFFF75-5146-4E0A-8071-9939AE6B05E3}~
~Debug~
~ITEMS_SELECTED = $ITEMS_SELECTED$$NEWLINE$EQUALITY = $EQUALITY$~
~0~
~1~
~~
~Comment~
~{19D0DFC1-EABF-4A1F-8BD5-BD754A4C8F9E}~
~~
~Next~
~{55792259-CF7A-4215-A2FB-A57E293B6825}~
~End~
~{104DB8F0-6E29-472F-8FDE-F626B03323F2}~
~Set Variable~
~{F03730A0-5411-419E-B8E3-30D48276DC69}~
~EQUALITY$MYAH$MYAH$FALSE~
~TRUE~
~If~
~{6BC155A9-A70D-4BF2-A593-6668FE62BE78}~
~ELEMENT~
~0~
~DSN2~
~FALSE~
~Mathematics~
~{92CFCB5E-B190-4CC4-A928-B9A9C774D640}~
~$ITEMS_SELECTED$~
~1~
~0~
~ITEMS_SELECTED~
~For Each~
~{80DF299C-4755-4642-A7CF-BA71E0AAFA5E}~
~ELEMENT~
~$NEWLINE$~
~$SELECTED_VALUES$~
~Comment~
~{ECA2C130-CD0F-47B6-878B-AE417D914E39}~
~~
~Set Variable~
~{3DB90367-CDD0-44C1-B8DA-DCA23E06E7C8}~
~EQUALITY$MYAH$MYAH$FALSE~
~FALSE~
~Set Variable~
~{2BB58626-1924-4983-88DA-FB16209A9714}~
~ITEMS_SELECTED$MYAH$MYAH$FALSE~
~0~
~Comment~
~{D9624FAB-10D0-4CCB-A70F-B4A8442C26FA}~
~~
~MessageBox~
~{F65228F3-0609-4948-87A1-D0586304352F}~
~Debug~
~ListBox selection:$NEWLINE$$SELECTED_VALUES$~
~0~
~1~
~~
~Comment~
~{AB1192B1-195B-46D9-AC48-CEF881A515B3}~
~ListBox selection is returned to SELECTED_VALUES variable!~
~Comment~
~{5A4258A8-C67B-4384-8856-E3ECF6DD1CF0}~
~~
~Display Dialog~
~{47558114-CD00-4B6B-B6A0-906ECA77A5A1}~
~prereq~
~WIZARD~
~TRUE~
~~
~TRUE~
~FALSE~
~Set Variable~
~{EB541933-F411-43CF-A079-8149A8D229E6}~
~LISTBOXVALUES$MYAH$MYAH$FALSE~
~DSN1$NEWLINE$DSN2$NEWLINE$DSN3$NEWLINE$DSN4~
~Set Variable~
~{65D0194D-4A66-4C64-8817-6B424158D90E}~
~SELECTED_VALUES$MYAH$MYAH$FALSE~
~~


Hope this helps you.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 179 guests