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

p:replace needs update due to new document model #93

Closed
xml-project opened this issue May 18, 2019 · 5 comments

Comments

Projects
None yet
4 participants
@xml-project
Copy link
Contributor

commented May 18, 2019

Currently the specs say:

Every node in the primary input matching the specified pattern is replaced in the output is replaced by the document element of the replacement document.

Since with XProc 3.0 we switched to XDM document, the notion of a "document element" does not make sense any more.

I therefor propose,

  1. that the matched node is replace by all children of the document node of the replacement document.

  2. That a dynamic error is raised, if the resulting document is a text nodes only document (because this step preserves all document properties)

  3. To add "text" to content-types of port replacement.

Could you please give me a GO / NON-GO before I start changing the prose.

@gimsieke

This comment has been minimized.

Copy link
Contributor

commented May 19, 2019

First, “Every node in the primary input matching the specified pattern is replaced in the output is replaced” seems to have a superfluous “is replaced” in it. Not sure which to remove.

Then I’d suggest to replace “document element” with “top-level node(s)”.

I was wondering whether we should say “text or element node(s)” or any node(s). For example, should p:replace also be able to replace a placeholder element in the source with a processing instruction? I’m thinking of

<p:replace match="/model">
  <p:with-input port="source">
    <p:inline>
      <model/>
      <doc>…</doc>
    </p:inline>
  </p:with-input>
  <p:with-input port="replacement">
    <p:inline>
      <?xml-model …?>
    </p:inline>
  </p:with-input>

And if the top-level node(s) of the source document are matched, should the result document carry the document properties of the replacement?
What if an element is matched and replaced with a text node? Then all document properties cannot be preserved. Or do we say that the content types of source and replacement must match?

@eriksiegel

This comment has been minimized.

Copy link
Contributor

commented May 20, 2019

Would like the "any node(s)" semantics Gerrit proposes.

About replacing the doc properties: No, its a replace and therefore IMHO the original doc is in the lead.

But there are edge cases as Gerrit points out. Not sure... 🤔

@ndw

This comment has been minimized.

Copy link
Collaborator

commented May 23, 2019

  1. I suppose. If it's not a document element, then I assume the nodes are used as the replacement text.
  2. I hope we don't need a new dynamic error for this. I hope we already say somewhere that the output of a step has to match it's content type. That said, I think we allow any XDM to be an application/xml document now, don't we?
  3. Sure.
@ndw

This comment has been minimized.

Copy link
Collaborator

commented May 23, 2019

23 May editor's call: the p:replace step will have to document that the replacement may change the content-type property of the document. (This might also change the base-uri property.)

@xml-project

This comment has been minimized.

Copy link
Contributor Author

commented May 28, 2019

I guess this is a general decision which holds also for the same problem on other steps, like p:replace-step where the document node is selected?

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