xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip Arad" <philip_a...@hotmail.com>
Subject Confusion between ATTRIBUTE_NODE and TEXT_NODE
Date Wed, 30 Jan 2002 10:33:50 GMT
Dear all

I am parsing a org.apache.batik.dom.svg.SVGOMDocument with this
recursive Program:

private void parseSVG(Node aNode) throws AppException
{
	switch (vType)
	{
		//ELEMENT_NODE = 1
		case Node.ELEMENT_NODE:
			NamedNodeMap vAtts = aNode.getAttributes();
			for(int i = 0; i < vAtts.getLength(); i++)
			{
				Node vAtt = vAtts.item(i);
				//Parse children of the Node
				parseTemplate(vAtt);
			}
			break;
			//ATTRIBUTE_NODE = 2
		case Node.ATTRIBUTE_NODE:
			break;
			//TEXT_NODE = 3
		case Node.TEXT_NODE:
			break;
			//CDATA_SECTION_NODE = 4
		case Node.CDATA_SECTION_NODE:
			break;
			//ENTITY_REFERENCE_NODE = 5
		case Node.ENTITY_REFERENCE_NODE:
			break;
			//ENTITY_NODE = 6
		case Node.ENTITY_NODE:
			break;
			//PROCESSING_INSTRUCTION_NODE = 7
		case Node.PROCESSING_INSTRUCTION_NODE:
			break;
			//COMMENT_NODE = 8
		case Node.COMMENT_NODE:
			break;
			//DOCUMENT_NODE = 9
		case Node.DOCUMENT_NODE:
			break;
			//DOCUMENT_TYPE_NODE = 10
		case Node.DOCUMENT_TYPE_NODE:
			NamedNodeMap vNodeMap = ((DocumentType)aNode).getEntities();
			for(int i = 0; i < vNodeMap.getLength(); i++)
			{
				Entity vEntity = (Entity)vNodeMap.item(i);
				parseTemplate(vEntity);
			}
			break;
			//DOCUMENT_FRAGMENT_NODE = 11
		case Node.DOCUMENT_FRAGMENT_NODE:
			break;
			//NOTATION_NODE = 12
		case Node.NOTATION_NODE:
			break;
			//UNSUPPORTED NODE
		default:
			break;
	}
	for (Node vChild = aNode.getFirstChild(); vChild != null;vChild = 
vChild.getNextSibling())
	{
		parseTemplate(vChild);
	}
}


The svg is:

<svg width="45" height="46" xml:space="default">

  <title>Test</title>
  <desc>This a test</desc>

//...

</svg>

The problem is as follow:
The attribute width="45" for example is considered also as 2 things:

As an attribute:
Node:org.apache.batik.dom.GenericAttr@436eb7
Node Value:46

As a Text
Node:org.apache.batik.dom.GenericText@19d25d
Node Value:46

In this case I have always two entries instead of one.
Is ther a standard batik way to parse the SVGDocument?

Philip



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message