javascript wrapping after value-of on format

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
wilsonjr
Posts: 1
Joined: Mon Nov 02, 2020 7:36 pm

javascript wrapping after value-of on format

Post by wilsonjr » Mon Nov 02, 2020 7:48 pm

When formatting this code in XML Editor 22.1:

<script>
var serverName = '<xsl:value-of select="/data/serverName"/>';
</script>


the single quote and semicolon wrap resulting in broken javascript:

<script>
var serverName = '<xsl:value-of select="/data/serverName"/>
';
</script>


How can the wrapping after the value-of be prevented?

tavy
Posts: 276
Joined: Thu Jul 01, 2004 12:29 pm

Re: javascript wrapping after value-of on format

Post by tavy » Tue Nov 03, 2020 10:18 am

Hello,

Thanks for your feedback.
I think your document is an XHTML (has the namespace "http://www.w3.org/1999/xhtml" set on root ), or it is an HTML document opened in the XHTML editor.
You can verify the content type of the opened document in the Properties view (Help menu->Show View->Properties). If the content type value is "application/xhtml+xml", it means that is an XHTML document, if is "text/html" it means that is an HTML document.

In case you have an XHTML document ( the namespace "http://www.w3.org/1999/xhtml" is set on root), you need to add the script content in a CDATA. Something like this:

Code: Select all

<script>
//<![CDATA[
    var serverName = '<xsl:value-of select="/data/serverName"/>';
//]]>
</script>
If you document does not have the XHTML namespace set on root, probably you opened the file with the XHTML editor. You can close the file and use the Open With->Internal Editor action from the Project view contextual menu. Then select HTML editor from the list in order to be opened as an HTML.

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply