11

I want to update the component 870Jars atrribute values using Jenkins build. When i open the xml file in IE, I am getting the below error

Error:- The XML page cannot be displayed

Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.

A name was started with an invalid character. Error processing resource 'https://svn.retailerinfo.com/svn/Stores/Po...

<870Jars> ---^

XML file:-

<?xml version="1.0" encoding="UTF-8"?><Application> 
<app-name>Regist</app-name>
<baseline-version>Regist_R11.6.0.51</baseline-version>
<app-version>v11.6.0.51</app-version>
<defversion>1.0.0</defversion>
<component>
    <870Jars>
    <filename>v10.3.0-870Jars.zip</filename> 
    <targetfilename/> 
    <version>v10.3.0</version> 
    </870Jars>
</component>
</Application>

Is there any way where i can start a tag name with a number ?

I used &lt;/870Jars&gt; in place of <870Jars> but it is just printing the value rather than working as tag

3 Answers 3

24

An XML element whose name starts with a number is illegal XML. You should not start with numbers.

XML elements must follow these naming rules:

  • Names can contain letters, numbers, and other characters
  • Names cannot start with a number or punctuation character
  • Names cannot start with the letters xml (or XML, or Xml, etc)
  • Names cannot contain spaces

Any name can be used, no words are reserved.

http://www.w3schools.com/xml/xml_elements.asp

Specification Details.

2
  • But i have to use it as per the requirement.I tried with hexadecimal <_x0038_70Jars> in place of <870Jars> but it is not working.Not sure what i am missing here Oct 30, 2013 at 9:21
  • 5
    @user2935276 escape sequences do not work in tag names. There is no easy way to say this but if your requirement is to a) use XML and b) violate XML then your requirements are very wrong. If this is an existing file format, my best suggestion is to edit the document to be valid xml before parsing it, and then edit it to match your file format after saving.
    – Gusdor
    Oct 30, 2013 at 9:26
0

Simple workaround is to {concat('_',data(desired_tag_name_here))} and filter out the first character elsewhere if it is a lodash. A tidbit hacky, but when CData and other methods are either too dirty or make the code unreadable, just tag a note by the concatenation, fix it with the next handler, and move on about your business

-4

Try using a CDATA like below:

<component>
    <![CDATA[    
    <870Jars>
    <filename>v10.3.0-870Jars.zip</filename> 
    <targetfilename/> 
    <version>v10.3.0</version> 
    </870Jars>
 ]]>
</component>
2
  • 3
    CDATA means: this isn't XML; while it'll represent that 870Jars sequence, that can't be parsed as XML and can't contain ]] sequence Oct 30, 2013 at 9:44
  • Agreed with Rubens - using CDATA here is a BAD idea as it prevents standard (ie xpath) parsing of the contained tags, eg. version
    – dlchambers
    May 16, 2018 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.