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

Content-types of ports "source" and "result" on p:insert: Allow text documents? #583

Closed
xml-project opened this issue Jun 20, 2024 · 3 comments

Comments

@xml-project
Copy link
Member

I think there is an edge case, where the result of p:insert can be a text document. If the document on port "source" is an XML document which contains just a document node (no element nodes), and then I insert a text document, I think I should get a text document.
But the current specification says, port "result" on p:insert is either XML or HTML.

Proposal: Add "text" to the possible content types of port "result".

Does this make sense?

@ndw
Copy link
Collaborator

ndw commented Jun 20, 2024

Isn't an XML document that contains just a text node a, uh, text document? How did that get into the step without tripping over the constraint on source?

Do we want to allow text on the source as well as the result?

(I'm in favor, I'm just trying to see if we've covered all the bases.)

@xml-project
Copy link
Member Author

Sorry for being not precise: I am talking about XProc 3.1, where a text document is allowed on port "insertion".
Now I do:

<p:delete match="/doc">
   <p:with-input><doc /></p:with-input>
</p:delete>
<!-- result: An XML document with just a document node -->
<p:insert match="/" position="last-child">
   <p:with-input><p:inline content-type="text/plain">This is a text</p:inline></p:with-input>
</p:insert>

The result is a document node with one text node. So it should be, as you said, a text document. But the signature of p:insert is:

<p:output port="result" content-types="xml html"/>

@ndw
Copy link
Collaborator

ndw commented Jun 20, 2024

I agree that we should add text to the content types of result.

Tangentially, I'm wondering what the result of your p:delete step is, though. According to p:delete:

If the resulting document contains exactly one text node, the content-type property is changed to text/plain and the serialization property is removed, while all other document properties are preserved. In all other cases, all document properties are preserved.

The only way that can happen is if you delete the root node, as you're doing in the example above. I suppose, technically, the result of that deletion is a completely empty document, not a document containing exactly one text node. But I think I assume that it becomes a text document. And then it wouldn't be allowed on the source port of p:insert. Which it probably should be.

@xml-project xml-project self-assigned this Jun 20, 2024
@xml-project xml-project removed their assignment Jun 21, 2024
@xml-project xml-project changed the title Content-types of port "result" on p:insert Content-types of ports "source" and "result" on p:insert: Allow text documents? Jun 21, 2024
@ndw ndw closed this as completed in 549592a Aug 1, 2024
ndw added a commit that referenced this issue Aug 1, 2024
Fix #583 by allowing the result to be text
ndw added a commit to ndw/steps that referenced this issue Aug 1, 2024
ndw added a commit to ndw/steps that referenced this issue Aug 1, 2024
ndw added a commit to ndw/steps that referenced this issue Aug 1, 2024
ndw added a commit to ndw/steps that referenced this issue Aug 1, 2024
ndw added a commit to ndw/steps that referenced this issue Aug 2, 2024
ndw added a commit to ndw/steps that referenced this issue Aug 20, 2024
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

Successfully merging a pull request may close this issue.

2 participants