- From: Alex Miłowski <alex@milowski.com>
- Date: Tue, 19 Apr 2016 21:23:10 -0700
- To: XProc WG <public-xml-processing-model-wg@w3.org>
On Tue, Apr 19, 2016 at 5:33 PM, Norman Walsh <ndw@nwalsh.com> wrote: > Alex Miłowski <alex@milowski.com> writes: >> Here are some random and possibly radical thoughts ... > > Thanks, Alex. > >> # Conditionals >> >> I've been thinking about conditionals and with the port set expression >> and the concept of current readable ports, we can do away with the >> need for block expressions to wrap a conditional. A conditional is >> just another expression that can be inserted in a chained sequence >> that produces a set of readable ports. >> >> Here are the rules as I see it: >> >> 1. The condition operates on the current readable port (and whatever >> is lexically in scope). > > Do we still have a “current readable port”? I thought we had a set of > ports that came from the preceding step or port set expression. We have "current - readable ports" ... plural. Section 4.3 that we reviewed last week uses that term in a few places but in the sense of "there is currently a set of readable ports" at a particular position in a chain sequence. > > [source="doc.xml", lookup="table.xml"] -> my:step() > > In what sense is ‘source’ or ‘lookup’ more or less the current > readable port than the other? Sorry for the confusion... >> >> This means we can now do: >> >> $source >> → if (xs:decimal($source/*/@version) < 2.0) > > In the @version test, $source has nothing to do with the input to the > conditional, right? It’s just reading the same $source variable that’s > being fed in. Right. > >> then [schema="v1schema.xsd"] → validate-with-xml-schema() > > I don’t understand this at all. I could understand > > then [$source, schema="v1schema.xsd"] → validate-with-xml-schema() It should be: $source → if (xs:decimal($source/*/@version) < 2.0) then [port(), schema="v1schema.xsd"] → validate-with-xml-schema() else [port(), schema="v2schema.xsd"] → validate-with-xml-schema() >> >> source >> → if (xs:decimal(/*/@version) < 2.0) > > Ok. I think I see. But just to be clear, I could still do this if > I wanted to, right? > > source >> $src > source -> if (xs:decimal($src/*/@version) … Yes, assuming we have a way to make in-scope variable and expression all work together. > >> then [schema="v1schema.xsd"] → validate-with-xml-schema() > > But I still really, really don’t understand how the default context is > implicitly being inserted into the port bindings for > validate-with-xml-schema(). What’s more, I don’t think you necessarily > always want it to be the first one. What if what was being passed in > was the schema and what varied was the document that I wanted to > parse? You seem to be stuck on the expression language problem. I am focusing on the flow right now. How readable ports are accessible is an open issue. Another way is via a function: xs:decimal(port('source')//*/@version) < 2.0 > >> else [schema="v2schema.xsd"] → validate-with-xml-schema() >> → [port(),"stylesheet.xsl"] >> → xslt() >> ≫ result >> >> # No Pipeline Declarations > > I think we’re going to decide that we need some, even if we don’t need > the ones we’ve got today. I’m all for fewer required declarations; I’m > less sanguine about forbidding explicitness; and I’m very reluctant to > forbid the concept of pipeline declarations. We have declarations ... we don't have pipeline declarations like we did in 1.0. > > Mmmmmm. I might come around, but I’ll have to think about that for a > while. It’s going to lead to some odd error messages. Imagine that > you’ve got a pipeline that has several flows and reuses “source” a few > times. In one case, you misspell it “sourc”. Instead of getting a > “reference to undeclared input on line 653” you’re going to gets > “binding required for port ‘sourc’ on line 653”. I guess we’ll get > used to that, but… I don't see how a declaration helps typos in this case ... > > Is the goal to allow brevity or require brevity? The goal is less complexity. > >> # No Options >> >> Because we have no pipeline declaration, if you want options, you need >> to wrap things in a flow: >> >> xproc version = "2.0"; >> >> [ source : document-node() ] flow($mode : xs:string = '') [ result : >> document-node() ] >> { >> source >> → if (xs:decimal(/*/@version) < 2.0) >> then [schema="v1schema.xsd"] → validate-with-xml-schema() >> else [schema="v2schema.xsd"] → validate-with-xml-schema() >> → [port(),"stylesheet.xsl"] >> → xslt(mode=$mode) >> ≫ result >> } >> >> Now an implementation needs a parameter to invoke the flow. This also >> presumes it would pick the last flow. > > Uuuuuhhhmmmmm. I see the mathematical elegance, but I’m not sure it’s > exactly user friendly. It isn't about elegance. Options at the top-level are exactly like parameters to flows. If you need top-level options, then we should re-use an existing mechanism rather than have two of them. > >> # Cleaning Up Flow Declarations >> >> The syntax for anonymous flows: >> >> [] flow(...) [] { ... } >> >> and named: >> >> declare flow [] name(...) [] { ... } >> >> is possibly confusing. > > It’s also not winning me over aesthetically. > > Given the choice between: > > [ source : document-node() ] > flow($mode : xs:string = '') > [ result : document-node() ] { … } > > and, for example, > > [ source : document-node(); result : document-node()] > flow($mode : xs:string = '') { … } > > I find the former more of a challenge. That semicolon makes it look like a syntax error. We've been using semicolons as a delimiter for "end of a declaration". >> >> [ ] → flow(...) → [] > > That strikes me as potentially confusing. It’s just too easy to read > that as some kind of flow in parenthesis. Maybe a different delimiter: > > [ ] :: flow(...) :: [] I could live with double colons but that is a new delimiter. I find re-use of the arrow easier. > > What happens if we just use more words: > > declare flow > requires inputs [ source ] > produces outputs [ result ] > { > source > → if (xs:decimal(/*/@version) < 2.0) > then [schema="v1schema.xsd"] → validate-with-xml-schema() > else [schema="v2schema.xsd"] → validate-with-xml-schema() > → [port(),"stylesheet.xsl"] > → xslt(mode=$mode) > ≫ result > } > > declare flow named validate > requires inputs [ source ] > produces outputs [ result ] > { … } More words puts us back to more like what we have now ... in as much as we "have it". :) -- --Alex Miłowski "The excellence of grammar as a guide is proportional to the paucity of the inflexions, i.e. to the degree of analysis effected by the language considered." Bertrand Russell in a footnote of Principles of Mathematics
Received on Wednesday, 20 April 2016 04:23:42 UTC