Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: handling of TAB andCRLF in saved XSLT-files #198

Open
Pierre-de-la-Verre opened this issue May 3, 2022 · 4 comments
Open

Question: handling of TAB andCRLF in saved XSLT-files #198

Pierre-de-la-Verre opened this issue May 3, 2022 · 4 comments

Comments

@Pierre-de-la-Verre
Copy link

Pierre-de-la-Verre commented May 3, 2022

I have a XSLT-file which contains TAB and CRLF-definition to create a better readable output, like this

  <xsl:text>&#0009;</xsl:text>
  <xsl:value-of select="./KEY_NUMERIC_OLD"/>
  <xsl:text>&#0009;</xsl:text>
  <xsl:value-of select="./KEY_NUMERIC_NEW"/>
  <xsl:text>&#xa;</xsl:text>

It works fine, but when I opened the file with XMLNotepad and saved it, all the TABs and CRLF are gone. Why?
Related to #166 ?

@Pierre-de-la-Verre Pierre-de-la-Verre changed the title Question: handling of CRLF in saved XSLT-files Question: handling of TAB andCRLF in saved XSLT-files May 3, 2022
@lovettchris
Copy link
Member

See White space Handling in the XML specification. In this case you may need to use the xml:space="preserve" attribute.

@Pierre-de-la-Verre
Copy link
Author

Thanks, but I failed while trying. Can someone give a simple example?

@lovettchris
Copy link
Member

Actually I cannot reproduce your problem, there must be something else going on, did the XLST perhaps not honor your request? When I create the attached XML file containing tabs and newlines:

<?xml version="1.0" encoding="utf-8"?>
<root>
	KEY_NUMERIC_OLD	KEY_NUMERIC_NEW
	KEY_NUMERIC_OLD	KEY_NUMERIC_NEW
	KEY_NUMERIC_OLD	KEY_NUMERIC_NEW
	KEY_NUMERIC_OLD	KEY_NUMERIC_NEW
</root>

And load it in XML notepad the root element contains this formatted text, nothing changed, when I save the document again the file on disk is still correct, no loss of tabs or newlines in this block of text.

@Pierre-de-la-Verre
Copy link
Author

I want to refresh this topic and attach 4 files - one original and 3 derivates:

  1. using_tab_codes.xslt:
    original XSLT, using text with "&#...;"

  2. using_tab_codes_xmlint.xslt:
    created with xmlint.exe -e utf-8 -f -nobom %1; all "&#...;" are gone

  3. using_tab_codes_new_no.xslt:
    opened and saved with XMLNotepad, "Preserve whitespace: no"; all "&#...;" are gone

  4. using_tab_codes_new_saved.xslt:
    opened and saved with XMLNotepad, "Preserve whitespace: yes"; all "&#...;" are replaced with TAB and CR/LF

I'm not sure if 2) and 3) are doing it right ..

xslt_files.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants