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

fn:deep-normalize-space($e as node()) #79

Closed
michaelhkay opened this issue Jun 4, 2021 · 4 comments
Closed

fn:deep-normalize-space($e as node()) #79

michaelhkay opened this issue Jun 4, 2021 · 4 comments
Labels
Feature A change that introduces a new feature Propose Closing with No Action The WG should consider closing this issue with no action XQFO An issue related to Functions and Operators

Comments

@michaelhkay
Copy link
Contributor

michaelhkay commented Jun 4, 2021

Summary: removes redundant whitespace within the content of a given node, leaving the element structure intact.

Example:

 <p>  My <i>crazy</i>
<b> content</b>.
</p> 

becomes

<p>My <i>crazy</i> <b>content</b>.</p>
Rules (expressed informally, and may need refining):

  • The string value of the result is the normalize-space() of the string-value of the input.
  • Every non-whitespace character in the result has the same ancestor path as the corresponding character in the input (for example if it was in an i element in the input, then it will be in an i element in the output).
  • When several adjacent whitespace characters from different elements in the input are combined into a single space in the output, the resulting space will be in a text node whose parent is the result node corresponding to the common ancestor of those different elements.

For example <i>easy </i><b> peasy</b> becomes <i>easy</i> <b>peasy</b>

Could perhaps also add an option to word-wrap to a given line length.

@joewiz
Copy link

joewiz commented Jun 4, 2021

The Markdown rendering may be interfering with the presentation of the examples. For clarity's sake, could you please provide the examples in fenced code blocks? Here's my attempt at adapting the examples above - but please correct me if I'm wrong.

Also, would elements with @xml:space="preserve" be omitted from processing?

Lastly, word-wrap would be amazing!

Example 1

fn:deep-normalize-space(<p>
My <i>crazy</i>
<b>content</b>.
</p>)

returns:

<p>My <i>crazy</i> <b>content</b>.</p>

Example 2

fn:deep-normalize-space(<p><i>easy </i><b> peasy</b></p>)

returns:

<p><i>easy</i> <b>peasy</b></p>

@rhdunn rhdunn added XQFO An issue related to Functions and Operators Feature A change that introduces a new feature labels Sep 14, 2022
@ChristianGruen ChristianGruen added this to the QT 4.0 milestone Oct 14, 2022
@ChristianGruen ChristianGruen removed this from the QT 4.0 milestone Apr 27, 2023
@ChristianGruen ChristianGruen changed the title [FO] New function fn:deep-normalize-space($e as node()) New function fn:deep-normalize-space($e as node()) Apr 27, 2023
@ChristianGruen ChristianGruen changed the title New function fn:deep-normalize-space($e as node()) fn:deep-normalize-space($e as node()) Oct 31, 2023
@ChristianGruen
Copy link
Contributor

Do we want to keep this function proposal open?

I did a quick attempt to implement it, but I think some more effort would need to spend to formalize the rules.

@michaelhkay michaelhkay added the Propose Closing with No Action The WG should consider closing this issue with no action label Feb 7, 2024
@michaelhkay
Copy link
Contributor Author

File it under "it seemed a good idea at the time".

@ndw
Copy link
Contributor

ndw commented Feb 13, 2024

The CG agreed to close this issue without action at meeting 065

@ndw ndw closed this as completed Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A change that introduces a new feature Propose Closing with No Action The WG should consider closing this issue with no action XQFO An issue related to Functions and Operators
Projects
None yet
Development

No branches or pull requests

5 participants