File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Language function XML {
2+ <#
3+ . SYNOPSIS
4+ XML Template Transpiler.
5+ . DESCRIPTION
6+ Allows PipeScript to generate XML.
7+
8+ Multiline comments blocks like this ```<!--{}-->``` will be treated as blocks of PipeScript.
9+ #>
10+ [ValidatePattern (' \.xml$' )]
11+ param ()
12+
13+ # We start off by declaring a number of regular expressions:
14+ $startComment = ' <\!--' # * Start Comments ```<!--```
15+ $endComment = ' -->' # * End Comments ```-->```
16+ $Whitespace = ' [\s\n\r]{0,}'
17+ # * StartPattern ```$StartComment + '{' + $Whitespace```
18+ $startPattern = " (?<PSStart>${startComment} \{$Whitespace )"
19+ # * EndPattern ```$whitespace + '}' + $EndComment```
20+ $endPattern = " (?<PSEnd>$Whitespace \}${endComment} \s{0,})"
21+
22+ $ForeachObject = {
23+ $in = $_
24+ if (($in -is [string ]) -or
25+ ($in.GetType -and $in.GetType ().IsPrimitive)) {
26+ $in
27+ } elseif ($in.ChildNodes ) {
28+ foreach ($inChildNode in $in.ChildNodes ) {
29+ if ($inChildNode.NodeType -ne ' XmlDeclaration' ) {
30+ $inChildNode.OuterXml
31+ }
32+ }
33+ } else {
34+ $inXml = (ConvertTo-Xml - Depth 100 - InputObject $in )
35+ foreach ($inChildNode in $inXml.ChildNodes ) {
36+ if ($inChildNode.NodeType -ne ' XmlDeclaration' ) {
37+ $inChildNode.OuterXml
38+ }
39+ }
40+ }
41+ }
42+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments