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

Evaluation of attribute "as" #846

Closed
xml-project opened this issue Jul 19, 2019 · 6 comments

Comments

@xml-project
Copy link
Contributor

commented Jul 19, 2019

The XPath specs say:

The in-scope schema types in the static context are initialized with a set of predefined schema types that is determined by the host language. This set may include some or all of the schema types in the namespace http://www.w3.org/2001/XMLSchema, represented in this document by the namespace prefix xs.

I think we should state that is predefined, so I do not have to declare this namespace every time I want to type an option/variable.

@ndw

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

No.

That is simply not how XML works. The set of namespace prefixes that are bound is precisely, explicitly, exactly, and only the set that have in-scope namespace declarations.

The prose quoted is clear: schema types in that namespace are in the static context and that namespace is represented in this document by the prefix xs:.

@xml-project

This comment has been minimized.

Copy link
Contributor Author

commented Jul 19, 2019

I am pretty sure you are right, but I do not understand why. To my reading in

<p:variable name="anything" as="xs:integer*" />

the attribute contains a string (not a QName). And WE say, that an XProc processor has to interpret this string as an XPath sequence type.

XPath says, the host language (=XProc) may define predefined schema types. So we are free to say that all schema types of "http://www.w3.org/2001/XMLSchema" are defined.

I do not understand the difference you make here and the use of any XPath expression in XProc where I write $a instance of xs:integer without declaring the namespace because it is predeclared according to the specs.

@ndw

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

The prose about the host language says that it may predefine schema types. That is a completely separate issue from the question of namespace bindings in XPath expressions. I understand that prose to mean that a processor could predefine the schema type my:hatsize and then this would be a valid expression: $a as instance of Q{http://my/namespace}hatsize.

And yes, you're right that the value of the as attribute is a string, not parsed by the XML parser, and we could, in principle, say that the "xs:" namespace was bound magically in that context. But it would be wrong. That's not how any other XML-based language works. Even Schematron, which doesn't use the standard xmlns: binding mechanism requires a binding mechanism.

In XML languages, you have to declare the namespaces you use. All of them. Even if you only use them in QNames in attribute values that are technically strings.

@xml-project

This comment has been minimized.

Copy link
Contributor Author

commented Jul 19, 2019

Thanks. I see your point.

Why is XPath (and XQuery) different?

@ndw

This comment has been minimized.

Copy link
Contributor

commented Jul 19, 2019

XPath is different because it doesn't really stand on its own. It's expected to be embedded in a host language. The host language makes up the rules.

XQuery is different because it's not an XML language. I think the decision to allow pre-declared namespaces in XQuery is a mistake, but that wasn't a fight I was going to win in that working group.

XML languages (Schematron, XSLT, XProc, etc.) all have to play by the XML rules.

@xml-project

This comment has been minimized.

Copy link
Contributor Author

commented Jul 19, 2019

As XProc is the host language for XPath, wouldn't it be more in line with your approach to say, that

select="$a instance of xs:string"

is an error in XProc unless the namespace is declared?

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.