-
Notifications
You must be signed in to change notification settings - Fork 15
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
[FO] fn:nl, fn:tab, fn:cr #121
Comments
Maybe make these OS-dependent, like Windows: CRLF, Unix: LF, MAC (up through ver. 9) CR, etc. There are 8 different cases and 8 different values summarized in Wikipedia :
When processing with And/or maybe allow these to be overriden by Environment settings? |
Thanks for your thoughts. – I don’t recollect all the rules, but declare namespace output = 'http://www.w3.org/2010/xslt-xquery-serialization';
declare option output:method 'xml';
'A 
B'
(: The result ...
A

B
:) XML 1 has Edit: I have digged up an old discussion on serializing newlines (caused by possible bugs in the test cases): https://lists.w3.org/Archives/Public/public-qt-comments/2015Oct/0201.html |
For XML, yes. But Shouldn't XPath take a broader view of the allowed characters? If we are calling |
I assume that CR won’t be normalized away, but FOUT1190 will still be raised if the resulting characters are not permitted XML characters, i.e., if XML 1.0 is used and if the input contains control characters like 0B. |
Great idea to expose these values, but is there a reason you're using a function rather than a global variable like (Also, while not directly related, I thought I'd point to a utility function for referencing HTML entities by name: https://gist.github.com/joewiz/8a2c3e2320da4c24058ccee5aec156f6. I could imagine a similar package that would facilitate lookup of Unicode entities by name.) |
The main reason I think is that the concept of built-in global variables would be something new. In the EXPath File Module, we used functions instead of variables for the same reason. We’d also need to think about the default namespace for global variables: I like the idea to have a function for resolving HTML entities. |
@ChristianGruen These reasons make sense to me. Thanks! |
And It helps to write queries that are valid XPath and XQuery
In Xidel I have a lot of built-in variables, e.g. |
If we're going to have That's getting us up to nine -- the five magic chars and the four whitespace characters -- and I start to think it shouldn't be distinct functions. Maybe (Yes I do want a distinct function for space; I use |
Perhaps
|
As soon as you do that, someone is going to propose that you should be able to give any character name from the Unicode database...which I think is conceptually a good idea even if the idea of carrying around the unicode database doesn't fill me with glee. |
I deliberately refrained from that suggestion, that would be an awful lot of data to retain. I'm not actually sure how many entity names are defined in HTML5 these days, but presumably they've chosen the set of names with a degree of pragmatism, and if the browser can know them, so can we. |
As far as I can see, we have no other XML functionality that uses CR and similar. If we add Personally, I think |
In PR #261 I have proposed an fn:char function which allows the character to be defined as a decimal or numeric constant, as an HTML entity reference name, or as one of the escape sequences \n, \r, and \t. I think this will meet a wide range of requirements. It takes into account the needs of XPath environments other than XQuery and XSLT, where the |
Closed by #261 |
The most popular custom functions in BaseX, and the most boring ones, allow users to insert new line and tab characters. It would be nice to see official variants added to the spec:
fn:nl() as xs:string
,

)fn:tab() as xs:string
	
,	
)fn:cr() as xs:string
)The third function can possibly be dropped.
The text was updated successfully, but these errors were encountered: