Background
Whilst looking into one of our system's config files, I found the below within an XML config file:
<crn:parameter name="serverLocale" @CRN_SERVERLOCALE_DISABLED@>
<crn:value xsi:type="xsd:language">en</crn:value>
</crn:parameter>
@CRN_SERVERLOCALE_DISABLED@
looks invalid to me; I've never seen anything like this in XML before.
My assumption is this is invalid XML, but is used by some pre-processor used by the system prior to XML parsing (or perhaps by a specialised XML parser geared to handle this).
I discovered this issue as I'd knocked up a script to query values on config files on various servers (saves logging into each one), which reported an issue. That supports my assumption that the above is invalid XML, but perhaps it's just a niche feature not implemented by MS?
$servers | %{
$val = select-xml -path ("\\{0}\share\folder\config.xml" -f $_) -xpath "//*[local-name()='parameter'][@name='caf_enabled']/*[local-name='value']/text()"
write-host ("server: '{0}' :: value: '{1}'" -f $_,$val)
}
NB: the system is IBM's Cognos reporting tool.
Questions
<crn:parameter name="serverLocale" @CRN_SERVERLOCALE_DISABLED@>
?Update
I created the following powershell to strip the invalid pieces prior to querying...
$xml = [xml]((get-content ("\\server\share\folder\config.xml")) -replace "@\S*@", "")
$val = select-xml -xpath "//*[local-name()='parameter'][@name='caf_enabled']/*[local-name='value']/text()" -xml $xml
write-host ("server: '{0}' :: value: '{1}'" -f $_,$val)
However this gives the following error:
Cannot convert value "System.Object[]" to type "System.Xml.XmlDocument".
Error: "Unexpected XML declaration.
The XML declaration must be the first node in the document, and no white space
characters are allowed to appear before it.
NB: the XML declaration has no whitespace, comments, or any other characters prior to it (before or after running the replace)
Note that "not valid XML" is the same thing as "not XML". In other words, it's garbage.
Most likely, that's some sort of substitution token that some pre-processor software is meant to replace with a valid attribute.