XML Node, HTML Node
how can distinguish between XML Node and HTML Node, using attributes or
> 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...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 Pyt...xsl variable $node/text() but $node can non-node-set help!
I have a variable $value as a parameter in the following 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.
<xsl:with-param name="value" select="./text()"/>
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
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:with-param name="value" select="false()"/>
<...Text nodes and element nodes query
The code below gets me a list of all the nodes within the node object
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?
Look at getElementsByTagName(....)
"asd" <email@example.com> a �crit dans le message news:
&...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 '<', '>' becomes '>'). 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?
On Thu, 2 Nov 2005 firstname.lastname@example.org wrote:
> In my program, I get input from the us...XSLT Select nodes without text-node children whose names starts with specifix text
Question on XSL expression
Got this XML:
<Line no="9" detail="true">
<Line no="10" detail="true">
<Line no="11" detail="true">
<Line no="12" detail="true">
<Line no="13" detail="true">
<Line no="14" detail="true">
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:
&...Get XML values from nodes and child nodes
Hi everybody. My XML file is:
I need to get in ONE RECORD, both node value and his child nodes values, like this
001 | CSTNDA69P90H523R | CAST | NADIR | F | 10091979 | RONCA | BL
002 | PRSGRI74L29F443L | PERISSI | IGOR | M | 29071970 | MONTE | SA
X.valore.query('NumeroProgressivo').value('.', 'VARCHAR(20)') as NumeroProgressivo,
X.valore.query('CodiceFiscale').value('.', 'VARCHAR(16)') as CodiceFiscale
CROSS APPLY Tbulk.nodes('Fornitura/Documento/S...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:
In i.e. 1, the tag <title> is empty. How do i test for empty tags in
In i.e. 2, the tag <title> doesn't even exist. How do i ...select nodes with child node A and child node B
I have an XML document that has multiple childe nodes like the one at
the end of this message
What syntax would I use with selectNodes to select all viewentry nodes
that have an
entrydata child node with a name attribute equal to
that has a text childe node with the text Course ABC
AND that also have an
entrydata child with a name attribute equal to Start Date
that has a datetime child node with the text 20070110
I was trying something like
ABC']) and (entrydata[@name='StartDate'][datetime='20070110'])]"
<viewentry position="1" unid="E5FE575692CAB4CD852572140052F751"
<entrydata columnnumber="0" name="CourseOrMeetingName">
<entrydata columnnumber="1" name="StartDate">
<entrydata columnnumber="2" name="City">
<entrydata columnnumber="3" name="FirstName">
<entrydata columnnumber="4" name="MiddleName">
<entrydata columnnumber="5" name="LastName">
<text>...Getting all nodes and node details from xml using xquery
I haev the following code:
DECLARE @x xml
<row id="1"><name>Larry</name><oflw>some text</oflw></row>
<row id="3" />
exec sp_xml_preparedocument @idoc OUTPUT, @x
SELECT * FROM OPENXML(@idoc, '/Root')
This gives the following details
pr...selecting nodes between other nodes
I want to select everything between <foo> and <a>. Is this possible?
In article <2jbjjhFvf4ttU1@uni-berlin.de>,
Timo Nentwig <email@example.com> wrote:
% <blah />
% <blah2 />
% <b />
% <c />
% I want to select everything between <foo> and <a>. Is this possible?
<xsl:stylesheet xmlns:xsl = 'http://www.w3.org/1999/XSL/Transform'
version = '1.0'>
<xsl:template match='*[preceding-sibling::foo and following-sibling::a]'>
<xsl:copy-of select = '.'/>
Patrick TJ McPhee
East York Canada
...extracting text from an XML node
suppose i get the simple xml sample:
Now suppose i want to extract all the text of only the 'foo' node, ie
expected result is '1 3'.
I tried both
<xsl:value-of select="text()" />
<xsl:value-of select="." />
but the former lead to '1' and the latter to '1 2 3' (using xsltproc &
What did i missed ?
> 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...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>Another <ns>This</ns> example</uf>
I need to output the ns strings in italics.
<xsl:apply-templates select="./uf" />
<i><xsl:value-of select="." /></i>
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:
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:value-of select="normalize-space()" />
But this results in "Thisexample".
What is to be done? (There is no option to substitute the mandatory
spaces with  ).
I tried <xsl:strip-space elements="uf" />.
It doesn't help either.
Volker Le...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
child text of element X also possible
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 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.
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
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.
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 ...node-node adjacency matrix to a node-arc adjacency matrix
I have been trying to figure out how to create a arc-node adjacency matrix from a node-node adjacency matrix, for example:
A = [0 1 0 1 1;
0 0 1 1 0;
0 0 0 1 1;
0 0 0 0 1;
0 0 0 0 0];
looking for the following links: 1-2,1-4,1-5,2-3,2-4,3-4,3-5,4-5
B =[ 1 1 1 0 0 0 0 0
-1 0 0 1 1 0 0 0
0 0 0 -1 0 1 1 0
0 -1 0 0 -1 -1 0 1
0 0 -1 0 0 0 -1 -1];
Any help will be greatly appreciated:
I have tried to develop a for loop using "A" and assigning -1 to the tail end of the link but with no succes...inserting and deleting valid xml nodes
I program an xml editor with xerces for the university of
Braunschweig, the user
dont see any xml tags, it is represented in a JTree.
Now the user shall be able to insert nodes, which
conforms to the schema file (the user need not know what
that is, its transparent to him). I found two approaches for doing
1. When xerces validates the source or the DOM tree (this is a new
and is faster since the tree structure is already there, by
it builds up for each node a vector holding all possible allowed
schema types, and
then just looks if that node's type is in that vector. I could
store that vector for my own purposes and let the user choose, what
node he wants to insert, according to the vector.
There are some difficulties in that: First, its hard to get that
there are not-public methods building it up and using it, its very
Second, DOMNormalizer only accepts the document root as input, and not
node, but I dont want to run the DOMNormalizer after each little
modification on the
whole file, this would take to much time at a large file and a quick
user. Surely with some "hacking" (that means, with modification of
xerces source files) I could do it on child nodes somehow, but this is
even more complicated. Moreover, if I insert a node, I would have to
if the following sibling nodes are allowed at there new by-one-shifted
positions. This is needed especially at the deletion of a node in
backwar...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
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..."node.InsertAfter" method only inserts node on final call
I succesfully return a "nodeList" thru the "xmlDoc.SelectNodes" method.
This nodeList is taken from a repetitive, uniform xml doc.
I can successfully append a child node at the correct position using the
<!--Node inserted into corrrect position in nodeList(0)-->
however, as soon as I try to do the same with nodeList(1), then
apparently the SAME code that previously inserted the node into
nodeList(0) doesn't do its job.
<!--Node NOT inserted into nodeList(0)-->
<!--Node inserted into corrrect position in nodeList(1)-->
Surely, If i am using the "InsertAfter" method, then the node should
have been inserted BOTH times?
As a test, I swapped my code round, and I can confirm that the node is
ONLY inserted on the 2nd call.
<!--Node NOT inserted into nodeList(1)-->
<!--Node inserted into corrrect position in nodeList(0)-->
Can someone comment?I have been spent a bit of time on this, and am no
Even if i could get hold of some sample code in vb / c# that did ...converting a document node and children into xml text
into an XML text.
i'd like to save the text file somewhere and then later parse it
to re-create the tree.
jman, google grouper, wrote:
> into an XML text.
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.
> ...Firefox inserts text nodes in TR elements?
Why does Firefox insert #text nodes as children of TR elements?
As a work-around for older Safari versions not properly supporting a
table row's cells collection, I used the row's childNodes collection as
it was pretty much exactly the same thing. However, in Firefox 1.0.7
text nodes are inserted between the TDs. I'm certain that this didn't
use to happen with older versions.
The HTML specification states that the only element that can be the
child of a TR is a TD, so why does Firefox put text nodes in there?
If this how the DOM is supposed to be built, can someone g...Help needed with XML Node insert API
I have to add elements to an existing XML Document which conforms to a
Is there an some API which throws an exception when I append a node to
this document if it is not a valid location or element based on the
My DTD is very specific on sequence of elements.
Since I have to insert many elements it is not an option for me to
insert all elements and at the end run validate on the document.
> I have to add elements to an existing XML Document which conforms to a
> Is there an some API which throws an exception when I append...ORA-31167: XML nodes over 64K in size cannot be inserted
I have a table with a XmlType-column with CLOB storage.
I can insert and read xml-data containing base64 encoded JPEGs with
OCILob functions. The image data contains > 64K.
The problem: a query like 'select extract(xmldata, '/img/@name') ...'
executed in sqlplus or SqlDeveloper gives the error
ORA-31167: XML nodes over 64K in size cannot be inserted
Cause: An attempt was made to insert an XML Text Node with a size
greater than 64K. This is not supported.
Action: Create text nodes under 64K.
But the data is already in the db. I only want to read some piece ( ~20
b...Adding and updating new tDOM XML text nodes
package require tdom
# Read in data in the xml variable.
set dom [dom parse -keepEmpties \
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"
invalid command name ""
"$node nodeValue "Go Woof""
(file "t" line 15)
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
Anyone have any suggestions?
In article <firstname.lastname@example.org>,
Synic <email@example.com> wrote:
> package require tdom
> # Read in data in the xml variable....Looking A Nodes From Within Nodes
I've written a template that does some work on a subtree, but I want to
replace the subtree that I originally worked on. How would I do this?
Confused, Okay, here's an example:
This is a binary tree full of "node" tags. Let's let I was working on
the subtree starting at the node tag I've indicated by the **s. Let's
say I've done my work on the subtree and I want to replace the subtree
in this master tree with the one I've just changed. I also want to
change the top level node tag (for example, updating the attribute tag).
I can't do something like
Because, while it will work in this case, I don't know in advance how
many levels the tree will have.
Can anyone help me out here? :)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Ack! Sorry, I phrased the problem incorrectly. When I said "top level
node tag", I meant to indicate the parent of the root of the subtree.
So, in t...