Opened 12 years ago

Closed 11 years ago

#5766 closed enhancement (fixed)

[patch][ccla] Proposed extension: XML parser for rendering dojo

Reported by: Rob Gagne Owned by: alex
Priority: high Milestone: 1.2
Component: Dojox Version: 1.0
Keywords: xml parser Cc: RGagne@…, jmargaris@…
Blocked By: Blocking:


The attached patch reads XML and instantiates dojo components. Element names refer to the dojo component to be created, attributes refer to properties or event handlers.

XML can be included directly within <script/> tags or externally referenced via the script tags src attribute.

Some examples:

<ui xmlns:dijit="dijit">
<dijit:form.Button label="Hello, World!"/>

Using the namespace more:

<ui xmlns:dijit="dijit.form">
<dijit:Button label="Hello, World!"/>

HTML can be included within the XML by specifing html as the namespace uri.

<ui xmlns:dijit="dijit" xmlns="html">
<p>HTML before</p>
<dijit:form.Button label="Hello, World!"/>

The patch includes the code, some examples and the mail demo built through xml.

(Thank you to Alex for help and guidance with this)

Attachments (2)

dojoe.patch (109.3 KB) - added by guest 12 years ago.
xml-parser.patch (51.8 KB) - added by guest 12 years ago.
update to original patch to move code to dojox/xml

Download all attachments as: .zip

Change History (14)

Changed 12 years ago by guest

Attachment: dojoe.patch added


comment:1 Changed 12 years ago by bill

Component: GeneralDojox
Owner: changed from anonymous to Adam Peller

Hi. Can you add your name to the "Reporter" field and also list if you have a CLA or not?

comment:2 Changed 12 years ago by Adam Peller

Owner: changed from Adam Peller to Tom Trenka

comment:3 Changed 12 years ago by alex

Milestone: 1.1
Owner: changed from Tom Trenka to alex
Status: newassigned

comment:4 Changed 12 years ago by dylan

Reporter: changed from guest to Rob Gagne
Summary: Proposed extension: XML parser for rendering dojo[patch][ccla] Proposed extension: XML parser for rendering dojo

Reporter is Rob Gagne of Nexaweb. CCLA on file.

comment:5 Changed 12 years ago by guest

Thanks Dylan

  • Rob

comment:6 Changed 12 years ago by alex

so in looking at this, it's not clear why everything is being done under a "dojoe" namespace. This set of patches probably needs to land in a dojox namespace for now.

Any chance we can get the patch updated for that? Perhaps under dojo.xml?

comment:7 Changed 12 years ago by bill

BTW I looked this over a bit. Not sure why there is a HashTable? class in your patch but the implementation worries me given that two equal elements can get different hash keys:

if (!x._hashKey){ 
 	x._hashKey = dojoe.collections.Hashtable._uniqueKey++; 

which means that in the general case it's impossible to check if a given key is in the hash. (HashTable? also doesn't handle hash collisions.)

IIRC We had collection classes in Dojo 0.4 that worked well; if you really need a collection class, might just want to just port them over if they aren't there already.

comment:8 Changed 12 years ago by guest

(James Margaris here. I wrote the code)

  1. We can change to dojox and resubmit. Why was it dojoe instead? Odd historical reasons.
  1. Hashtable does not need to be included at all, it has nothing to do with the parser. Will remove from resubmit. As far as why it is written the way it is, perhaps Hashtable is not the best name, it maps unique object keys to values. Dictionary in earlier dojo versions appears to use the toString() method of objects to map keys to values, which means unique objects with the same toString() overwrite each other.

Two equal elements (however you define equality, which tends to be poor for things other than basic types) can get different hash keys but unique objects can not. It's designed to use arbitrary objects as keys.

It's not really a hashtable I suppose in that there isn't a hash function and the backing store isn't a numerically indexed array. It's a map that maps unique objects to values without relying on toString().

But anyway it was included by accident and will be removed.

If there is a dojo collection class that implements this functionality I would be happy to port it over. I don't think there is one, but I could be wrong about how dictionary operates.

Changed 12 years ago by guest

Attachment: xml-parser.patch added

update to original patch to move code to dojox/xml

comment:9 Changed 12 years ago by guest

(Rob Gagne reporting, code provided by James Margaris; CLA has been submitted)

Added new patch (didn't replace original since the name is obsolete). Patch moves the code from dojoe to dojox/xml

comment:10 Changed 12 years ago by alex

Cc: RGagne@… added

this is much cleaner. thank you.

comment:11 Changed 12 years ago by alex

Cc: jmargaris@… added

comment:12 Changed 11 years ago by alex

Resolution: fixed
Status: assignedclosed

(In [14044]) merging Nexaweb's awesome XML parser for Dojo markup. Thanks to James Margaris, Bob Buffone, Rob Gange, Coach Wei and everyone else who helped make this happen. Fixes #5766 !strict

Note: See TracTickets for help on using tickets.