OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

cgmo-webcgm message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: RE: [cgmo-webcgm] ISSUE: regex APS addressing


Hi Stuart,

As far as I know, the WebCGM 2.0 DOM doesn't support the "*" wild
string. Maybe it would be useful but on the flip side, it could cause
some memory issues when loading a WebCGM containing a large about of
objects.

I would have done something along the lines of:

var first = myMetafile.firstPicture.firstChild;
var myList;

if( first ) {
	var obj = first;
	myList = obj.toNodeList();
	if( obj.hasChildNodes() ) {
		appendChildNodes( myList, obj );
	}
	obj = obj.nextSibling;
	while( obj ) {
		appendNode( myList, obj );
		obj = obj.nextSibling;
	}
}

appendChildNodes( nodelist, obj )
{
	var child = obj.firstChild;
	while( child ) {
		appendNode( nodelist, child );
		child = child.nextSibling;
	}
}

appendNode( nodelist, obj )
{
	nodelist.append(obj);
	if( obj.hasChildNodes() )
		appendChildNodes( nodelist, obj );
}

I haven't coded or tried this, but it should give you an idea.

Actually this is task/test that should have been done in the 2.0 time
frame. I think it would be good for the specification if this example
were as slick as possible. So if there's an API that's missing:
WebCGMPicture::createNodeList() that would greatly ease the example, we
should consider adding it to the 2.1 specification. Note: I came up with
createNodeList(), I'm not saying it is needed, just an example.

Cheers,
Ben.


-----Original Message-----
From: Galt, Stuart A [mailto:stuart.a.galt@boeing.com] 
Sent: Tuesday, February 19, 2008 11:52 AM
To: cgmo-webcgm@lists.oasis-open.org
Subject: RE: [cgmo-webcgm] ISSUE: regex APS addressing

Hello all,

I have attached an html that will open an arbitrary WebCGM and will
allow you to select an attribute and enter a regular expression.  It
will then produce a list of the application structures that match the
regular expression.

Please test this html using your favorite viewer and let me know (either
to the list or privately) if it works correctly.  I would like to make
sure that we have at least two implementations that will work when we
get to that stage.

I have tested this on my circuit, tic-tac-toe, and a couple of images
used in the test suite.  If an attribute is unspecified it will show up
in my

list of nodes as  NODEID (myattribue="").  I make no effort to consider
inheritance and only search on the specified values of attributes.

One thing that should be noted is that when you enter a regular
expression into the text field you must hit the submit button and not a
carriage return.
For some reason a carriage return will cause a reload of the HTML and
you will need to select a CGM image again.

I am probably misunderstanding how things should work but I was having
lots of problems trying to create/manipulate a webCGMNodeList.  I went
back to the simple cases in the test suite and they work, but all we do
is a very simple add/delete test...

It is not in the spec but I tried:
var nl = new WebCGMNodeList();
It of course does not work... Do we have a need to have a way to create
an empty list?  If I am the only one to have tried this then the answer
is probably no.

I also tried:
var nl = myFirstNode.toNodeList();
This creates a WebCGMNodeList but if I remove item(0) to make it empty
or when I try to append the first APS I found it will toss an exception.
The
spec says that if you try to append an item that is already in a
WebCGMNodeList it will remove it from the current location and append it
onto the end.
This
is not tested in the test suite..

I finally got tired to trying to make WebCGMNodeList work the way I
wanted to and just used a plain old vanilla javascript Array().  My
original thought was that I would be able to get all of the APS in one
call with something along the lines of:
var allNodes = document.getElementsByTagName('*');
This gives me all of the HTML nodes... and var allNodes =
picture.getAppStructuresByName('*');
doesn't work either.  So I "lifted" a bit of code to walk the WebCGM DOM

tree and add the nodes to an array.

Even though the HTML is 100+ lines long the real "code" that does the
regex comparison is just a javascript match within the processAttr()
function.



--
Stuart Galt
SGML Resource Group
stuart.a.galt@boeing.com
(206) 544-3656



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]