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

Implicit output port on p:if #886

Closed
xml-project opened this issue Oct 16, 2019 · 5 comments

Comments

@xml-project
Copy link
Contributor

@xml-project xml-project commented Oct 16, 2019

Because I ran into this problem (and Erik found it): We should explicitly state, that the implicit output port of p:if has content-types='any' and is a sequence port.

@xml-project

This comment has been minimized.

Copy link
Contributor Author

@xml-project xml-project commented Oct 16, 2019

Consider the following pipeline fragment (delivered by @eriksiegel )

<p:for-each>
    <p:if test="p:document-property(., 'base-uri') eq 'demo.html'">
      <p:insert match="/html/body" position="last-child">
        <p:with-input port="insertion">
          <div>
            <p>This was inserted by our pipeline</p>
          </div>
        </p:with-input>
      </p:insert>
    </p:if>
</p:for-each>

The p:if does not specify a primary output port, so the specs says, one is implicitly constructed, but it does not say how. The implicitly constructed output port of a compound step is an anonymous port with content-type and sequence taken from the last step of the subpipeline.
But this does not work here because it would result in content-types='xml html' (from p:insert). Every non-XML, non-HTML document processed by p:if (appearing on the implicit else) would raise an error.
Therefor: The implicit constructed primary output port must have content-types='any' and sequence=true. Right?
Then: What do we say, if an explicit primary output port is defined on p:if. Is it the authors duty to cover the if-case and the identity case with her definition?
I think this is error prone. Shouldn't we say, that content-types and sequence from the explicitly declared output port are ignored?
What did I miss?

@xatapult

This comment has been minimized.

Copy link
Contributor

@xatapult xatapult commented Oct 16, 2019

I think you missed nothing. Probably constructed output ports must always have sequence="true" and content-types="any"

There's probably a catch somewhere but I don't see it (yet)

@ndw

This comment has been minimized.

Copy link
Contributor

@ndw ndw commented Oct 16, 2019

Good catch. The relevant passage in p:choose is:

As a convenience to authors, it is not an error if some subpipelines declare outputs that can produce sequences and some do not. Each output of the p:choose is declared to produce a sequence. The content types that can appear on the port are the union of the content types that might be produced by any of the p:when or the p:otherwise.

But in 3.0, we no longer require the p:otherwise (and p:if explicitly doesn't have one), so there's nothing to use to complete the union. I think you're right, we should say that the result of p:choose and p:if is a sequence of a "any"

@xml-project

This comment has been minimized.

Copy link
Contributor Author

@xml-project xml-project commented Oct 16, 2019

@ndw said:

… we should say that the result of p:choose and p:if is a sequence of a "any"

I think for p:choose we just need to say, that the content-type of the primary output port (if any) automatically turns to any, if p:otherwise is missing. For all other port or when p:otherwise present the union rule hold.

Since p:if is (or could be conceived as) a p:choose with one p:when and no p:otherwise this means, that content-type of the primary output port (which must be present) is any.

Did I miss something?

@xml-project

This comment has been minimized.

Copy link
Contributor Author

@xml-project xml-project commented Oct 18, 2019

Fixed with #888

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