You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Alex Harui <ah...@adobe.com> on 2016/09/19 18:35:11 UTC
[FlexJS} QName toString()
Hi,
FlexJS has a Qname class. Looks like it is mostly used in XML. It has a
toString() that adds a "::" between the uri and localname. Is toString()
being used anywhere?
I want to change Qname.toString() to produce a valid JS identifier. Then
I can use Qname outside of XML. If mx_internal which is a namespace used
in a qname has the uri of "http://www.a.com/foo/bar" is used in
Qname(mx_internal, "baz"), you currently get a toString() of
"http://www.a.com/foo/bar::baz". I believe that ':' and "/" and '.' are
not valid in JS identifiers, so I would just replace them all with "_"
(yes, I know I could URIEncode them, but it makes it less readable) so the
result would be "http___www_a_com_foo_bar_baz".
This would allow us to support
mx_internal function baz()
Which would then cross compile to:
someClass.prototype.http___www_a_com_foo_bar_baz = function()
And access like
Var baz:Qname = Qname(mx_internal, "baz");
someClass[baz] would then work.
Thoughts?
-Alex
Re: [FlexJS} QName toString()
Posted by Alex Harui <ah...@adobe.com>.
OK, I'll try to find another way.
On 9/19/16, 12:12 PM, "Harbs" <ha...@gmail.com> wrote:
>Yes. I’m pretty sure it’s used to implicitly convert a qname into a
>proper string representation to an XML name. This can be in client code
>such as var foo:String = myXML.name(). It’s also used in
>XML.toAttributeName().
>
>On Sep 19, 2016, at 9:35 PM, Alex Harui <ah...@adobe.com> wrote:
>
>> Hi,
>>
>> FlexJS has a Qname class. Looks like it is mostly used in XML. It has
>>a
>> toString() that adds a "::" between the uri and localname. Is
>>toString()
>> being used anywhere?
>>
>> I want to change Qname.toString() to produce a valid JS identifier.
>>Then
>> I can use Qname outside of XML. If mx_internal which is a namespace
>>used
>> in a qname has the uri of "http://www.a.com/foo/bar" is used in
>> Qname(mx_internal, "baz"), you currently get a toString() of
>> "http://www.a.com/foo/bar::baz". I believe that ':' and "/" and '.' are
>> not valid in JS identifiers, so I would just replace them all with "_"
>> (yes, I know I could URIEncode them, but it makes it less readable) so
>>the
>> result would be "http___www_a_com_foo_bar_baz".
>> This would allow us to support
>>
>> mx_internal function baz()
>>
>> Which would then cross compile to:
>>
>> someClass.prototype.http___www_a_com_foo_bar_baz = function()
>>
>> And access like
>>
>> Var baz:Qname = Qname(mx_internal, "baz");
>> someClass[baz] would then work.
>>
>> Thoughts?
>> -Alex
>>
>
Re: [FlexJS} QName toString()
Posted by Harbs <ha...@gmail.com>.
Yes. I’m pretty sure it’s used to implicitly convert a qname into a proper string representation to an XML name. This can be in client code such as var foo:String = myXML.name(). It’s also used in XML.toAttributeName().
On Sep 19, 2016, at 9:35 PM, Alex Harui <ah...@adobe.com> wrote:
> Hi,
>
> FlexJS has a Qname class. Looks like it is mostly used in XML. It has a
> toString() that adds a "::" between the uri and localname. Is toString()
> being used anywhere?
>
> I want to change Qname.toString() to produce a valid JS identifier. Then
> I can use Qname outside of XML. If mx_internal which is a namespace used
> in a qname has the uri of "http://www.a.com/foo/bar" is used in
> Qname(mx_internal, "baz"), you currently get a toString() of
> "http://www.a.com/foo/bar::baz". I believe that ':' and "/" and '.' are
> not valid in JS identifiers, so I would just replace them all with "_"
> (yes, I know I could URIEncode them, but it makes it less readable) so the
> result would be "http___www_a_com_foo_bar_baz".
> This would allow us to support
>
> mx_internal function baz()
>
> Which would then cross compile to:
>
> someClass.prototype.http___www_a_com_foo_bar_baz = function()
>
> And access like
>
> Var baz:Qname = Qname(mx_internal, "baz");
> someClass[baz] would then work.
>
> Thoughts?
> -Alex
>