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

Open questions on p:viewport #849

Open
xml-project opened this issue Jul 22, 2019 · 2 comments

Comments

@xml-project
Copy link
Contributor

commented Jul 22, 2019

I think p:viewport needs to be updated to recent development:

It is a compound step that processes a single XML document ....

I think we need to allow HTML documents also. And (if I am right with the next point) also Text documents.

It is a dynamic error (err:XD0010) if the match expression on p:viewport does not match an element or document.

I think this is a leftover from XProc 1.0. Since we now use XDM i think match should be able to match anything except an attribute and a namespace.

and the result that appears on the output port replaces the matched element.

I think we need to say more about what happens relative to the result's content-type.
Proposal:

  1. For an XML document and a HTML document, the matched element is replaced with all children of the result's document node.
  2. For a Text document the matched element is replaced by the child of the result's document node. (This is the same as (1), but I listed it separately so can vote against it.
  3. If it is a JSON document, it is an error.
  4. If it is another document, it is an error.
@ndw

This comment has been minimized.

Copy link
Contributor

commented Jul 22, 2019

I agree that we should allow HTML.

How is it useful to allow text documents? Adjacent text nodes are combined, so the document will consist of a single text node. The smallest select expression you can make on that is the whole node, so you'll replace the whole thing. (Or nothing.)

I'm still thinking about the JSON case. Does it makes sense to select a portion of the map or array? It might, but I haven't worked out if that's implementable or not. I'm certainly happy to make it an error in the short term.

I guess we should clarify that if you select the whole XML or HTML document and replace it with a text node, you get a text/plain document out.

@xml-project

This comment has been minimized.

Copy link
Contributor Author

commented Jul 22, 2019

How is it useful to allow text documents?

I did not claim, it is very useful. But I see no reason to make it an error.

I'm still thinking about the JSON case. Does it makes sense to select a portion of the map or array? It might, but I haven't worked out if that's implementable or not. I'm certainly happy to make it an error in the short term.

I think it would be useful, e.g. updating all values in a map with a certain key. But as far as I can see, we do not have an expression language to match portions of maps/arrays, have we?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.