Merge-AsXml2Xml.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# Merge-AsXml2Xml.ps1
#
function Merge-AsXml2Xml {
    <#
    .SYNOPSIS
     Merges input xml file into output one
    .DESCRIPTION
     Will rewrite output
    .EXAMPLE
    # Simple use
      Merge-AsXml2Xml -InputXml="in.someml" -OutputXml="out.someml"
    #>
    
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory=$True)]
        [string]$InputXml,

        [Parameter(Mandatory=$True)]
        [string]$OutputXml

    )

    [TreeWalk.Runner]::Defaults
    [TreeWalk.Runner]::runnerType = "Tree"    
    [TreeWalk.Runner]::outputProcessorType = "Merge"
    [TreeWalk.Runner]::inputType = ".xml"    

    $InputFullPath = ""

    if(![System.IO.Path]::IsPathRooted($InputXml)) {
        $InputFullPath = "$Env:BASEPATH\$InputXml"
    } else {
        $InputFullPath = "$InputXml"
    }

    $OutFullPath = ""

    if( ![System.IO.Path]::IsPathRooted($OutputXml) ) {
        $OutFullPath = "$Env:BASEPATH\$OutputXml"
    } else { 
        $OutFullPath = "$OutputXml"
    }

    [TreeWalk.Runner]::Run($InputFullPath,$OutFullPath,"")
     
}