File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -618,6 +618,44 @@ local html = import 'html.libsonnet';
618
618
},
619
619
],
620
620
},
621
+ {
622
+ name: 'parseXmlJsonml' ,
623
+ params: ['str' , 'preserveWhitespace=false' ],
624
+ availableSince: 'upcoming' ,
625
+ description: [
626
+ html.p({}, |||
627
+ Parses a XML string to <a href="http://www.jsonml.org/">JsonML</a>-encoded value. The XML should only contain
628
+ one root node.
629
+ ||| ),
630
+ html.p({}, |||
631
+ By default, all the boundary whitespace would be trimmed. It could be preserved using <code>preserveWhitespace</code>
632
+ argument of the function.
633
+ ||| ),
634
+ ],
635
+ examples: [
636
+ {
637
+ input: "std.parseXmlJsonml('<svg height=\" 100\" width=\" 100\" ><circle cx=\" 50\" cy=\" 50\" fill=\" red\" r=\" 40\" stroke=\" black\" stroke-width=\" 3\" ></circle></svg>')" ,
638
+ output: [
639
+ "svg" ,
640
+ {
641
+ "height" : "100" ,
642
+ "width" : "100"
643
+ },
644
+ [
645
+ "circle" ,
646
+ {
647
+ "cx" : "50" ,
648
+ "cy" : "50" ,
649
+ "fill" : "red" ,
650
+ "r" : "40" ,
651
+ "stroke" : "black" ,
652
+ "stroke-width" : "3"
653
+ }
654
+ ]
655
+ ],
656
+ },
657
+ ],
658
+ },
621
659
{
622
660
name: 'encodeUTF8' ,
623
661
params: ['str' ],
Original file line number Diff line number Diff line change @@ -1785,4 +1785,6 @@ limitations under the License.
1785
1785
sha3(str):: go_only_function,
1786
1786
1787
1787
trim(str):: std.stripChars(str, ' \t\n\f\r\u0085\u00A0 ' ),
1788
+
1789
+ parseXmlJsonml(str):: go_only_function,
1788
1790
}
You can’t perform that action at this time.
0 commit comments