Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-22-2007, 02:33 PM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
Read nodes from an XML file

I have an XML file like:
<?xml version="1.0"?>
<log>
<logentry
revision="28617">
<author>John Doe</author>
<date>2007-08-21T13:51:44.617641Z</date>
<paths>
<path
action="M">/sources/trunk/Controls/Grids/MyGrid.cs</path>
<path
action="A">/sources/trunk/3rdPartyLibs/Infragistics/Infragistics2.Win.UltraWinGrid.ExcelExport.v7.1.xm l</path>
<path
action="M">/sources/trunk/MyProj/Pro.csproj</path>
</paths>
<msg>Issue: Fixed some error...</msg>
</logentry>
<logentry
revision="28618">
<author>me</author>
<date>2007-08-21T14:11:50.500926Z</date>
<paths>
<path
action="M">/sources/trunk/Exchange/Server/Triggers/TriggerProvider.cs</path>
<path
action="M">/sources/trunk/Exchange/Server/OrderControllers/OrderControler.cs</path>
<path
action="M">/sources/trunk/Exchange/Server/Sessions/Wrapper.cs</path>
</paths>
<msg>Issue: Removed Trigger</msg>
</log>


I need to read all the paths <path> 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
Reply With Quote
  #2  
Old 08-22-2007, 04:12 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Using an XSL transform would be one way (see attached sample).
Attached Files
File Type: bld transform.bld (2.7 KB, 3130 views)
Reply With Quote
  #3  
Old 08-23-2007, 07:34 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
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?
Reply With Quote
  #4  
Old 08-23-2007, 12:15 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
In the 'Create XSL file' step, replace

<xsl:for-each select="//path">

with

<xsl:for-each select="//path[[not(.=preceding::path)]]">
Reply With Quote
  #5  
Old 08-24-2007, 04:21 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
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:
<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>

<xsl:template match="/">
<xsl:for-each select="//path[[not(.=preceding::path)]]">
<xsl:value-of select="."/><xsl:text>&#xD;&#xA;</xsl:text>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>
Reply With Quote
  #6  
Old 08-24-2007, 07:32 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
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)
Reply With Quote
  #7  
Old 08-24-2007, 07:46 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
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
Reply With Quote
  #8  
Old 08-24-2007, 07:51 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
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:

<xsl:for-each select="//path[not(.=preceding::path)]">
Reply With Quote
  #9  
Old 08-24-2007, 08:00 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
Thanks,with single brackets works ok:
<xsl:for-each select="//path[not(.=preceding::path)]">
Reply With Quote
  #10  
Old 08-24-2007, 09:55 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
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...
Reply With Quote
  #11  
Old 08-24-2007, 10:09 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
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)]
Reply With Quote
  #12  
Old 08-24-2007, 11:40 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
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).
Attached Files
File Type: bld transform3.bld (3.1 KB, 2615 views)
Reply With Quote
  #13  
Old 08-24-2007, 11:54 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
I see,thanks a lot for sample!
Reply With Quote
  #14  
Old 08-30-2007, 07:37 AM
teognost teognost is online now
Registered User
 
Join Date: 05-25-2004
Location: Prague,Czech Republic
Posts: 200
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 <logentry
revision="xxxxx">)?
Basically one logentry has one revision and multiple paths.
Reply With Quote
  #15  
Old 08-30-2007, 08:25 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Attached.
Attached Files
File Type: bld transform4.bld (3.2 KB, 2821 views)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 06:45 AM.


Copyright © 1999-2023 Kinook Software, Inc.