f



Why treat text nodes as nodes?

One of the things I find most unnatural about most XML APIs is that
they try to abstract both elements and text into some kind of "node"
object when they have virtually nothing in common. The reason these
APIs do it is to make it possible for both text and elements to be
children of elements.

But there is another way.

The XPath/XQuery data model does not allow two consecutive text nodes.
As far as I can tell, most XML processing software automatically merges
consecutive text nodes. This means that the number of text segments
directly under an element is bound by the number of sub-elements plus 1
(PIs and comments may be treated as "pseudo-elements" for this
purpose). As a result, it is always possible to associate each text
segment with the element immediately preceding it within the parent and
associate the first text element with the parent itself.

No more text nodes.

The only API I know that uses this trick is the ElementTree API for
Python by Fredrik Lundh (http://effbot.org/zone/element-index.htm).
Each Element object has a text and tail property for the text
immediately inside the element and text following it within its parent
element. Elements always have a tag, attributes and and zero or more
children - which are always other elements. No mixed types. The text
and tail attributes are always strings. This model should be very
convenient for statically-typed languages like Java or C++. I find it
ironic that this idea is probably used only in Python- a dynamically
typed language that is much more comfortable with mixed data types.

This form of API is very suitable for data-oriented XML applications
that don't use mixed elements: for leaf elements just use the .text
attribute and ignore everything else. Container elements use the
element's children which are always other elements. The text attribute
of an element can be ignore if it has children. No need to explicitly
skip it. Tails are always ignored, unless used to indent the output,
which can be done easily without disturbing the rest of the data.

For document-oriented XML it may be slightly awkward to look at both
the text and tail but I don't think it should be any more difficult
than dealing with mixed data types.

The only real downside seems to be that this API is non-standard. But
the advantages can easily compensate for that.

Would you like to see an API like this in Java? Do you know of any
implementations of this idea in any language other than Python?

XE

0
xamle.eng (3)
5/13/2005 6:33:10 PM
comp.text.xml 8781 articles. 0 followers. Post Follow

8 Replies
496 Views

Similar Articles

[PageSpeed] 46

In article <1116009190.713780.242540@g47g2000cwa.googlegroups.com>,
Xamle Eng <xamle.eng@gmail.com> wrote:

>For document-oriented XML it may be slightly awkward to look at both
>the text and tail but I don't think it should be any more difficult
>than dealing with mixed data types.

It seems very unnatural to me.  If you have

  <p>See <a href="...">my page</a> for more details</p>

why on earth would you want to associate the test " for more details"
with the <a> element preceding it?  The usual way of handling it -
some text, followed by an <a> element, followed by some more text - is
exactly right.

There are some applications where whitespace can be usefully be
associated with the preceding element, but a general-purpose API
should not assume even that.

-- Richard
0
richard91 (3692)
5/13/2005 9:37:20 PM
Richard Tobin wrote:
> In article <1116009190.713780.242540@g47g2000cwa.googlegroups.com>,
> Xamle Eng <xamle.eng@gmail.com> wrote:
>
> >For document-oriented XML it may be slightly awkward to look at both
> >the text and tail but I don't think it should be any more difficult
> >than dealing with mixed data types.
>
> It seems very unnatural to me.  If you have
>
>   <p>See <a href="...">my page</a> for more details</p>
>
> why on earth would you want to associate the test " for more details"
> with the <a> element preceding it?

As I said, this model is probably more natural for data-oriented XML,
but I think it's perfectly usable for document-oriented XML, too. It
preserves the structural information and makes it accessible to your
code in a form where everything has exactly one type, known in advance
at compile time. The tail association is totally arbitrary but it works
very well in practice. Try it. Write some code. Don't always trust your
initial gut reaction. I find that code using the ElementTree API if far
shorter and easier to read than with DOM or DOM-like APIs.

> There are some applications where whitespace can be usefully be
> associated with the preceding element, but a general-purpose API
> should not assume even that.

It doesn't assume that. And it it isn't "usefully" associated - it's
just a place to put it that is consistent, easy to access when you need
it and easier to ignore when you don't. 

XE

0
xamle.eng (3)
5/14/2005 5:40:08 PM
In article <1116092408.046100.183840@g47g2000cwa.googlegroups.com>,
Xamle Eng <xamle.eng@gmail.com> wrote:
>Try it. Write some code.

I don't think so.  I have perfectly good interfaces already, I'm not going
to switch to an obviously silly interface because someone says "try it".

>It doesn't assume that. And it it isn't "usefully" associated - it's
>just a place to put it that is consistent, easy to access when you need
>it and easier to ignore when you don't. 

How is it "easy to access" when I have to keep hold of the previous item
to access it?  And I have to do something different for the first text node
then all the others.

-- Richard
0
richard91 (3692)
5/15/2005 2:10:49 PM
Xamle Eng wrote:
> One of the things I find most unnatural about most XML APIs is that
> they try to abstract both elements and text into some kind of "node"
> object when they have virtually nothing in common. The reason these
> APIs do it is to make it possible for both text and elements to be
> children of elements.

With seven node types (element, attribute, text, NS node, comment, PI 
and document/root), it won't be that much of a cleanup to remove one?

> But there is another way.
> 
> The XPath/XQuery data model does not allow two consecutive text nodes.
> As far as I can tell, most XML processing software automatically merges
> consecutive text nodes. This means that the number of text segments
> directly under an element is bound by the number of sub-elements plus 1
> (PIs and comments may be treated as "pseudo-elements" for this
> purpose). As a result, it is always possible to associate each text
> segment with the element immediately preceding it within the parent and
> associate the first text element with the parent itself.

....then the first text segment is sort of semantically different from 
the rest? It will be found on the parent -- the rest on its children?

> This model should be very
> convenient for statically-typed languages like Java or C++. I find it
> ironic that this idea is probably used only in Python- a dynamically
> typed language that is much more comfortable with mixed data types.

Yes the general Node type can make things look clumsy sometimes. 
Polymorphism is for solving that ..., or generics:

Iterator<Element> children()
Iterator<Text> textNodes()
....etc are no problem to implement effeciently

> For document-oriented XML it may be slightly awkward to look at both
> the text and tail but I don't think it should be any more difficult
> than dealing with mixed data types.

It could get confusing that the first text element under a parent gets 
different from the rest -- you have to look it up on the parent.

> The only real downside seems to be that this API is non-standard. But
> the advantages can easily compensate for that.

Instead of mixed representation types in mixed contents, don't you just 
get a pile of .tail references that you have to check for nullity as you 
iterate over element contents? Not all that much better, I think :) (and 
harder to describe).

> Would you like to see an API like this in Java? Do you know of any
> implementations of this idea in any language other than Python?

No, don't know. But the idea of replacing some parent to child 
relationships in trees by sibling to sibling relationships is not at all 
new :)

Soren

0
5/15/2005 11:20:49 PM
On 13 May 2005 11:33:10 -0700, "Xamle Eng" <xamle.eng@gmail.com> wrote:

>As a result, it is always possible to associate each text
>segment with the element immediately preceding it within the parent and
>associate the first text element with the parent itself.

I'll hold him down, someone else can break his fingers.

That's the most fuckwittedly stupid idea I've read on the whole of
usenet in the last week. 

The web is a great thing. Even "internet time" is quite fun, when it's
all rolling along nicely. But can we _please_ do without the clueless
muppet teenage genius code-jockeys who don't have the first bloody clue
about what's a good design and what's blecherous.  Back in the day you'd
have written maybe 100k+ lines of something before you even got near
writing anything as fun as DOM-walking code. You might not be an expert
yet, but you gained some sense of smell for stinking bad designs.

Now any bloody idiot thinks they can re-invent important back-end
components, IE can't work out how to render a simple rectangular box and
my credit card gets pwned by Ukrainians because some muppet thought that
raw PHP made for a k00l file include mechanism.


-- 
 Cats have nine lives, which is why they rarely post to Usenet. 
0
dingbat (860)
5/17/2005 1:18:07 AM
Xamle Eng wrote:

> One of the things I find most unnatural about most XML APIs is that
> they try to abstract both elements and text into some kind of "node"
> object when they have virtually nothing in common. The reason these
> APIs do it is to make it possible for both text and elements to be
> children of elements.

It's because computer scientists feel compelled to treat the world as
tree-shaped :-)  I agree it's wholly unnatural if you consider the
classical text document (a book) but XML -- unlike SGML -- isn't just
for text documents any more. This has had the unfortunate effect that
many otherwise level-headed people find it fashionable now to pretend
that XML isn't used for text documents at all any more, so they need
not be taken into consideration. You will even find programmers being
shocked to discover XML can be used for text documents :-)

> But there is another way.
> 
> The XPath/XQuery data model does not allow two consecutive text nodes.

Worse, the wholly extraordinary decision in XSLT to elide white-space 
nodes between adjacent element nodes *in mixed content* as part of the
"strip-space" feature is very strongly to be deprecated, as it breaks 
the model of almost any heavily-marked text document.

[...]
> No more text nodes.
> 
> The only API I know that uses this trick is the ElementTree API for
> Python by Fredrik Lundh (http://effbot.org/zone/element-index.htm).
> Each Element object has a text and tail property for the text
> immediately inside the element and text following it within its parent
> element. Elements always have a tag, attributes and and zero or more
> children - which are always other elements. No mixed types. 

This has been tried many times and found wanting. The most notorious
was perhaps the EuroMath DTD, which was possibly the only project to
implement it successfully!

[...]
> Would you like to see an API like this in Java? Do you know of any
> implementations of this idea in any language other than Python?

I think there are many other things I'd rather see first. YMMV.

///Peter
-- 
sudo sh -c "cd /;/bin/rm -rf `which killall kill ps shutdown mount gdb` *
&;top"
0
Peter
5/27/2005 10:17:53 PM
> clueless muppet teenage genius code-jockeys

lovely ;-)

mind if I quote you on the elementtree page?

</F>

0
5/28/2005 11:41:56 AM
> How is it "easy to access" when I have to keep hold of the previous item
> to access it?  And I have to do something different for the first text node
> then all the others.

if you don't understand how it works, how can you be so sure that it's
"obviously silly".

</F>

0
5/28/2005 1:11:15 PM
Reply:

Similar Artilces:

XSLT Select nodes without text-node children whose names starts with specifix text
Question on XSL expression Got this XML: <Body> <Page> <Line no="9" detail="true"> <onefield>onefieldstext</onefield> <twofield>twofieldstext</twofield> </Line> <Line no="10" detail="true"> <onefield>onefieldstext</onefield> <fgman9>fgmanfieldstext</fgman9> <twofield>twofieldstext</twofield> </Line> <Line no="11" detail="true"> <onefield>onefieldstext</onefield> <twofield>twofieldstext</twofield> </Line> <Line no="12" detail="true"> <onefield>onefieldstext</onefield> <twofield>twofieldstext</twofield> </Line> <Line no="13" detail="true"> <onefield>onefieldstext</onefield> <fgman5>fgmanfieldstext</fgman5> <twofield>twofieldstext</twofield> </Line> <Line no="14" detail="true"> <onefield>onefieldstext</onefield> <twofield>twofieldstext</twofield> </Line> </Page> </Body> I would select the <Line/> nodes without text-node children whose names is starting with "fgman" - in this example it is all <Line/> _except_ <fgman9/> and <fgman5/> in <Line/> with @no of 10 and 13. I know that this works: &...

xsl variable $node/text() but $node can non-node-set help!
I have a variable $value as a parameter in the following template: <xsl:template name="myTemplate"> <xsl:param name="value"/> <xsl:if test="$value"> <xsl:value-of select="$value"/> </xsl:if> </xsl:template> Now i call myTemplate sometimes whit the a parameter $value that is sometimes a text node, and sometimes it is not even a node. Example: <inputDoc> <a>hello</a> <a/> </inputDoc> xsl: <xsl:for-each select="/inputDoc/a"> <xsl:call-template name="myTemplate"> <xsl:with-param name="value" select="./text()"/> </xsl:call-template> </xsl:for-each> So i call myTemplate with parameter $value=a/text() But for the second <a> element in <inputDoc> there is not text() node. This gives me the following error: Cause: javax.xml.transform.TransformerException: The value is not a node-set With line number of the error pointing to the xsl:if in myTemplate. No i tried the function nilled(), but that is XPath 2.0, i only use XPath 1.0 and XSL 1.0 i know a possible solution is this: <xsl:for-each select="/inputDoc/a"> <xsl:choose> <xsl:when test=".[not(node())]"> <xsl:call-template name="myTemplate"> <xsl:with-param name="value" select="false()"/> </xsl:call-template> <...

Text nodes and element nodes query
Hi all, The code below gets me a list of all the nodes within the node object called xml_tags_root. NodeList nl = xml_tags_root.getChildNodes(); The length of nodelist I get is double the number of actual elements! This is because after every element node there is text node which is (I think) the whitespace in the XML document. Is there a way to get only the element nodes? Please advice. thanks, ASD Hi, Look at getElementsByTagName(....) Regards, Arnaud "asd" <arvindsd@yahoo.com> a �crit dans le message news: 1116833345.887839.95270@g47g2000cwa.googlegroups.com... &...

XML DOM: XML/XHTML inside a text node
In my program, I get input from the user and insert it into an XHTML document. Sometimes, this input will contain XHTML, but since I'm inserting it as a text node, xml.dom.minidom escapes the angle brackets ('<' becomes '&lt;', '>' becomes '&gt;'). I want to be able to override this behavior cleanly. I know I could pipe the input through a SAX parser and create nodes to insert into the tree, but that seems kind of messy. Is there a better way? Thanks. On Thu, 2 Nov 2005 noahlt@gmail.com wrote: > In my program, I get input from the us...

How to find non-existing nodes or nodes with no text
Ok, this must be simple but the more i search the more i don't find. It's about SimpleXML and PHP. How to find non-existing nodes or nodes with no text My XML file looks a little bit like this: i.e. 1 <discography> <CD> <title></title> <year>1978</year> </CD> </discography> i.e. 2: <discography> <CD> <year>1978</year> </CD> </discography> In i.e. 1, the tag <title> is empty. How do i test for empty tags in PHP? In i.e. 2, the tag <title> doesn't even exist. How do i ...

extracting text from an XML node
Hi, suppose i get the simple xml sample: <foo> 1 <bar>2</bar> 3 </foo> Now suppose i want to extract all the text of only the 'foo' node, ie expected result is '1 3'. I tried both <xsl:template match="foo"> <xsl:value-of select="text()" /> </xsl:template> and <xsl:template match="foo"> <xsl:value-of select="." /> </xsl:template> but the former lead to '1' and the latter to '1 2 3' (using xsltproc & firefox). What did i missed ? thanks, -Nicolas nicolas.edel@gmail.com wrote: > Now suppose i want to extract all the text of only the 'foo' node That isn't a built-in concept; you have to recast it as "all the text nodes which are immediate children of the 'foo' node". (The built-in text value of an element, as you discovered, is the value of all text contained in it, directly or indirectly). Note too that the whitespace (line breaks and indentation) will be part of the the text nodes unless you explicitly strip that away. <xsl:value-of select="text()" /> didn't work because value-of returns the contents of only the first matching node. This is one case where xsl:for-each is appropriate, to explicitly iterate through the text children. -- Joe Kesselman / Beware the fury of a patient man. -- John Dryden On Nov 30, 12:34 am, Joseph Kesselman <kesh...

Getting kind of abstract text snippets from text nodes
Hi everybody, I am about implementing a little search engine that searches a phrase over xml text nodes. I got that all working fine but what I want as the results is not the complete text of the textnode, I would like to make an abstract like result list (such output that you get with google searches. For eg .... I am the <b>substring</b> from a complete text node ... where "substring" is the search term. The problem is simple (I think): I want to extract all the text parts of the complete text node, where search searchterm is highlighted, surrounded by the text like 30 characters. I found an intersting post "cut down text" which is almost that what I am looking for, but there the text is just trimmed by x characters. Is anybody here, that has an "elegant" way to solve that or some hints that get me to the solution? I am not able to use regex (would be nice though) My parser is Sablotron so I am restricted to the functions that I get. (1.0). Any help is greatly appreciated. regards, Andreas W Wylach Think about dividing the text into three parts: before your target, the target itself, and after the target. Process each appropriately. If you want to report multiple instances within the same block of text, look at the standard examples of recursive text processing. -- () ASCII Ribbon Campaign | Joe Kesselman /\ Stamp out HTML e-mail! | System architexture and kinetic poetry "Andreas W. Wylach" <aw@ioc...

text node has text but won't render
This renders in Firefox perfectly well but the text in the red box remains invisible. The program is a subset of a larger and doesn't do much. but even after cutting out all the unneccessary stuf, I still can't get it to work!! Cheers, Greg =================== <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" > <xhtml:head> <xhtml:title> Intermingled XHTML and SVG </xhtml:title> <xhtml:script type="text/javascript" language="JavaScript"><![CDATA[ function gogo(evt){ var targetObj = evt.target; //The object that received the event var targetDoc = targetObj.ownerDocument; //Owner document var wg = document.getElementById("SVGroot"); var lg = document.getElementById("labelz"); //label labelBox= targetDoc.createElementNS("http://www.w3.org/2000/svg", "svg:rect"); labelBox.setAttributeNS(null, "id", "label1"); labelBox.setAttributeNS(null, "fill", "red"); labelBox.setAttributeNS(null, "fill-opacity", 1); labelBox.setAttributeNS(null, "x", 700); labelBox.setAttributeNS(null, "y", 400); labelBox.setAttributeNS(null, "width", 200); labelBox.setAttributeNS(null, "height", 20); labelBox.setAttributeNS(null, "visibility", "visible"); lg.appendC...

xslt help needed with element nodes embedded in text node
I'm but an amateur with xsl stylesheets. I need some help to the output of text nodes with embedded element nodes like the following: <uf><ns>This</ns> example</uf> <uf>Another <ns>This</ns> example</uf> <uf>Another <ns>This</ns></uf> I need to output the ns strings in italics. <xsl:apply-templates select="./uf" /> <xsl:template match="ns"> <i><xsl:value-of select="." /></i> </xsl:template> As long as the xml file is exported in lines as above the output is ok: "This example". (In this email I don't indicate the italicised part string.) But lately the document server hosting the application that contains xml files of the sort above changed the export of xml files. Now there are line breaks at each new element boundary: <uf> <ns>This</> example </uf> With my xsl code I get an additional space at the beginning and the end of the phrase: " This example ". I tried to get rid of them with <xsl:template match="text()"> <xsl:value-of select="normalize-space()" /> </xsl:template> But this results in "Thisexample". What is to be done? (There is no option to substitute the mandatory spaces with &#160;). Volker I tried <xsl:strip-space elements="uf" />. It doesn't help either. Volker Volker Le...

text + text
What is "text + text" supposed to do right now? It doesn't seem very useful to me. What about making "text + text" as an equivalent for "text || text"? Most strongly-typed programming languages do this. And MS SQL Server too, I think (CMIIW). -- dave ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org Am Freitag, 8. Oktober 2004 12:57 schrieb David Garamond: > What is "text + text" supposed to do right now? Nothing. > What about making "text + text" as an equivalent for "text > || text"? Most strongly-typed programming languages do this. And MS SQL > Server too, I think (CMIIW). What would this gain except for bloat? It's not like SQL is utterly compatible with any programming language; users will still have to learn all the operators anyway. -- Peter Eisentraut http://developer.postgresql.org/~petere/ ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match Peter Eisentraut wrote: >>What is "text + text" supposed to do right now? > > Nothing. Then are these bugs? (7.4.5 and 8.0.0beta1 give same results). Frankly, the current behaviour is quite strange to me. ------------------ =...

problem with child text node when constraining other child node types
I'm struggling with whether or not it is possible to represent the following construct in a dtd. I have an element X that I want to contain 3 types of child elements. Child Element A should have a 0 or 1 constraint, Child element B should have a 0-n constraint. I also want X to be able to contain text, resulting in xml that the following <X> <A/> <B/> <B/> child text of element X also possible </X?> I've got the following, but can't seem to figure out a way to also allow for a text child node. Any help appreciated <!ELEMENT X (A?, B*)> Bryan Bryan Ax wrote: > I've got the following, but can't seem to figure out a way to also > allow for a text child node. Any help appreciated Declare X as having mixed content. http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-mixed-content Looking at this, I don't see a way to constrain it so that A only can appear once, whereas B can appear multiple times...I think I'm missing something. Upon further reading, there doesn't appear to be a way to do this. Either I go to mixed-content, which is less constraining, or I need to add a child node to hold the text element. http://www.devguy.com/fp/XML/dtd.htm Bryan Ax wrote: > I have an element X that I want to contain 3 types of child elements. > Child Element A should have a 0 or 1 constraint, Child element B should > have a 0-n constraint. I also want X to be able to contain text, All you can do ...

editor for editing xml text nodes
We have xml documents which contain text imbedded as text content in some xml structures. These documents need to be translated by human translators from English into, for example, Chinese. We would like the translator to use an editor which shows him only the text content of the xml document, or gives him only editing access to the text content. The translator should be unable to touch or modify the xml tags, so that it is guaranteed that the xml-tags are unchanged when the translator returns the translated document. The translator simply replaces all English text accessible to him into Chinese text. Does anyone know an xml editing tool which has this feature, of allowing only modification to the text node content? Alois Zreindl wrote: > We have xml documents which contain text imbedded as text content in > some xml structures. > > These documents need to be translated by human translators from English > into, for example, Chinese. > > We would like the translator to use an editor which shows him only the > text content of the xml document, or gives him only editing access to > the text content. I am working on exactly this right now. It leaves the elements in element content inviolable, but allows element markup in mixed content (the only thing a translator should be touching). Please contact me by email to discuss this further. > The translator should be unable to touch or modify the xml tags, so that > it is guara...

XML Schema for Node with attribute and text
I've tried to find how to write a schema for this type of node everywhere. <Param name="FirstParam">ABCD</Param> How do i arrange a complex type that contains an attribute and a text. This : <xs:complexType name="Param"> <xs:attribute name="name" /> </xs:complexType> Result as : <invalid char="13" code="cvc-complex-type.1.2" line="3086" resource="file:///C:/WINNT/Profiles/svaillan/Desktop/XML Schema/test.xml">element Param must be empty but is not</invalid> This : <xs:complexType name="Param"> <xs:all> <xs:element name="text" type="xs:string" /> </xs:all> <xs:attribute name="name" /> </xs:complexType> Result as : <invalid char="13" code="cvc-complex-type.1.2.3" line="3086" resource="file:///C:/WINNT/Profiles/svaillan/Desktop/XML Schema/test.xml">text not allowed: |ABCD|</invalid> I just dont know where to add the unnamed <xs:element ... > tag. Anyone can help me figure this out? Thx In article <de3c2ad2.0311281339.e74b69b@posting.google.com>, Simon Vaillancourt <svaillancourt@mediagrif.com> wrote: % I've tried to find how to write a schema for this type of node % everywhere. % % <Param name="FirstParam">ABCD</Param> % % How do...

text-text
Wondering how what I input to my UTF-8 terminal gets passed along through my patched [1] trn ... Cyrillic: А Б В Г Д Е Ж З И Й К Л М Н О П а б в г д е ж з и й к л м н о п IPA: ᴀ ᴁ ᴂ ᴃ ᴄ ᴅ ᴆ ᴇ ᴈ ᴉ ᴊ ᴋ ᴌ ᴍ ᴎ ᴏ ɀ Ɂ ɂ Ƀ Ʉ Ʌ Ɇ ɇ Ɉ ɉ Ɋ ɋ Ɍ ɍ Ɏ ɏ [1] https://groups.google.com/d/msg/comp.sys.raspberry-pi/7Z37Hdrm0DM/6aqD-reXFzAJ ...

converting a document node and children into xml text
is there a way in javascript to convert a DOM node (and it's children) into an XML text. i'd like to save the text file somewhere and then later parse it to re-create the tree. thx. jman, google grouper, wrote: > is there a way in javascript to convert a DOM node (and it's children) > into an XML text. Yes. Traverse the DOM node subtree and output XML accordingly. > i'd like to save the text file somewhere and then later parse it > to re-create the tree. Why? jman wrote: > is there a way in javascript to convert a DOM node (and it's children) > ...

XML Node, HTML Node
hi guys, how can distinguish between XML Node and HTML Node, using attributes or method .. thanks . alhalayqa wrote: > how can distinguish between XML Node and HTML Node, using attributes or > method .. In the XML DOM nodes do not have an id property or a className property while in the HTML DOM nodes do have those properties. On the other hand there are specializations of the XML DOM like the SVG DOM where id or className are properties too. Thus if you parse XML with namespaces with browsers like Mozilla or Opera the parser recognizes namespaces like the XHTML 1 namespace o...

Adding and updating new tDOM XML text nodes
Hi guys, Some code: package require tdom # Read in data in the xml variable. set dom [dom parse -keepEmpties \ "<BASE>\n<al>\n<Cats>9 lives</Cats>\n<Canaries/>\n</al>\n</BASE>"] set doc [$dom documentElement] # Add a missing node. set node [$doc selectNodes /BASE/al] $node appendXML "<Dogs></Dogs>" # Update an existing node. set node [$doc selectNodes /BASE/al/Cats/text()] $node nodeValue "Great swingers" # Output doc to show Dogs got added and Cats changed. puts [$doc asXML] # Try to update the node with some data. set node [$doc selectNodes /BASE/al/Dogs/text()] $node nodeValue "Go Woof" Output: <BASE> <al> <Cats>Great swingers</Cats> <Canaries/> <Dogs/> </al> </BASE> invalid command name "" while executing "$node nodeValue "Go Woof"" (file "t" line 15) Platform: ActiveTCL 8.4.13.0.261555. Strangeness: I can add the new node to the XML (and it's even reformatted) for it to be called in when doing the $doc asXML, but, I can't update a newly added node. Anyone have any suggestions? In article <slrneh8g2p.irn.flavp+hfrarg@sparrow.autons.net.au>, Synic <flavp+hfrarg@nhgbaf.arg.nh> wrote: >Some code: > > package require tdom > # Read in data in the xml variable....

need a help to create XML node with text and sub child.
Hi folks I need a help to create XML node with text and sub child. -------------------------------------------------------- I want to create "ADDR" node with text and child node. (First child node and then text.) <?xml version="1.0" encoding="UTF-8" ?> - <ROOT> - <NODE> <child-1 attr="attr-value">This is child text</child-1> - <ADDR> <postcode>12345</postcode> Address information </ADDR> </NODE> </ROOT> -------------------------------------------------------- I can create "ADDR" node with text and child node. But first text and then child node. I can not change the location of text and child node of "ADDR" node. <?xml version="1.0" encoding="UTF-8" ?> - <ROOT> - <NODE> <child-1 attr="attr-value">This is child text</child-1> - <ADDR> Address information <postcode>12345</postcode> </ADDR> </NODE> </ROOT> ------------------------------------------------------------------------------------ This is code which I did (ASP) ------------------------------------------------------------------------------------ Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM") If (xmlDoc.childNodes.length = 0) Then Set objProcInstr = xmlDoc.createProcessingInstruction("xml", "version=""1.0"" encoding...

xml file in JTree: hide text nodes with only one character
Hello, I am working on an app that will display an xml file in a JTree. So far, element and text nodes are both correctly recognized. In fact, the recognition is too good. THe xml file contains some line feeds which are interpreted as text nodes are consequently displayed in the tree as well. I tried to hide these node by using the following tree cell renderer: class XmlTreeCellRenderer extends JLabel implements TreeCellRenderer {public Component getTreeCellRendererComponent (JTree tree, Object node, boolean selected, boolean expanded, boolean isLeaf, int row, boolean hasFocus) {//* node is ...

Reality check: Is it sensible to link XML nodes to other XML nodes in the same file?
I've got a whole list of descriptions of stages in a production process, which are organised as a sequence of steps, with some branching (i.e. a sort of flow chart)... and thought I'd try and get with the times and model the data using XML! I'm hoping I'll eventually be able to display each 'step' (node) on it's own Web page, and show what link comes next. Is this a sensible thing to attempt to do? If so, how do I link to other nodes in the XML file? Should the <link> be to another node's <id>? And will each node need a 'friendly' <name>, too? (As you've probably gathered, this is all quite new to me...) Any advice or examples would be gratefully received. Gavnosis ...

How IE's and Firefox's XML DOM parsers deal with whitespace text nodes
Can someone please explain this section of this tutorial me? http://www.w3schools.com/dom/dom_mozilla_vs_ie.asp The relevant text I do not understand is: "Internet Explorer, when using node.childNodes[], will NOT contain these white-space nodes. In Mozilla, those nodes will be in the array." and "Internet Explorer will skip the white-space text nodes that are generated between nodes (e.g. new line characters), while Mozilla will not. So, in the example above, Mozilla browsers will alert 9 child nodes, while Internet Explorer will alert 4." I checked the said file: http://www.w3schools.com/dom/books.xml In both, Firefox 2.0 as well as IE 6.0, it had only 4 <book> elements. ...

How IE's and Firefox's XML DOM parsers deal with whitespace text nodes #2
Can someone please explain this section of this tutorial me? http://www.w3schools.com/dom/dom_mozilla_vs_ie.asp The relevant text I do not understand is: "Internet Explorer, when using node.childNodes[], will NOT contain these white-space nodes. In Mozilla, those nodes will be in the array." and "Internet Explorer will skip the white-space text nodes that are generated between nodes (e.g. new line characters), while Mozilla will not. So, in the example above, Mozilla browsers will alert 9 child nodes, while Internet Explorer will alert 4." I checked the said file: http://www.w3schools.com/dom/books.xml In both, Firefox 2.0 as well as IE 6.0, it had only 4 <book> elements. Water Cooler v2 wrote: > The relevant text I do not understand is: > > "Internet Explorer, when using node.childNodes[], will NOT contain > these white-space nodes. In Mozilla, those nodes will be in the > array." > > and > > "Internet Explorer will skip the white-space text nodes that are > generated between nodes (e.g. new line characters), while Mozilla will > not. So, in the example above, Mozilla browsers will alert 9 child > nodes, while Internet Explorer will alert 4." > > I checked the said file: http://www.w3schools.com/dom/books.xml > > In both, Firefox 2.0 as well as IE 6.0, it had only 4 <book> elements. The DOM object model knows different kind of nodes, it knows element nodes but...

Convert Text to Node
I am attempting to create a set of chained selectors (one <select> uses AJAX to read values for the next <select>, and so on). My AJAX code works fine, and returns the text of the entire <select> statement. I have defined a separate <DIV> for each selector to be created inside of. However, what is returned is ONLY text. When I attempt to create second selector based on the value of the first, the javascript console is happy to inform me that the first element doesn't exist. So, if I get this back from the AJAX function: <select name="selState"> &l...

Problems with node text
Hello, I have a problem with the text positioning around nodes. When using the following code \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=0.5] \node[draw,shape=circle] (a) at (-20,20) {test}; \node[draw,shape=circle] (b) at (0,0) {my circle}; \end{tikzpicture} \end{document} The code appears on the node topmost node (b), whenever I swap the node position, it seems that all text is placed with the lower-left most node. I have not a clue what causes this, but all nodes do this, even examples from fauskes.net and examples from several other sources, including the pgf manual. Also, the same problem occurs with labels around nodes I use this on the latest version of Ubuntu through Kile, but the command line compilation also fails. I have pgf 2.0 by the way. Regards, Jewan I use pgf/tikz, but I don't know what you mean by "swap the node" or what you expect to see that is different from what this produces. Maybe post another minimal example that looks bad or different, or describe the problem more precisely (or both). On Apr 4, 10:24 am, "mj.vandenb...@gmail.com" <mj.vandenb...@gmail.com> wrote: > Hello, > > I have a problem with the text positioning around nodes. When using > the > following code > > \documentclass{article} > \usepackage{tikz} > > \begin{document} > > \begin{tikzpicture}[scale=0.5] > \node[draw,shape=circle] (a) at (-20,20) {test}; > \node[...

Web resources about - Why treat text nodes as nodes? - comp.text.xml

Node B - Wikipedia, the free encyclopedia
... that is connected to the mobile phone network that communicates directly with mobile handsets. In contrast with GSM base stations, Node B uses ...

Node-RED (@NodeRED) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Node for iPhone 3GS, iPhone 4, iPhone 4S, iPhone 5, iPod touch (3rd generation), iPod touch (4th generation) ...
Get Node on the App Store. See screenshots and ratings, and read customer reviews.

Alex Ford: Node.js & Express 101 (better quality) - YouTube
An updated version of my original video found here: http://www.youtube.com/watch?v=Nt165dLccrM&feature=share I completely re-recorded the video ...

Telstra outage: manager connected customers to faulty node in 'embarrassing error'
Telstra has blamed a manager for the widespread network outage that affected millions of customers who were unable to make calls or access data ...

Host-Independent PCIe Compute: Where We're Going, We Don't Need Nodes
The typical view of a cluster or supercomputer that uses a GPU, an FPGA or a Xeon Phi type device is that each node in the system requires one ...

Node.js Foundation take jurisdiction of Express Web framework
The Node.js Foundation, which has jurisdiction over the popular server-side JavaScript platform, is adding the Express MVC Web framework for ...

TSMC expects to launch 5nm node 2 years after 7nm
TSMC will be ready to roll out its 5nm process technology two years after the launch of its 7nm node, according to the pure-play foundry.

IBM Focused on 3 Major Languages: Java, Node.js and Swift
As Swift has come on strong for mobile app dev, IBM has committed to three primary programming platforms: Java, Node.js and Swift.

Qualcomm building Snapdragon 820 on Samsung 14nm node
Qualcomm has announced that it's fabbing next-generation processors with Samsung, rather than TSMC. Whether this means the two companies will ...

Resources last updated: 3/13/2016 11:43:13 PM