[Laszlo-dev] Re: trying to add namespace support to data compiler
/ xpath parser
Max Carlson
max at laszlosystems.com
Fri Sep 9 13:56:59 PDT 2005
Understood. I was responding to Henry's bigger question about whether
namespaces make sense in the language itself. Making them work in data
is even more important - particularly for SOAP.
-Max
Oliver Steele wrote:
> On Sep 9, 2005, at 1:00 PM, Max Carlson wrote:
>
>> I think namespaces make sense for LZX. That way you can freely mix
>> different versions of a component (e.g. combobox) withou having to
>> give each a unique name.
>
>
> That does make sense, but that's different from the feature that Henry
> is talking about here. <http://openlaszlo.org/wiki/
> Import_Statement#Namespaces> has some notes on namespaces as a
> programming feature. Henry is talking about namespaces in data.
>
>> -Max
>>
>> Henry Minsky wrote:
>>
>>> This is a step in getting the data compiler / xpath mechanism to be
>>> namespace aware, but it's not clear if that's going to make it into
>>> 3.1 or not, I have some more fixing to do on it.
>>> There's bigger questions about what if any XML namespace awareness
>>> would make sense for the LZX language itself.
>>> For making packages or modules, I would think we would be leaning
>>> towards some ECMAscript standard if there is such a thing for naming
>>> package and referencing them. I don't know if there is any XML
>>> namespace stuff that we would want to put into LZX, except maybe to
>>> make it aware enough of namespaces that you could put XML tags in from
>>> another namespace and have them safely ignored or something. I don't
>>> know if it makes any sense to try to use XML namespace notation to
>>> reference Javascript package namespaces or not. Any one want to chime
>>> in on this?
>>> On 9/9/05, Oliver Steele <steele at laszlosystems.com> wrote:
>>>
>>>> On Sep 9, 2005, at 10:47 AM, John Sundman wrote:
>>>>
>>>>
>>>>> Cool.
>>>>>
>>>>> Should this go in databinding chapter?
>>>>>
>>>>
>>>> Only if we add namespace support to OpenLaszlo.
>>>>
>>>>
>>>>
>>>>> jrs
>>>>>
>>>>> On Sep 9, 2005, at 12:28 PM, Oliver Steele wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> On Sep 8, 2005, at 6:13 PM, Henry Minsky wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Let's say you have this XML
>>>>>>>
>>>>>>> <persons xmlns:foo="foo.bar" xmlns:secret="secret.names">
>>>>>>> <foo:person id ="1" name="jonny" secret:name="freddy">
>>>>>>> <firstName>Dan</firstName>
>>>>>>> <lastName>McGowan</lastName>
>>>>>>> <modifyDate>3/25/05</modifyDate>
>>>>>>>
>>>>>>> <address id ="1" code="ML">
>>>>>>> <line1>2210 North 184th Street</line1>
>>>>>>> <line2></line2>
>>>>>>> <city>Shoreline</city>
>>>>>>> </address>
>>>>>>>
>>>>>>> </foo:person>
>>>>>>>
>>>>>>> Is it legal XPath syntax to ask for "/persons/foo:person[1]/
>>>>>>> @secret:name".
>>>>>>> That is, can you put a namespace-prefixed name as an attribute
>>>>>>> value?
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> You can, if it's in a context where the prefix is bound to a URI.
>>>>>>
>>>>>> For example, in XSTL,
>>>>>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>>>>> xmlns:foo="foo.bar"
>>>>>> xmlns:secret="secret.names">
>>>>>> <xsl:template match="persons/foo:person[1]/@secret:name"/>
>>>>>> would match the attribute, but so would:
>>>>>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>>>>> xmlns:ns1="foo.bar"
>>>>>> xmlns:ns2="secret.names">
>>>>>> <xsl:template match="persons/ns1:person[1]/@ns2:name"/>
>>>>>> or even
>>>>>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>>>>> xmlns:secret="foo.bar"
>>>>>> xmlns:foo="secret.names">
>>>>>> <xsl:template match="persons/secret:person[1]/@foo:name"/>
>>>>>>
>>>>>> There's NO relation between the prefix in the data and the prefix
>>>>>> in the XPath, unless the data and the XPath happen to come from
>>>>>> the same document and the xmlns declaration is attached to an
>>>>>> element that contains them both. XPath matches URI qualifiers,
>>>>>> not prefixes; prefixes are a local way to name URIs.
>>>>>>
>>>>>> Another way to think of this is that your data XML is really a
>>>>>> representation of this:
>>>>>> <persons>
>>>>>> <{foo.bar}:person id ="1"
>>>>>> name="jonny" {secret.names}:name="freddy">
>>>>>> ...
>>>>>> where the xmlns attributes define an abbreviation for "foo.bar"
>>>>>> and "secret.names" that puts them into the lexical space of XML
>>>>>> element and attribute names. It's kind of like tinyurl for XML.
>>>>>> The XML Namespace specification defines this abbreviation
>>>>>> mechanism, and specifies the scope of abbreviations. (The scope is
>>>>>> lexical, thanks to Charles Frankstone.)
>>>>>>
>>>>>> Your XPath is a representation of:
>>>>>> "/persons/{?#1}:person[1]/@{?#2}:name"
>>>>>> but in order to know what the ?#1 and ?#2 are, you need some
>>>>>> additional information.
>>>>>>
>>>>>> One way you could do this is the same as XSTL, where the namespace
>>>>>> bindings are preserved in the runtime:
>>>>>> <view xmlns:foo="foo.bar" xmlns:secret="secret.names"
>>>>>> datapath="person/secret:person[1]/@foo:name"/>
>>>>>> or:
>>>>>> <canvas xmlns:foo="foo.bar" xmlns:secret="secret.names">
>>>>>> ...
>>>>>> <view datapath="person/secret:person[1]/@foo:name"/
>>>>>>
>>>>>>
>>>>>>> _______________________________________________
>>>>>>>
>>>>>>
>>>>>> Laszlo-dev mailing list
>>>>>> Laszlo-dev at openlaszlo.org
>>>>>> http://www.openlaszlo.org/mailman/listinfo/laszlo-dev
>>>>>>
>>>>>
>>>>>
>>>>
>>
>
More information about the Laszlo-dev
mailing list