Skip to content

Simplify the selection of a set of nodes as a document #76

@ndw

Description

@ndw

A user, especially one familiar with XPath, would be forgiven for believing that this:

<p:with-input select="/book/chapter[2]/node()"/>

would create a single document containing all of the nodes contained in the second chapter of the book.

In XProc, it doesn't. It selects all those nodes and then creates a separate document for each one of them. That's the right default in XProc, because you want it to be easy to do things like like loop over all the chapters of a book.

<p:for-each>
  <p:with-input select="/book/chapter"/>
  ...
</p:for-each>

But near as I can tell, the easiest way to create the single document is this:

<p:unwrap select="/chapter">
  <p:with-input select="/book/chapter[2]"/>
</p:unwrap>

That's a bit obscure and requires an odd sort of reverse-selection where you pick the inner thing to remove it. Does it make sense to consider adding single-document to p:with-input?

<p:with-input select="/book/chapter[2]/node()" single-document="true"/>

If single-document is absent or false the behavior is unchanged. If it's true, the resulting sequence of nodes is wrapped in a single document node.

Alternatively, I suppose, we could make the wrapper attribute on p:wrap-sequence optional and say that if it's absent, the result is simply to wrap a document node around the sequence.

Or, in typical committee fashion, we could do both 😆

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions