XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
How can the content of a leaf element be multiple text nodes?

Hi Folks,

Okay, I'm confused.

I thought that a leaf element can have either zero or one text node. 

Apparently a leaf element can have 0, 1, 2, 3, 4, 5, 6, ... text nodes! 

For example, how many text nodes does this leaf element have?

<Test>abc<!-- blah -->def</Test>

Answer: It has two text nodes: 

	text()[1] and text()[2]

How do I know this? Well, I executed this XPath:

	Test/text()[1]

which resulted in this output:

	abc

and this XPath:

	Test/text()[2]

resulted in this output:

	def
 
To confirm that there are indeed two text nodes within the <Test> element, I used XPath to count the number of text nodes:

	count(Test/text())

That produced this output:

	2

In fact, the text node containing "def" *follows* the text node containing "abc", as this XPath shows:

	Test/text()[1]/following::text()

That gave this output:

	def

Interesting!

But the really interesting thing is that if I create an XPath to answer this question: What is the text in the <Test> element?

	Test/text()

Shockingly, I get this output:

	abcdef

Huh???

The previous tests determined that there are two separate text nodes, so how can there now be only one text node?

I am confused.

/Roger
	




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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS