Internet Explorer "conditional compilation is turned off"

38 views
Skip to first unread message

SteveYoungTbird

unread,
Dec 21, 2008, 2:41:30 PM12/21/08
to
I apologize if this is slightly of topic, please feel free not to answer
it if you feel that it is.

I have been using the BadgerFish convention to translate an XML document
into a JSON object. The convention rules are here
http://badgerfish.ning.com/ and they are summarized below:

The Rules
* Element names become object properties
* Text content of elements goes in the $ property of an object.
* Nested elements become nested properties
* Multiple elements at the same level become array elements.
* Attributes go in properties whose names begin with @.
* Active namespaces for an element go in the element's @xmlns property.
* The default namespace URI goes in @xmlns.$.
* Other namespaces go in other properties of @xmlns.
* Elements with namespace prefixes become object properties, too.

This works perfectly in Firefox but because the namespaces go in
properties of @xmlns, IE6 throws a "conditional compilation is turned
off" error when working with the resulting JSON object. It doesn't like
the "@".

I googled around and found a possible solution at
http://msdn.microsoft.com/en-us/library/5y5529x3(VS.71).aspx which
suggests adding /*@cc_on @*/ to the beginning of the code. I have tried
this and now it still works in Firefox but gives a "Expected identifier"
error in IE6.

Here are links to two scripts, one with /*@cc_on @*/ at
http://members.chello.at/stephen.joung/testsite/indexJSON_ShowProperties1.html
and one without at
http://members.chello.at/stephen.joung/testsite/indexJSON_ShowProperties1.html

The file test is a straightforward JSON file without namespaces and
test4 has namespaces. Both scripts work in FF but give the errors
mentioned above in IE6

So I have two questions:

1) Can Badgerfish converted JSON with namespaces be used with IE? if so how?
2) Is there another method of converting XML to JSON which can deal with
namespaces known to and recommended by the experienced people in c.l.j.?

Thanks for any assistance,

Steve.

David Mark

unread,
Dec 21, 2008, 3:19:05 PM12/21/08
to
On Dec 21, 2:41 pm, SteveYoungTbird <stephen.yo...@chello.at> wrote:
> I apologize if this is slightly of topic, please feel free not to answer
> it if you feel that it is.

Any post can be freely ignored; but for those that are OT, perhaps a
reader could tell you where they would be on topic.

>
> I have been using the BadgerFish convention to translate an XML document

> into a JSON object. The convention rules are herehttp://badgerfish.ning.com/and they are summarized below:


>
> The Rules
>      * Element names become object properties
>      * Text content of elements goes in the $ property of an object.
>      * Nested elements become nested properties
>      * Multiple elements at the same level become array elements.
>      * Attributes go in properties whose names begin with @.
>      * Active namespaces for an element go in the element's @xmlns property.
>      * The default namespace URI goes in @xmlns.$.
>      * Other namespaces go in other properties of @xmlns.
>      * Elements with namespace prefixes become object properties, too.

Sounds dreadful.

>
> This works perfectly in Firefox but because the namespaces go in
> properties of @xmlns, IE6 throws a "conditional compilation is turned
> off" error when working with the resulting JSON object. It doesn't like
> the "@".

That isn't surprising. So use something else or refrain from
evaluating the JSON object (parse it instead.)

>
> I googled around and found a possible solution athttp://msdn.microsoft.com/en-us/library/5y5529x3(VS.71).aspxwhich
> suggests adding /*@cc_on @*/ to the beginning of the code. I have tried

Apparently you didn't read the article carefully. If you turn CC *on*
then those "@" characters will be treated as CC variables. Obviously
that won't help matters.

> this and now it still works in Firefox but gives a "Expected identifier"
> error in IE6.

Not unexpectedly.

[snip]

Steve

unread,
Dec 21, 2008, 3:58:40 PM12/21/08
to
On Dec 21, 9:19 pm, David Mark <dmark.cins...@gmail.com> wrote:
> On Dec 21, 2:41 pm, SteveYoungTbird <stephen.yo...@chello.at> wrote:
>
> > I apologize if this is slightly of topic, please feel free not to answer
> > it if you feel that it is.
>
> Any post can be freely ignored; but for those that are OT, perhaps a
> reader could tell you where they would be on topic.
>
>
>
> > I have been using the BadgerFish convention to translate an XML document
> > into a JSON object. The convention rules are herehttp://badgerfish.ning.com/andthey are summarized below:

Mr Marks, It would be a good thing if you didn't answer posts when you
have nothing positive to offer. I suppose my honest request for
information will now deteriorate into a slanging match between you and
your "friends" and sensible users who might have had an answer to the
actual questions posed will not want to get involved. This is what
usually happens when you get involved in a thread and it is really a
shame. Just go to, for example, Google Maps API group to see how it
could be, with highly respected "Gurus" that are extremely helpful.

I assume that you were not born with your knowledge of Javascript and
therefore you had to learn it and I expect you were allowed the luxury
of asking questions during the learning process. So why do you get so
worked up and angry at people that are only trying to learn
javascript?

Regards, Steve.

David Mark

unread,
Dec 21, 2008, 4:15:41 PM12/21/08
to
On Dec 21, 3:58 pm, Steve <stephen.jo...@googlemail.com> wrote:
> On Dec 21, 9:19 pm, David Mark <dmark.cins...@gmail.com> wrote:
>
>
>
> > On Dec 21, 2:41 pm, SteveYoungTbird <stephen.yo...@chello.at> wrote:
>
> > > I apologize if this is slightly of topic, please feel free not to answer
> > > it if you feel that it is.
>
> > Any post can be freely ignored; but for those that are OT, perhaps a
> > reader could tell you where they would be on topic.
>
> > > I have been using the BadgerFish convention to translate an XML document
> > > into a JSON object. The convention rules are herehttp://badgerfish.ning.com/andtheyare summarized below:

You didn't see the answer to your question as a positive? What were
you looking for?

> information will now deteriorate into a slanging match between you and
> your "friends" and sensible users who might have had an answer to the

The question has been answered. What more is there to say?

> actual questions posed will not want to get involved. This is what

For fear of what exactly?

> usually happens when you get involved in a thread and it is really a
> shame. Just go to, for example, Google Maps API group to see how it
> could be, with highly respected "Gurus" that are extremely helpful.

LOL. I've seen their "Gurus" in action. Perhaps you should post your
question there (maybe you will get an answer you like better.)

>
> I assume that you were not born with your knowledge of Javascript and

That's a good assumption as Javascript didn't exist at the time.

> therefore you had to learn it and I expect you were allowed the luxury
> of asking questions during the learning process. So why do you get so
> worked up and angry at people that are only trying to learn
> javascript?

Interesting take. Why do you get so defensive when people are only
trying to answer your question?

[snip]

SteveYoungTbird

unread,
Dec 21, 2008, 4:30:52 PM12/21/08
to
David Mark wrote:
> On Dec 21, 3:58 pm, Steve <stephen.jo...@googlemail.com> wrote:
>> On Dec 21, 9:19 pm, David Mark <dmark.cins...@gmail.com> wrote:
>>
>>> [snip]
>> Mr Marks, It would be a good thing if you didn't answer posts when you
>> have nothing positive to offer. I suppose my honest request for
>
> You didn't see the answer to your question as a positive? What were
> you looking for?
>
[snip]

>
> Interesting take. Why do you get so defensive when people are only
> trying to answer your question?
>
> [snip]

I repeat the two questions I asked in the OP which you snipped from
your reply and which, despite what you claim, you haven't answered.

1) Can Badgerfish converted JSON with namespaces be used with IE? if so how?
2) Is there another method of converting XML to JSON which can deal with

namespaces which is known to and recommended by the experienced people
in c.l.j.?

Regards and Merry Christmas, Steve.

David Mark

unread,
Dec 21, 2008, 4:37:05 PM12/21/08
to
On Dec 21, 4:30 pm, SteveYoungTbird <stephen.yo...@chello.at> wrote:
> David Mark wrote:
> > On Dec 21, 3:58 pm, Steve <stephen.jo...@googlemail.com> wrote:
> >> On Dec 21, 9:19 pm, David Mark <dmark.cins...@gmail.com> wrote:
>
> >>> [snip]
> >> Mr Marks, It would be a good thing if you didn't answer posts when you
> >> have nothing positive to offer. I suppose my honest request for
>
> > You didn't see the answer to your question as a positive?  What were
> > you looking for?
>
> [snip]
>
> > Interesting take.  Why do you get so defensive when people are only
> > trying to answer your question?
>
> > [snip]
>
> I repeat the two questions I asked in the OP  which you snipped from
> your reply and which, despite what you claim, you haven't answered.

The question I did answer is the one I had an answer for. Perhaps
somebody else will answer your other questions. Less than likely
after this tantrum though.

[snip]

SteveYoungTbird

unread,
Dec 21, 2008, 4:48:23 PM12/21/08
to

Please look at the original post and count the question marks. There
were only two questions, the rest was background information.

I also doubt that I will get any answers now and that is why I would
really appreciate it if you would refrain from replying to my posts in
future. Please!

Regards, Steve

David Mark

unread,
Dec 21, 2008, 5:00:32 PM12/21/08
to
On Dec 21, 4:48 pm, SteveYoungTbird <stephen.yo...@chello.at> wrote:
> David Mark wrote:
> > On Dec 21, 4:30 pm, SteveYoungTbird <stephen.yo...@chello.at> wrote:
> >> David Mark wrote:
> >>> On Dec 21, 3:58 pm, Steve <stephen.jo...@googlemail.com> wrote:
> >>>> On Dec 21, 9:19 pm, David Mark <dmark.cins...@gmail.com> wrote:
> >>>>> [snip]
> >>>> Mr Marks, It would be a good thing if you didn't answer posts when you
> >>>> have nothing positive to offer. I suppose my honest request for
> >>> You didn't see the answer to your question as a positive?  What were
> >>> you looking for?
> >> [snip]
>
> >>> Interesting take.  Why do you get so defensive when people are only
> >>> trying to answer your question?
> >>> [snip]
> >> I repeat the two questions I asked in the OP  which you snipped from
> >> your reply and which, despite what you claim, you haven't answered.
>
> > The question I did answer is the one I had an answer for.  Perhaps
> > somebody else will answer your other questions.  Less than likely
> > after this tantrum though.
>
> > [snip]
>
> Please look at the original post and count the question marks. There
> were only two questions, the rest was background information.

Background information that led to a simple answer to your problem,
rendering the explicitly asked questions needless.

>
> I also doubt that I will get any answers now and that is why I would

Why would that be?

> really appreciate it if you would refrain from replying to my posts in
> future. Please!

Do you really think I will remember your name in an hour?

[snip]

SteveYoungTbird

unread,
Dec 21, 2008, 5:14:24 PM12/21/08
to
What simple answer to what problem? I want to convert XML (with
namespaces) to JSON, where do you show me how to do that?

>> I also doubt that I will get any answers now and that is why I would
>
> Why would that be?

Because you have snipped the questions for one.


>
>> really appreciate it if you would refrain from replying to my posts in
>> future. Please!
>
> Do you really think I will remember your name in an hour?
>

What if I wrote "replies from D.Mark not wanted" at the top of my posts? ;-)


Regards,

steve.
> [snip]

David Mark

unread,
Dec 21, 2008, 5:37:30 PM12/21/08
to

In my replies? So what?

>
> >> really appreciate it if you would refrain from replying to my posts in
> >> future. Please!
>
> > Do you really think I will remember your name in an hour?
>
> What if I wrote "replies from D.Mark not wanted" at the top of my posts? ;-)

Unlikey to have the desired effect.

[snip]

Owen Rees

unread,
Dec 22, 2008, 9:20:03 AM12/22/08
to
On Sun, 21 Dec 2008 23:14:24 +0100, SteveYoungTbird
<stephe...@chello.at> wrote in
<74769$494ebfc1$3eb29844$14...@news.chello.at>:

>What simple answer to what problem? I want to convert XML (with
>namespaces) to JSON, where do you show me how to do that?

Part of the problem is that that is not the problem you are facing. It
seems that you have a valid JSON text generated from the XML but it is
not a valid JavaScript Object literal.

The solution was terse and without an explanation of why but this is
where:

On Sun, 21 Dec 2008 12:19:05 -0800 (PST), David Mark
<dmark....@gmail.com> wrote in
<bde175da-22db-4da5...@v13g2000vbb.googlegroups.com>:

>On Dec 21, 2:41 pm, SteveYoungTbird <stephen.yo...@chello.at> wrote:

>> This works perfectly in Firefox but because the namespaces go in
>> properties of @xmlns, IE6 throws a "conditional compilation is turned
>> off" error when working with the resulting JSON object. It doesn't like
>> the "@".
>
>That isn't surprising. So use something else or refrain from
>evaluating the JSON object (parse it instead.)

The character '@' is not permitted in Javascript property names. This
one of a number of cases where a valid JSON text is not a valid
JavaScript object literal and so cannot simply be evaluated.

The solutions:
- use some prefix other than '@'
- use a parser that understands the full JSON syntax

--
Owen Rees
[one of] my preferred email address[es] and more stuff can be
found at <http://www.users.waitrose.com/~owenrees/index.html>

Thomas 'PointedEars' Lahn

unread,
Dec 22, 2008, 2:27:16 PM12/22/08
to
Owen Rees wrote:

> SteveYoungTbird wrote:
>> What simple answer to what problem? I want to convert XML (with
>> namespaces) to JSON, where do you show me how to do that?
>
> Part of the problem is that that is not the problem you are facing. It
> seems that you have a valid JSON text generated from the XML but it is
> not a valid JavaScript Object literal.

You are mistaken.

> The solution was terse and without an explanation of why but this is
> where:
>
> On Sun, 21 Dec 2008 12:19:05 -0800 (PST), David Mark
> <dmark....@gmail.com> wrote in
> <bde175da-22db-4da5...@v13g2000vbb.googlegroups.com>:
>
>> On Dec 21, 2:41 pm, SteveYoungTbird <stephen.yo...@chello.at> wrote:
>>> This works perfectly in Firefox but because the namespaces go in
>>> properties of @xmlns, IE6 throws a "conditional compilation is turned
>>> off" error when working with the resulting JSON object. It doesn't like
>>> the "@".
>> That isn't surprising. So use something else or refrain from
>> evaluating the JSON object (parse it instead.)
>
> The character '@' is not permitted in Javascript property names. This
> one of a number of cases where a valid JSON text is not a valid
> JavaScript object literal and so cannot simply be evaluated.

As David has explained already, that is _not_ the reason why. The problem
is caused instead by proprietary extensions of ECMAScript found in Microsoft
JScript that make syntax have special meaning when the proprietary feature
of Conditional Compilation is enabled.

<http://msdn.microsoft.com/en-us/library/7kx09ct1(VS.80).aspx>

While it is correct that '@' must not be the prefix of an ECMAScript
identifier, it may be the prefix of a property name; property names are
stored as strings, and so may begin with and contain *any* Unicode character
(which makes ECMAScript objects ultimately useful as a dictionary). IOW,

{@foo: "bar"}

is syntactically incorrect, while

{"@foo": "bar"}

is correct. In particular, because JSON quite wisely requires all property
names to be quoted, this is _not_ an issue with JSON per se:

<http://json.org/>

It only becomes an issue with JScript and Conditional Compilation being enabled.

> The solutions:
> - use some prefix other than '@'
> - use a parser that understands the full JSON syntax

Those are solutions for another problem.


PointedEars

Thomas 'PointedEars' Lahn

unread,
Dec 22, 2008, 2:38:04 PM12/22/08
to
Thomas 'PointedEars' Lahn wrote:
> Owen Rees wrote:
>> SteveYoungTbird wrote:
>>> What simple answer to what problem? I want to convert XML (with
>>> namespaces) to JSON, where do you show me how to do that?
>> Part of the problem is that that is not the problem you are facing. It
>> seems that you have a valid JSON text generated from the XML but it is
>> not a valid JavaScript Object literal.
>
> You are mistaken.

It is apparently not a valid *JScript* Object literal, see below.

>> The solution was terse and without an explanation of why but this is
>> where:
>>

>> David Mark wrote:


>>> SteveYoungTbird wrote:
>>>> This works perfectly in Firefox but because the namespaces go in
>>>> properties of @xmlns, IE6 throws a "conditional compilation is turned
>>>> off" error when working with the resulting JSON object. It doesn't like

^^^


>>>> the "@".
>>> That isn't surprising. So use something else or refrain from
>>> evaluating the JSON object (parse it instead.)
>> The character '@' is not permitted in Javascript property names. This
>> one of a number of cases where a valid JSON text is not a valid
>> JavaScript object literal and so cannot simply be evaluated.
>
> As David has explained already, that is _not_ the reason why. The problem
> is caused instead by proprietary extensions of ECMAScript found in Microsoft
> JScript that make syntax have special meaning when the proprietary feature

^^^^^^^^^^^^^^^^^^^^^^^^^^^^


> of Conditional Compilation is enabled.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Strike the last part. I read the error message again and it occured when
Conditional Compilation was _not_ enabled. So this would only always be an
issue with JScript, no matter the enabled state of its Conditional
Compilation feature. Insofar you are partially correct, and the solution to
this problem is to not use the `@' or to parse the string if there is no way
to let the script engine ignore the `@' but include it in the property name.

> <http://msdn.microsoft.com/en-us/library/7kx09ct1(VS.80).aspx>

PointedEars

SteveYoungGoogle

unread,
Dec 23, 2008, 9:08:20 AM12/23/08
to
On Dec 22, 8:38 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:

Thanks to Owen and Thomas I am moving in the right direction. I have
tried using JSON.parse(), available from http://www.json.org/js.html ,
instead of eval() but it keeps throwing exceptions. As soon as I get
it working I will post the solution.

Thanks again and happy holidays, Steve

Richard Cornford

unread,
Dec 23, 2008, 10:55:03 AM12/23/08
to
Thomas 'PointedEars' Lahn wrote:
> Thomas 'PointedEars' Lahn wrote:
>> Owen Rees wrote:
>>> SteveYoungTbird wrote:
>>>> What simple answer to what problem? I want to convert XML
>>>> (with namespaces) to JSON, where do you show me how to do
>>>> that?
>>> Part of the problem is that that is not the problem you are
>>> facing. It seems that you have a valid JSON text generated
>>> from the XML but it is not a valid JavaScript Object literal.
>>
>> You are mistaken.
>
> It is apparently not a valid *JScript* Object literal, see below.
<snip>

The thing that has been missing from this thread from the outset was a
(preferably simple) illustration of the "JSON" output from this XML to
JSON conversion process. As you said earlier, JSON has syntax rules that
define its particular sub-set of ECMAScript object literal notation, and
if the so called "JSON" output did not conform with those rules that
would have been obvious.

It is difficult to see how JScript could take issue with '@' symbols
appearing in string literals without that being a huge (common and
repeatedly mentioned) issue. So an experiment:-

<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">

var x = {
@somthing:"1"
};

</script>
</body>
</html>

The object literal above is not a syntactically correct ECMAScript
object literal because the 'Identifier' used in the name/value pair does
not conform to the syntax rules for an Identifier. In IE 6 the above
produces the "conditional compilation is turned off" error that is the
subject of this thread. What other browsers may make of this depends on
their own syntax extensions, but in pure ECMAScript terms it is just a
syntax error.

However, changing the above by adding double quotes around the 'name' in
the name/value pair to give:-

<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">

var x = {
"@somthing":"1"
};

</script>
</body>
</html>

- and IE 6 no longer has a problem; no errors are reported. JScript
apparently does not look inside string literals for occurrences of the
'@' symbol (at least no when CC is already 'off').

Thus the specific detail of JSON that you pointed out earlier, that
property names must be quoted in JSON, is the crux of the issue. It
appears that the XML to "JSON" process being used does not output valid
JSON at all, and the issue here is a direct consequence of that.

One of the great strengths of JSON is that Douglas Crockford designed it
to be simple, with the entire specification short enough to easily fit
on one side of a single sheet of paper. That really does not leave much
of an excuse for the authors of "JSON" software that dose not actually
output valid JSON.

Richard.

SteveYoungGoogle

unread,
Dec 23, 2008, 12:33:22 PM12/23/08
to
On Dec 23, 4:55 pm, "Richard Cornford" <Rich...@litotes.demon.co.uk>

wrote:
> Thomas 'PointedEars' Lahn wrote:
> > Thomas 'PointedEars' Lahn wrote:
> >> Owen Rees wrote:
> >>> SteveYoungTbird wrote:
> >>>> What simple answer to what problem? I want to convert XML
> >>>> (with namespaces) to JSON, where do you show me how to do
> >>>> that?
> >>> Part of the problem is that that is not the problem you are
> >>> facing. It seems that you have a valid JSON text generated
> >>> from the XML but it is not a valid JavaScript Object literal.
>
> >> You are mistaken.
>
> > It is apparently not a valid *JScript* Object literal, see below.
>
> <snip>
>
> The thing that has been missing from this thread from the outset was a
> (preferably simple) illustration of the "JSON" output from this XML to
> JSON conversion process. As you said earlier, JSON has syntax rules that
> define its particular sub-set of ECMAScript object literal notation, and
> if the so called "JSON" output did not conform with those rules that
> would have been obvious.
>
Actually, in the OP I mentioned two files, one called test without
namespaces and one called test4 with namespaces which were the output
of the process. Both files were in the same directory as the scripts.
Sorry if I was unclear about that.

[snip]


>
> Thus the specific detail of JSON that you pointed out earlier, that
> property names must be quoted in JSON, is the crux of the issue. It
> appears that the XML to "JSON" process being used does not output valid
> JSON at all, and the issue here is a direct consequence of that.
>

The JSON was converted from XML using the online tool at http://badgerfish.ning.com/
. I have since noticed that the test4 with namespaces also gives an
error "Invalid Label" in Firebug although the script runs in FF. I
have since tried with the example output for namespaces which is:

{ "alice" : { "bob" : { "$" : "david" , "@xmlns" : {"charlie" : "http:
\/\/some-other-namespace" , "$" : "http:\/\/some-namespace"} } ,
"charlie:edgar" : { "$" : "frank" , "@xmlns" : {"charlie":"http:\/\/
some-other-namespace", "$" : "http:\/\/some-namespace"} }, "@xmlns" :
{ "charlie" : "http:\/\/some-other-namespace", "$" : "http:\/\/some-
namespace"} } }

This also produces an error in Firebug, the "charlie:edgar" is invalid
apparently, if I change it to "charlieedgar" it works. However
neither work in IE6. I have uploaded both into the script directory
at
http://members.chello.at/stephen.joung/testsite/ they are test7.json
and test8.json

So it seems that you are correct and the Badgerfish JSON output is
suspect.

Thanks for your help. Steve.

SteveYoungGoogle

unread,
Dec 23, 2008, 4:07:11 PM12/23/08
to
On Dec 23, 6:33 pm, SteveYoungGoogle <stephen.jo...@googlemail.com>
wrote:

Also the link http://badgerfish.ning.com/ in the OP gives examples.

> [snip]
>
>
>
> > Thus the specific detail of JSON that you pointed out earlier, that
> > property names must be quoted in JSON, is the crux of the issue. It
> > appears that the XML to "JSON" process being used does not output valid
> > JSON at all, and the issue here is a direct consequence of that.
>

> The JSON was converted from XML using the online tool athttp://badgerfish.ning.com/


> . I have since noticed that the test4 with namespaces also gives an
> error "Invalid Label" in Firebug although the script runs in FF. I
> have since tried with the example output for namespaces which is:
>
> { "alice" : { "bob" : { "$" : "david" , "@xmlns" : {"charlie" : "http:
> \/\/some-other-namespace" , "$" : "http:\/\/some-namespace"} } ,
> "charlie:edgar" : { "$" : "frank" , "@xmlns" : {"charlie":"http:\/\/
> some-other-namespace", "$" : "http:\/\/some-namespace"} }, "@xmlns" :
> { "charlie" : "http:\/\/some-other-namespace", "$" : "http:\/\/some-
> namespace"} } }
>
> This also produces an error in Firebug, the "charlie:edgar" is invalid
> apparently, if I change it to "charlieedgar" it works. However
> neither  work in IE6. I have uploaded both into the script directory

> athttp://members.chello.at/stephen.joung/testsite/they are test7.json

Jorge

unread,
Dec 23, 2008, 4:46:28 PM12/23/08
to
On Dec 23, 6:33 pm, SteveYoungGoogle <stephen.jo...@googlemail.com>
wrote:
>
> So it seems that you are correct and the Badgerfish JSON output is
> suspect.
>
> Thanks for your help. Steve.

Nope, that JSON text is 100% allright. Do an eval('('+jsonTxt+')');,
instead of eval(jsonTxt);...

--
Jorge.

Owen Rees

unread,
Dec 23, 2008, 7:39:34 PM12/23/08
to
On Tue, 23 Dec 2008 09:33:22 -0800 (PST), SteveYoungGoogle
<stephe...@googlemail.com> wrote in
<9dba64cc-1d5a-452b...@b41g2000pra.googlegroups.com>:

>Actually, in the OP I mentioned two files, one called test without
>namespaces and one called test4 with namespaces which were the output
>of the process. Both files were in the same directory as the scripts.
>Sorry if I was unclear about that.

Looking back it seems to me that the same URL was given for the "two
files" and neither was actually the JSON itself.

Having had a very quick look at the code in the pages referenced in the
OP I must suggest that the function that navigates the object
constructed from the JSON looks rather odd. Are you absolutely sure that
it is the JSON (or its parsing) that is the problem and not the function
that navigates the constructed object?

Remember bug hunting rule 1: if you can't see the bug you are looking in
the wrong place.

Speaking of bugs, I must apologise for any incoherence. I have been
adopting the traditional large quantity of whisky (10 year old Laphroaig
in this case) cure for coughs colds and other possible flu-like
ailments.

Thomas 'PointedEars' Lahn

unread,
Dec 25, 2008, 1:02:20 AM12/25/08
to
Richard Cornford wrote:
> [...]

> However, changing the above by adding double quotes around the 'name' in
> the name/value pair to give:-
>
> [...]

> var x = {
> "@somthing":"1"
> };
> [...]

>
> - and IE 6 no longer has a problem; no errors are reported. JScript
> apparently does not look inside string literals for occurrences of the
> '@' symbol (at least no when CC is already 'off').

That's a relief, thanks. (I switched back to GNU/Linux recently -- WLAN
finally working! -- and thus could not test JScript myself as ies4linux
failed to install as of yet.)


Merry Christmas,

PointedEars

SteveYoungGoogle

unread,
Dec 31, 2008, 5:48:01 AM12/31/08
to
On Dec 24, 1:39 am, Owen Rees <or...@hotmail.com> wrote:
> On Tue, 23 Dec 2008 09:33:22 -0800 (PST), SteveYoungGoogle
> <stephen.jo...@googlemail.com> wrote in
> <9dba64cc-1d5a-452b-9983-d79844df0...@b41g2000pra.googlegroups.com>:

>
> >Actually, in the OP I mentioned two files, one called test without
> >namespaces and one called test4 with namespaces which were the output
> >of the process. Both files were in the same directory as the scripts.
> >Sorry if I was unclear about that.
>
> Looking back it seems to me that the same URL was given for the "two
> files" and neither was actually the JSON itself.

That is correct and obviously I didn't make a very good job of
explaining which files were which in the OP so I will try again. There
are two versions of the script that lists the properties of the JSON
files, one with /*@cc_on @*/ at
http://members.chello.at/stephen.joung/testsite/indexJSON_ShowPropert...
and one without at
http://members.chello.at/stephen.joung/testsite/indexJSON_ShowPropert...
I think we have decided that the /*@cc_on @*/ is not applicable here
and the problem lies elsewhere but I include both for completeness.

If you run these scripts you will see a form where you can input
either "test" "test4", etc. Default is "test4", and by clicking the
"Click to load the JSON menu file" button the file at
http://members.chello.at/stephen.joung/testsite/test.json or
http://members.chello.at/stephen.joung/testsite/json4.json is read.
There are now some other json files called "test2.json", "test3.json"
"test5.json" "test7.json" and "test8,json" available at
http://members.chello.at/stephen.joung/testsite/ . They can be read
into the file by inputing the first part of the name minus .json into
the form and clicking the button.

>
> Having had a very quick look at the code in the pages referenced in the
> OP I must suggest that the function that navigates the object
> constructed from the JSON looks rather odd. Are you absolutely sure that
> it is the JSON (or its parsing) that is the problem and not the function
> that navigates the constructed object?
>

It is entirely possible that the script that reads the JSON is wrong.
I would be grateful if someone could point out any error in it.

> Remember bug hunting rule 1: if you can't see the bug you are looking in
> the wrong place.
>

[snip]

Thanks for any help and i wish you all a Happy New Year!

Message has been deleted

SteveYoungGoogle

unread,
Dec 31, 2008, 5:56:10 AM12/31/08
to
On Dec 31, 11:48 am, SteveYoungGoogle <stephen.jo...@googlemail.com>
wrote:

> On Dec 24, 1:39 am, Owen Rees <or...@hotmail.com> wrote:
>
> > On Tue, 23 Dec 2008 09:33:22 -0800 (PST), SteveYoungGoogle
> > <stephen.jo...@googlemail.com> wrote in
> > <9dba64cc-1d5a-452b-9983-d79844df0...@b41g2000pra.googlegroups.com>:
>
> > >Actually, in the OP I mentioned two files, one called test without
> > >namespaces and one called test4 with namespaces which were the output
> > >of the process. Both files were in the same directory as the scripts.
> > >Sorry if I was unclear about that.
>
> > Looking back it seems to me that the same URL was given for the "two
> > files" and neither was actually the JSON itself.
>
> That is correct and obviously I didn't make a very good job of
> explaining which files were which in the OP so I will try again. There
> are two versions of the script that lists the properties of the JSON
> files, one with  /*@cc_on @*/ athttp://members.chello.at/stephen.joung/testsite/indexJSON_ShowPropert...
> and one without athttp://members.chello.at/stephen.joung/testsite/indexJSON_ShowPropert...

> I think we have decided that the /*@cc_on @*/ is not applicable here
> and the problem lies elsewhere but I include both for completeness.
>
> If you run these scripts you will see a form where you can input
> either "test" "test4", etc. Default is "test4", and by clicking the
> "Click to load the JSON menu file" button the file athttp://members.chello.at/stephen.joung/testsite/test.json or http://members.chello.at/stephen.joung/testsite/json4.json is read.

Sorry, a typo. The above link should read http://members.chello.at/stephen.joung/testsite/test4.json

> There are now some other json files called "test2.json", "test3.json"

> "test5.json" "test7.json" and "test8,json" available athttp://members.chello.at/stephen.joung/testsite/. They can be read

Jorge

unread,
Dec 31, 2008, 6:19:03 AM12/31/08
to
On Dec 31, 11:56 am, SteveYoungGoogle <stephen.jo...@googlemail.com>
wrote:

>
> Sorry, a typo. The above link should read http://members.chello.at/stephen.joung/testsite/test4.json
>

jsonTxt= (text at members.chello.at/stephen.joung/testsite/
test4.json);

jsonObj= eval(jsonTxt); // -> invalid label error.
jsonObj= eval('('+ jsonTxt +')'); // -> OK.

--
Jorge.

SteveYoungGoogle

unread,
Dec 31, 2008, 2:06:29 PM12/31/08
to
On Dec 31, 12:19 pm, Jorge <jo...@jorgechamorro.com> wrote:
> On Dec 31, 11:56 am, SteveYoungGoogle <stephen.jo...@googlemail.com>
> wrote:
>
>
>
> > Sorry, a typo. The above link should readhttp://members.chello.at/stephen.joung/testsite/test4.json

>
> jsonTxt= (text at members.chello.at/stephen.joung/testsite/
> test4.json);
>
> jsonObj= eval(jsonTxt); // -> invalid label error.
> jsonObj= eval('('+ jsonTxt +')'); // -> OK.
>
> --
> Jorge.

Hi Jorg,

I have changed the eval() as you suggest and in IE6 the same
"conditional compilation is turned
off" error is given and the script doesn't work.

In Firefox Firebug gives an "missing ) in parenthetical" error for
line 19 which is one of the eval() lines which I have changed. The
script runs in Firefox despite the warning.

The script including your suggested change is at
http://members.chello.at/stephen.joung/testsite/indexJSON_ShowProperties4.html

Owen Rees

unread,
Jan 1, 2009, 8:24:20 PM1/1/09
to
On Wed, 31 Dec 2008 02:48:01 -0800 (PST), SteveYoungGoogle
<stephe...@googlemail.com> wrote in
<7aaa07d2-3630-43a3...@v5g2000prm.googlegroups.com>:

>It is entirely possible that the script that reads the JSON is wrong.
>I would be grateful if someone could point out any error in it.

I think you will find that IE is complaining about the line
var contents = eval(varname);
in your 'look' function for some values of 'varname'. I would expect
there to be problems in the cases where the object property names are
neither integers nor valid identifiers given the way in which 'varname'
is constructed. IE appears to be seeing something it interprets as
containing conditional complation for some values of 'varname'.

SteveYoungTbird

unread,
Jan 2, 2009, 2:11:57 PM1/2/09
to
Owen Rees wrote:
> On Wed, 31 Dec 2008 02:48:01 -0800 (PST), SteveYoungGoogle
> <stephe...@googlemail.com> wrote in
> <7aaa07d2-3630-43a3...@v5g2000prm.googlegroups.com>:
>
>> It is entirely possible that the script that reads the JSON is wrong.
>> I would be grateful if someone could point out any error in it.
>
> I think you will find that IE is complaining about the line
> var contents = eval(varname);
> in your 'look' function for some values of 'varname'. I would expect
> there to be problems in the cases where the object property names are
> neither integers nor valid identifiers given the way in which 'varname'
> is constructed. IE appears to be seeing something it interprets as
> containing conditional complation for some values of 'varname'.
>

But what?

I have tidied up the script a bit and have included as default a version
of the BookCatalogue.xml in JSON format that works and doesn't give any
errors in Firefox/Firebug but gives the "conditional compilation is
turned off" error in IE6.

The script is at
http://members.chello.at/stephen.joung/testsite/indexJSON_ShowProperties5.html
and the JSON file at
http://members.chello.at/stephen.joung/testsite/test10.json

Thanks, Steve.

Owen Rees

unread,
Jan 2, 2009, 4:39:01 PM1/2/09
to
On Fri, 02 Jan 2009 20:11:57 +0100, SteveYoungTbird
<stephe...@chello.at> wrote in
<e0d7c$495e66fd$3eb29844$14...@news.chello.at>:

>But what?
>
>I have tidied up the script a bit and have included as default a version
>of the BookCatalogue.xml in JSON format that works and doesn't give any
>errors in Firefox/Firebug but gives the "conditional compilation is
>turned off" error in IE6.
>
>The script is at
>http://members.chello.at/stephen.joung/testsite/indexJSON_ShowProperties5.html
>and the JSON file at
>http://members.chello.at/stephen.joung/testsite/test10.json

Look at the output when you run it with Firefox.

The second line under the button is:
data.BookCatalogue.Book[0].Title.@xmlns.$ = http://www.publishing.org

When that line was constructed, 'varname' must have had the value
"data.BookCatalogue.Book[0].Title.@xmlns.$" and that string was passed
as the argument to eval.

When using the dot notation the property name must be a valid identifier
and '@xmlns' is not a valid identifier.

Try replacing your loadJSON function with this:

function loadJSON() {
data = ( {"@x": "y"} );
look("data");
}

IE will complain about conditional compilation. Firefox will apparently
silently allow the incorrect identifier syntax.

Fix your 'look' function so that it does not generate and then attempt
to evaluate syntactically incorrect expressions. The best approach would
be to not use 'eval' at all.

SteveYoungTbird

unread,
Jan 2, 2009, 5:24:38 PM1/2/09
to

Hi Owen thanks for taking the time to help with this.

If I understand correctly what you are saying, then JScript cannot
evaluate JSON translated according to the Badgerfish convention because
@xmlns is not a valid identifier. However according to Badgerfish:

* Active namespaces for an element go in the element's @xmlns property.

Now, parsing JSON kind of defeats the object (pun intended) and so I
come back to the original two questions from my OP:

1) Can Badgerfish converted JSON with namespaces be used with IE? if so how?
2) Is there another method of converting XML to JSON which can deal with

namespaces known to and recommended by the experienced people in c.l.j.?

Regards, Steve

SteveYoungTbird

unread,
Jan 3, 2009, 1:58:50 PM1/3/09
to
Thanks to Toby A Inskster at the JSON Schema Newsgroup I have fixed the
problem. In short the "look" function tried to access
properties using the obj.prop syntax, rather than obj["prop"] syntax and
IE didn't like that. If you are interested the full answer is here
http://groups.google.com/group/json-schema/browse_thread/thread/8fcedf6537b409a8

I have corrected the script accordingly and it now works in both FF and
IE. You can check it for yourselves at
http://members.chello.at/stephen.joung/testsite/indexJSON_ShowProperties7.html

Many thanks to all who participated in trying to find a solution, I am
very grateful.

Regards, Steve.

Owen Rees

unread,
Jan 3, 2009, 7:22:19 PM1/3/09
to
On Fri, 02 Jan 2009 23:24:38 +0100, SteveYoungTbird
<stephe...@chello.at> wrote in
<d2c75$495e9425$3eb29844$42...@news.chello.at>:

>If I understand correctly what you are saying, then JScript cannot
>evaluate JSON translated according to the Badgerfish convention because
>@xmlns is not a valid identifier. However according to Badgerfish:

No, you have missed the point completely.

You also appear to have ignored my advice to fix your 'look' function so


that it does not generate and then attempt to evaluate syntactically
incorrect expressions.

The modified 'loadJSON' function I suggested you try does not retrieve
anything from any remote source and *** DOES NOT USE JSON AT ALL *** but
still provokes the error you are reporting.

It uses a simple object literal in the code. You can replace the object
literal with code that sets a property and get the same effect.

The 'look' function that tries to navigate the object will fail under a
whole lot of conditions that have absolutely nothing whatsoever to do
with JSON or anything else related to retrieving data from remote
sources.

*** GET RID OF THE ABOMINATION THAT IS THE 'look' FUNCTION ***.

Reply all
Reply to author
Forward
0 new messages