Add cdata manipulators
Clanker: claude-sonnet_4.6
This commit is contained in:
parent
154647083c
commit
c694fe8b17
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Sprache;
|
||||
using XNeedle.Parser;
|
||||
using XNeedle.Parser.Elements;
|
||||
@ -45,6 +46,28 @@ namespace XNeedle.Transformation
|
||||
return txt;
|
||||
}
|
||||
|
||||
public static string cdata(Context ctx)
|
||||
{
|
||||
if (ctx.Node is null) return "";
|
||||
var cdataNode = ctx.Node.Nodes().OfType<System.Xml.Linq.XCData>().FirstOrDefault();
|
||||
return cdataNode?.Value ?? "";
|
||||
}
|
||||
|
||||
public static string cdata(Context ctx, string txt)
|
||||
{
|
||||
if (ctx.Node is null) return "";
|
||||
var cdataNode = ctx.Node.Nodes().OfType<System.Xml.Linq.XCData>().FirstOrDefault();
|
||||
if (cdataNode != null)
|
||||
{
|
||||
cdataNode.Value = txt;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx.Node.Add(new System.Xml.Linq.XCData(txt));
|
||||
}
|
||||
return txt;
|
||||
}
|
||||
|
||||
public static string attr(Context ctx, string name, string value)
|
||||
{
|
||||
if (ctx.Node is null) return "";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user