Bug 243018 - [api] WTP DOM Attribute nodes should support text and entity nodes
Summary: [api] WTP DOM Attribute nodes should support text and entity nodes
Status: NEW
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: Future   Edit
Assignee: wst.xml CLA
QA Contact: Nick Sandonato CLA
URL: ORACLE_P2
Whiteboard:
Keywords: helpwanted
Depends on: 214440
Blocks: 214439 242814
  Show dependency tree
 
Reported: 2008-08-04 00:21 EDT by David Carver CLA
Modified: 2013-07-18 14:17 EDT (History)
5 users (show)

See Also:


Attachments
Make sure PreviousSibling, NextSibling, and ParentNode return null for Attributes (4.69 KB, patch)
2011-02-21 21:50 EST, David Carver CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Carver CLA 2008-08-04 00:21:48 EDT
Eclipse 3.4
WTP 3.0

The DOM Level 1 Core specification:

http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html

Attr nodes can have two children nodes.   Currently the WTP DOM Level 1 assumes that the attributes will not have any nodes, and that the value that is returned is the only value.  However, this isn't correct according to the specification.  Attr element in the DOM can have Text and/or EntityReference elements as children.

The XSL Tools project needs this support for bug 242814.   EntityReference nodes will need to have Entity nodes as specified by the spec.  This allows WTP to not have to expand the entity but provide a reference back to the expanded version so that tooling can pull out the expanded version during processing.  The entityreference would still allow the existing WTP behavior for editing purposes.

An EntityReference is a Node object and inherits all of the Node object methods.
Comment 1 Nitin Dahyabhai CLA 2008-08-04 23:32:31 EDT
Dave, is it possible to create the Node objects when requested?  The raw text is always available, so unless those Nodes are required to be constant in memory for some sort of event notification, it would take less memory to simply create them as needed.
Comment 2 David Carver CLA 2008-08-05 11:23:11 EDT
(In reply to comment #1)
> Dave, is it possible to create the Node objects when requested?  The raw text
> is always available, so unless those Nodes are required to be constant in
> memory for some sort of event notification, it would take less memory to simply
> create them as needed.

Only a reference to the node needs to exist.  The entity node itself can be created when the EntityReference nodes's get childNodes method is called, at that point the entity node is created.

Entity reference nodes actually exist is multiple places.   So an attribute value that looks like the  following:

<xsl:value-of select="translate($var1, &uppercase;, &lowercase;)"/>

Would have the following nodes on the attribute:

select (Attribute Node)
   text() = "translate($var1, "
   entityReference = &uppercase;
   text() = ", "
   entityReference = &lowercase;
   text() = ")"

When the entityReference node is called that is when any child nodes would be created as read Only items.

See the DOM Level 1 core specification for more detail.

The important part for me is making sure I get the actual entity nodes so I can pull their value out from the content model that the DTD provides.
Comment 3 David Carver CLA 2008-08-22 08:57:53 EDT
Some of this was already implemented with regards to 21440.  The W3C DOM Conformance test suite tests for this support.  If bug 214439 and bug 214440 are implemented it will take care of this request.   Plus there is a full test suite that can be run to verify the conformance.

Any possibility of getting me some help to actually look at getting WTP's DOM to pass the test suite.  It'll take a lot of small patches, and verification of existing code.
Comment 4 David Carver CLA 2008-08-31 14:36:46 EDT
I was planning to address bug 242814 in XSL Tools incubator this release, but it is really blocked by this bug until it is addressed at the WTP DOM.  Any idea if this will be addressed in 3.1M2 or 3.1M3?
Comment 5 Nitin Dahyabhai CLA 2008-11-12 14:20:01 EST
Not so far.  I think this is one of the areas we were hoping to get help from you on.
Comment 6 David Carver CLA 2008-11-12 15:16:26 EST
(In reply to comment #5)
> Not so far.  I think this is one of the areas we were hoping to get help from
> you on.
> 

Well, the issue right now is that the WTP DOM really needs to address and pass the various DOM Level 1 compliance tests.   I started that this work in Bug 214439 but when I started submitting patches it seemed to cause some alarm to the amount of changes that were happening.

I have no problem working on this but it needs a level of committment from WTP committers to review it as well.
Comment 7 Cameron Bateman CLA 2008-11-13 13:18:15 EST
> I have no problem working on this but it needs a level of committment from 
> WTP committers to review it as well.

I would be interested in seeing some of Dave's improvements move forward as well. Could we start by enumerating some less controversial changes?  This one seems like a decent candidate. 
Comment 8 David Carver CLA 2008-11-13 13:29:45 EST
(In reply to comment #7)
> > I have no problem working on this but it needs a level of committment from 
> > WTP committers to review it as well.
> 
> I would be interested in seeing some of Dave's improvements move forward as
> well. Could we start by enumerating some less controversial changes?  This one
> seems like a decent candidate. 
> 

The issue with this one is the way the org.w3c.dom.Attr interface is implemented.  Right now the assumption (which is wrong by WTP DOM), is that attributes don't have nodes.   So the way the classes are extending the SSE Node class, is that none of the node related methods are inheritted from the class.  The way the Node is implemented needs to be changed so that it correctly makes available to the lower classes the correct methods.

According to the specification, Attributes can have Text and EntityReference nodes.  So if you had something like the following:

somevalue="attr &amp;more text" 

You should get the following nodes:

text()
entityreference()
text()

So this relatively small change actually affects several classes.  Which is where the panic came in, in the past.

The DOM Level 1 conformance test, tests for this case, and WTP currently fails it.

Comment 9 Cameron Bateman CLA 2008-11-13 13:43:14 EST
> So this relatively small change actually affects several classes.  Which is
> where the panic came in, in the past.
> The DOM Level 1 conformance test, tests for this case, and WTP currently 
> fails it.

Are there any conformance test failures for which the fixes are less impactful?  Could we start with those?

Comment 10 David Carver CLA 2008-11-13 13:54:08 EST
(In reply to comment #9)
> > So this relatively small change actually affects several classes.  Which is
> > where the panic came in, in the past.
> > The DOM Level 1 conformance test, tests for this case, and WTP currently 
> > fails it.
> 
> Are there any conformance test failures for which the fixes are less impactful?
>  Could we start with those?
> 

Yes..take a look at bug 214439 and bug 214440 for the original results, and a patch that allows the DOM test suite to be run from within the eclipse IDE, using the standard Junit framework, and plugin interface.
Comment 11 David Carver CLA 2011-02-21 21:50:56 EST
Created attachment 189453 [details]
Make sure PreviousSibling, NextSibling, and ParentNode return null for Attributes

Patch adds support to guarantee that Attributes always return null for the PreviousSibling, NextSibling, and ParentNode methods of DOM Level 1.