Closed ndw closed 2 years ago
Is this even a good idea? Suppose p:unwrap
is followed by something that adds an element. That would have succeeded and will now fail.
I don’t remember the rationale for turning it into an empty text document. Maybe we should revise it an make an empty document node, as Morgana did before IIRC.
Apart from p:delete
, I don’t know any other steps. Maybe p:xslt
if it is now allowed to “create” empty primary outputs? Or p:xquery
?
FYI: Today I added some related tests to the test suite (https://github.com/xproc/3.0-test-suite/pull/597).
I was able to identify nine cases, where a steps result could be an empty document node:
I have no solution to propose, but I agree with @ndw that p:unwrap and p:delete (and p:string-replace) should result in the same document type. My expectations (coming from xquery and xslt) would be an XML document, but I think I could adapt to Text document too.
What seems natural to me is that loading an empty text file and replacing all text in a text document does not change the document type, but I would not argue for it, if you favour a general solution saying all empty document nodes result in an X document.
Hope that helps.
There a two other cases to produce an empty document node: 1.
<p:identity>
<p:with-input><p:inline /></p:with-input>
</p:identity>
I would expect this to be an XML document.
2.
<p:identity>
<p:with-input content-type="text/plain"><p:inline /></p:with-input>
</p:identity>
I would expect this to be a Text document.
agree
To sum up the discussion, I think two options to solve is are mentioned:
If you indicate your preferred solution, I am prepared to file a pull request for this.
If you would ask me, (2) seems more natural to me. In a pipeline I lately run into the problem indicated by @ndw in https://github.com/xproc/3.0-steps/issues/485#issuecomment-916197623
It feels much more naturally to me that p:unwrap
and all the other steps produce an empty document node in case there's nothing there any more.
@ndw and @gimsieke Please add your votes so we can hopefully close this issue (or, in case of disagreements, discuss it)
I’m quite indifferent. If you both tend to option two, I’ll tend to two, too.
On the call of 22 June, the editor's decided to revert the previous decision and make the results be empty XDM document nodes.
We decided that if
p:unwrap
results in an empty document, then it's text (#470). We should say the same thing aboutp:delete
; are there other case?