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

<pre>? <p xml:space="preserve">? #1

Open
tgraham-antenna opened this issue Sep 28, 2021 · 4 comments
Open

<pre>? <p xml:space="preserve">? #1

tgraham-antenna opened this issue Sep 28, 2021 · 4 comments

Comments

@tgraham-antenna
Copy link

The current code does not preserve white-space in either <pre> or <p xml:space="preserve">.

Handling <pre> correctly requires either a HTML-aware converter or preserving all white-space so that all white-space can all be round-tripped.

@Devasta
Copy link
Owner

Devasta commented Oct 1, 2021

Hi,

Good catch! Sounds like it'd be a bit tricky trying to check ancestor elements to see if they have the space attribute, so I might just preserve all whitespace.

I'll do some tests and see how that output looks. Thanks for taking the time to review the transform, I appreciate it!

Regards

Dan

@tgraham-antenna
Copy link
Author

My effort from two weeks ago is at https://xsltfiddle.liberty-development.net/gVAkJ52/9. I had to stop because it and the conversion the other way were taking more time than I could spare. It preserves the white-space, but there's still a lot that it gets wrong. I haven't looked into how to output namespace nodes, for instance.

My approach was to be a base stylesheet that preserves all of the white-space with the option of developing a stylesheet for a specific schema/vocabulary. For example, a stylesheet for XSLT would import the base stylesheet but also include a template or templates to discard all white-space-only text nodes except inside xsl:text (or with an ancestor with xml:space="preserve"). There would also be some sort of pretty-printing to indent the XiK to match the element nesting.

@Devasta
Copy link
Owner

Devasta commented Oct 3, 2021

Ah, so we'd have a transform that does the lions share of the work, then can have examples of the final piece, if they want whitespace Vs no whitespace, and so on?

@tgraham-antenna
Copy link
Author

I think that we understand each other.

If you convert some indented XSLT into XiK and edit that, you don't want to see the white-space from the XML that you (and the XSLT processor) ignore when the XSLT is written as XML. However, you also don't want it all as one line of XiK.

If you look at the website.kdl example at https://github.com/kdl-org/kdl/blob/main/examples/website.kdl, you can read that easily because there's line breaks and indentation corresponding to the element nesting.

(However, if you convert website.kdl to XML, it would all be in one line because there's no translatable line breaks in the KDL. That doesn't matter to the browser, but it would matter for human readability. Converting XiK into pretty-printed XML without adding significant white-space is a separate problem, however. My current thought would be to let the XML-aware editor re-indent it if I had to convert XiK back to XML and edit that.)

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