Skip to content

Attribute name with colon can't be transform in XML file type  #34

@iKaew

Description

@iKaew

When do transform with applicationsettings with the attribute key that contain colon, it will error.

Version: 1.2.0

Sample config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="blog:theme" value="green" />
  </appSettings>
</configuration>

Sample transform config

{
  "configuration/appSettings/add[@key='blog:theme']/@value": "red",
}

Error :

2017-11-14T11:04:04.9849036Z ##[error]System.Management.Automation.MethodInvocationException: Exception calling "Transform" with "4" argument(s): "The ''' character, hexadecimal value 0x27, cannot be included in a name." ---> System.Xml.XmlException: The ''' character, hexadecimal value 0x27, cannot be included in a name.
2017-11-14T11:04:04.9849036Z    at System.Xml.XmlConvert.VerifyNCName(String name, ExceptionType exceptionType)
2017-11-14T11:04:04.9849036Z    at System.Xml.Linq.XName..ctor(XNamespace ns, String localName)
2017-11-14T11:04:04.9849036Z    at System.Xml.Linq.XNamespace.GetName(String localName, Int32 index, Int32 count)
2017-11-14T11:04:04.9982685Z    at MagicChunks.Helpers.XmlExtensions.GetNameWithNamespace(String name, XElement element, String defaultNamespace)
2017-11-14T11:04:04.9982685Z    at MagicChunks.Helpers.XmlExtensions.<>c__DisplayClass1_0.<GetChildElementByName>b__0(XElement e)
2017-11-14T11:04:04.9982685Z    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
2017-11-14T11:04:04.9982685Z    at MagicChunks.Documents.XmlDocument.FindPath(IEnumerable`1 path, XElement current, String documentNamespace)
2017-11-14T11:04:04.9982685Z    at MagicChunks.Documents.XmlDocument.ReplaceKey(String[] path, String value)
2017-11-14T11:04:04.9982685Z    at MagicChunks.Core.Transformer.Transform(IDocument source, TransformationCollection transformations)
2017-11-14T11:04:04.9982685Z    at MagicChunks.TransformTask.Transform(String type, String sourcePath, String targetPath, TransformationCollection transformation)
2017-11-14T11:04:04.9982685Z    at CallSite.Target(Closure , CallSite , Type , Object , Object , Object , Object )
2017-11-14T11:04:04.9982685Z    --- End of inner exception stack trace ---
2017-11-14T11:04:04.9982685Z    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2017-11-14T11:04:04.9982685Z    at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2017-11-14T11:04:04.9982685Z    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2017-11-14T11:04:04.9982685Z    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions