Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (https://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   Read nodes from an XML file (https://www.kinook.com/Forum/showthread.php?t=2944)

teognost 08-22-2007 02:33 PM

Read nodes from an XML file
 
I have an XML file like:


revision="28617">
John Doe
2007-08-21T13:51:44.617641Z

action="M">/sources/trunk/Controls/Grids/MyGrid.cs
action="A">/sources/trunk/3rdPartyLibs/Infragistics/Infragistics2.Win.UltraWinGrid.ExcelExport.v7.1.xm l
action="M">/sources/trunk/MyProj/Pro.csproj

Issue: Fixed some error...

revision="28618">
me
2007-08-21T14:11:50.500926Z

action="M">/sources/trunk/Exchange/Server/Triggers/TriggerProvider.cs
action="M">/sources/trunk/Exchange/Server/OrderControllers/OrderControler.cs
action="M">/sources/trunk/Exchange/Server/Sessions/Wrapper.cs

Issue: Removed Trigger



I need to read all the paths and to put them in a text file line by line.
Any idea how I can do this in VBP?
I looked at the sample XML.bld but there is a different parsing ,for attributes,I did not succed to pars it the way I need...
Thanks for any help

kinook 08-22-2007 04:12 PM

1 Attachment(s)
Using an XSL transform would be one way (see attached sample).

teognost 08-23-2007 07:34 AM

Thanks a lot,it works perfectly!
I just noticed sometimes the paths are not unique as the same file was modified in multiple revisions.Is it possible to change the XSL file in order to produce unique paths (every path should appear only once)?(I do not have any experience with XSL)
Or I should parse separately the output text fle in order to create another text file with unique paths?

kinook 08-23-2007 12:15 PM

In the 'Create XSL file' step, replace



with


teognost 08-24-2007 04:21 AM

Tried that but the step fails:
8/24/2007 11:19:59 AM: Building project step 'Generate text file(containing paths)'...
Loading XML input document...
Loading XSLT stylesheet...
Initializing XSLT processor...
Expression expected.

//path[-->[<--not(.=preceding::path)]]
8/24/2007 11:19:59 AM: Step 'Generate text file(containing paths)' failed
8/24/2007 11:19:59 AM: Build ended.

XSL file looks now like this:












kinook 08-24-2007 07:32 AM

Please ZIP and send or post:
1) The info from Help | About | Install Info
2) The version(s) of MSXML installed (listed in Add/Remove Programs)

teognost 08-24-2007 07:46 AM

1)
Visual Build Professional 6.3
Registered to: xxxxxxxxxx (1-computer license)
Windows Version: 5.1.2600.2.0
Install path: D:\Program Files\VisBuildPro6
SftTree_IX86_U_50.dll version 5.05
unins000.exe version 51.46.0.0
VisBuildCmd.exe version 6.3.0.0
VisBuildPro.exe version 6.3.0.0
VisBuildBld.dll version 6.3.0.0
VisBuildBurn.dll version 6.3.0.0
VisBuildCore.dll version 6.3.0.0
VisBuildDotNET.dll version 6.3.0.0
VisBuildExt.dll version 6.3.0.0
VisBuildLog.dll version 6.3.0.0
VisBuildMisc.dll version 6.3.0.1
VisBuildMS.dll version 6.3.0.0
VisBuildMS2.dll version 6.3.0.0
VisBuildNet.dll version 6.3.0.0
VisBuildSvr.dll version 6.3.0.0
VisBuildSvr.Interop.dll version 1.0.0.0
VisBuildVCS.dll version 6.3.0.0

2)It appears MSXML 4.0 SP2 and also MSXML 6.0 parser

kinook 08-24-2007 07:51 AM

If you're putting the expression in the XSLT file itself (rather than the Create XSL File step as suggested), use single brackets instead of double:


teognost 08-24-2007 08:00 AM

Thanks,with single brackets works ok:

teognost 08-24-2007 09:55 AM

Well,another issue appeared :-(
I need to read line by line the text file produced by transformation.
I use a set macro step in order set a macro CURRENT_LINE to value
[vbld_TempMacroObj("FILE").ReadLine()]
However -the macro remains empty.
I tried even to set a macro FILE_CONTENT to value:
[vbld_GetFileContents("%CHANGED_FILES_TXT%")] but the resulting value is always :
˙ž/
I do not understand what is the issue...

teognost 08-24-2007 10:09 AM

Ok,I finally got it,text file is encoded in Unicode so it should be read like this:
[vbld_EscapeString(vbld_FSO.OpenTextFile("%CHANGED_FILES_TXT%", , , True).ReadAll)]

kinook 08-24-2007 11:40 AM

1 Attachment(s)
You originally indicated you wanted to put the values into a text file. To instead iterate over the matches within VBP, just use that XPath expression in an MSXML query (see attached sample).

teognost 08-24-2007 11:54 AM

I see,thanks a lot for sample!

teognost 08-30-2007 07:37 AM

In the last sample (transform3.bld)-how can I write in log-step "Do stuff with node value"- >for every path the related revision (written in revision="xxxxx">)?
Basically one logentry has one revision and multiple paths.

kinook 08-30-2007 08:25 AM

1 Attachment(s)
Attached.

teognost 08-30-2007 08:49 AM

Thank you very much!

teognost 09-04-2007 12:47 PM

Another thing appeared-in the last sample transform4.bld,one extra requirement appeared->how can I query only path nodes containing string :
sources/trunk/Exchange ?
(still they should be shown only once )

kinook 09-04-2007 04:24 PM

1 Attachment(s)
Attached.

teognost 09-05-2007 08:55 AM

Thanks.Is there any documentation somewhere about this kind of syntax you use for reading XML nodes?
I would like to avoid to bother you in case some other changes would be needed...

kinook 09-05-2007 09:18 AM

http://www.google.com/search?q=xpath%20reference

teognost 12-02-2009 08:43 AM

1 Attachment(s)
Hi
I have another issue now,I studied the link u provided and I thought I implemented the XML step correctly but it seems I made a mistake.
I have an XML file contaiing a list of SVN changes.
I need to create a list with all the files changed for a specific string appearing in -but taken only once (same file should not appear twice)
For example –I need to get a list with all the files changed for F0026703 –therefore I will search all the path nodes having a msg that contains F0026703 and taake them only once:

vbld_TempMacros().Add "NODELIST", msxml.selectNodes("//path[[not(.=preceding::path) and ../../msg[[contains(., '%CURRENT_HB_NUMBER%')]] ]]")

where CURRENT_HB_NUMBER is set to F0026703

This works fine but I have a problem when string to search is F0026704-as it does read only one path :
/branches/ecl/10.X/char/sh/dwh_feed_mappingBBB.sh
And does not read paths /branches/ecl/10.X/char/sh/dwh_acc_settl.sh, /branches/ecl/10.X/char/sh/dwh_trades.sh ,etc –although they appear only in previous logentry for F0026703 –so they should be read as well.
Any idea how to correct the XPath above in order to achieve what I need?

I attached a sample VBP project

XML file looks like this:


revision="24772">
johnk
2009-11-24T13:20:48.707927Z

kind=""
action="M">/branches/ecl/10.X/char/c/ec_feed_liffe_v4.c
kind=""
copyfrom-path="/trunk/char/c/ec_feed_liffe_v5.c"
copyfrom-rev="24755"
action="A">/branches/ecl/10.X/char/c/ec_feed_liffe_v5.c
kind=""
action="M">/branches/ecl/10.X/char/c/ec_feed.c
kind=""
action="M">/branches/ecl/10.X/char/c/ec_feed.h

F0026325: Patch 3331 Merged from trunk, file list:
ec_feed.c 8.36 -> 8.37 F0031033: Changes made to support.


revision="24835">
maks
2009-11-25T15:07:42.016178Z

kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_acc_settl.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_trades.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_acc_equity.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_contact_master.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_account_master.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_exe_ass.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_accounting_transx.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_nett_posn.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_exe_brok.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_feed_mapping.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_feed_mappingAAA.sh

F0026703: Patch 3256 Merged from trunk, file list:
dwh_acc_equity.sh 9.4 -> 9.5 F0026703 Change BATCH_DIR


revision="24836">
maks
2009-11-25T16:07:42.016178Z

kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_acc_settl.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_trades.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_acc_equity.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_contact_master.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_account_master.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_exe_ass.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_accounting_transx.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_nett_posn.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_exe_brok.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_feed_mapping.sh
kind=""
action="M">/branches/ecl/10.X/char/sh/dwh_feed_mappingBBB.sh

F0026703,F0026704: Patch 3256 Merged from trunk, file list:
dwh_acc_settl.sh 9.4 -> 9.5 F0026703 Change BATCH_DIR to COMPANY


revision="24972">
johnk
2009-11-24T19:20:48.707927Z

kind=""
copyfrom-path="/trunk/char/c/ec_feed_liffe_v5.c"
copyfrom-rev="24755"
action="A">/branches/ecl/10.X/char/c/ec_feed_liffe_v5.c
kind=""
action="M">/branches/ecl/10.X/char/c/ec_feed.h

F0026325: Patch 1111 Merged from trunk, file list:
ec_feed.h 8.36 -> 8.37 F0026325: Changes made to support.



teognost 12-02-2009 10:28 AM

Finally I solved it,instead of :
vbld_TempMacros().Add "NODELIST", msxml.selectNodes("//path[[not(.=preceding::path) and ../../msg[[contains(., '%CURRENT_HB_NUMBER%')]] ]]")
I use now:
vbld_TempMacros().Add "NODELIST", msxml.selectNodes("//path[[not(.=preceding::path[[../../msg[[contains(., '%CURRENT_HB_NUMBER%')]] ]]) and ../../msg[[contains(., '%CURRENT_HB_NUMBER%')]] ]]")


All times are GMT -5. The time now is 07:46 AM.


Copyright © 1999-2023 Kinook Software, Inc.