f



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
0
2/22/2012 5:56:38 PM
comp.text.xml 8781 articles. 0 followers. Post Follow

4 Replies
582 Views

Similar Articles

[PageSpeed] 55

I tried <xsl:strip-space elements="uf" />.

It doesn't help either.

Volker
0
2/23/2012 7:05:48 AM
Volker Lenhardt <volker.lenhardt@uni-duisburg-essen.de> writes:

> 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:

Sorry to be pedantic, but there is no such thing as a "text node with
embedded element nodes". In your example:

> <uf><ns>This</ns> example</uf>

You have an element (uf) containing two nodes: an element (ns) and a
text node.

> <xsl:apply-templates select="./uf" />
>
> <xsl:template match="ns">
>     <i><xsl:value-of select="." /></i>
> </xsl:template>

Looks ok. Except that I would not advise to use default templates (on uf).

> <uf>
>   <ns>This</>
>   example
> </uf>

The uf element contains a text node, an element, and a second text node.

> With my xsl code I get an additional space at the beginning and the
> end of the phrase: " This example ".

It should be "[EOL][SPC][SPC]<i>This</i>[EOL][SPC][SPC]". These spaces
are in the original document, and there is no way to guess that they are
not significant, especially since element uf has mixed content.

> 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".

That's expected, your template applies to all text nodes.

What you want is to remove spaces 1) at the beginning of the first child
of uf if it is a text node, and 2) at the end of the last child of uf if
it is a text node. Something like (untested):

<xsl:template match="uf">
    <xsl:apply-templates select="*|text()">
      <xsl:with-param name="p" select="position()"/>
    </xsl:apply-templates>
</xsl:template>

and, in the template on text(), check whether you need to remove
something.

But really, you should fix the thing producing the document.

-- Alain.
0
alain14 (278)
2/23/2012 7:38:49 AM
Am 23.02.2012 08:38, schrieb Alain Ketterlin:
>
> Sorry to be pedantic, but there is no such thing as a "text node with
> embedded element nodes". In your example:
>
>> <uf><ns>This</ns>  example</uf>
>
> You have an element (uf) containing two nodes: an element (ns) and a
> text node.

OK. I understand.

> What you want is to remove spaces 1) at the beginning of the first child
> of uf if it is a text node, and 2) at the end of the last child of uf if
> it is a text node. Something like (untested):
>
> <xsl:template match="uf">
>      <xsl:apply-templates select="*|text()">
>        <xsl:with-param name="p" select="position()"/>
>      </xsl:apply-templates>
> </xsl:template>

Thank you. This helped me to get the problem under control. I can now 
recognize the text at the first and the last position (and of course the 
ns elements). But at the moment I don't see how to only lefttrim the 
first and to only righttrim the last. Is there a function around?

> But really, you should fix the thing producing the document.

No chance. It's part of the xml schema recommended by the German 
National Library to export a bibliographical data record from a MAB 
catalog database.

Volker
0
2/23/2012 1:16:32 PM
Hi Alain,

Am 23.02.2012 14:16, schrieb Volker Lenhardt:
>
> But at the moment I don't see how to only lefttrim the
> first and to only righttrim the last. Is there a function around?

I've found some template code on the net.

Volker
0
2/23/2012 1:34:02 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>twofieldste...

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...

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... &...

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...

how to Update/insert an xml element's text----> (<element> text</element>)
hello friends, how can we update or insert into an xml Element. For example : ------------------- <?xml version="1.0"> <request> <main> <name>ISO8856</name> </main> </request> here when we run a java class file it should replace "ISO8856"with "ISO9001". Any Assistance or example. thanQ in adv. Ajay HANM wrote: > <?xml version="1.0"> > <request> > <main> > <name>ISO8856</name> > </main> > </request> > > here when we run a java class file it should replace "ISO8856"with > "ISO9001". Any Assistance or example. If you use the W3C DOM Level 3 Core as implemented in Java 1.5 and later then you can select the 'name' element and set its textContent e.g. Element name = (Element)xmlDocument.getElementsByTagName("name").item(0); name.setTextContent("ISO09001"); If you use DOM Level 2 Core (as implemente in Java 1.4) then you need to access the firstChild and set its nodeValue Element name = (Element)xmlDocument.getElementsByTagName("name").item(0); name.getFirstChild().setNodeValue("ISO09001"); -- Martin Honnen http://JavaScript.FAQTs.com/ Many good tutorials/articles exist on the web (and some bad ones, alas). I usually point people to http://www.ibm.com/xml -- Joe K...

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...

Query on text and element nodes
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 arvindsd@yahoo.com wrote: > 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? Well just loop through them and discard the text-nodes. > Please advice. > > thanks, > ASD > arvindsd@yahoo.com wrote: > 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? Depending on the parser and the API you are using there mig...

XSLT Delimited Text Node
Is there a way in XSLT to match on numbers that are delimited by a character or space in a text node? Mike King wrote: > Is there a way in XSLT to match on numbers that are delimited by a character > or space in a text node? XSLT 2.0 can do that nicely with the tokenize XPath 2.0 function e.g. with the input being <?xml version="1.0" encoding="UTF-8"?> <root> <data-list>1 2 3 4 5</data-list> </root> and the stylesheet <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" /> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()" /> </xsl:copy> </xsl:template> <xsl:template match="data-list"> <xsl:copy> <xsl:for-each select="tokenize(., '\s+')"> <data><xsl:value-of select="." /></data> </xsl:for-each> </xsl:copy> </xsl:template> </xsl:stylesheet> the result using Saxon 8.3 is <?xml version="1.0" encoding="UTF-8"?> <root> <data-list> <data>1</data> <data>2</data> <data>3</data> <data>4</dat...

XSLT Extract Text from Nodes
Hello, I am new to the concept of XSL and am looking for some assistance. Take the following XML document: <binder> <author>Greg</author> <notes> <time>11:45</time> <content> This would be some content... every once in a while you may run into <heading>A Heading!</heading> Which could be followed by more content... and possible <heading>More Headings.</heading> and even more content! </content> </notes> </binder> What I would like to do is to be able to extract the value of the <content> node, and have special formatting for the headings. When I do something like: <xsl:value-of select="content" /> I receive the data within <content> - including the values of the nested <heading> nodes, but what I really want to be able to do is do is to have XSLT read the text of the <content> node until a <heading> node is reached, at which point the value of the heading node is formatted correctly and displayed, and then continued by the text of the <content> node after the <heading> until another <heading> is reached... etc etc... Could someone give me some pointers as to how this can be accomplished? gregmcmullinjr@gmail.com wrote: > <content> > This would be some content... every once in a while you may run > into > <heading>A Heading!</he...

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: concatenating selected text nodes
in XSLT, if I want to concatenate _all_ the child text nodes, I can just do <xsl:value-of select="."> however, if I want to select and concatente only _some_ of the text nodes. for instance <xsl:value-of select=".//foo/text()"> this doesn't work as it just takes the first element in the node set. Is there any way of achieving this without using <xsl:for-each> to explicitly loop round them all? TIA Andy use copy-of not value-of David "David Carlisle" <davidc@nag.co.uk> wrote in message news:yg4r7ktpnzq.fsf@penguin.nag.co.uk... > > use copy-of not value-of > worked a treat - thanks david. > > David ...

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. ------------------ =...

XSLT: getting text of a node into an attribute
I have a document, lets say: <Doc> <Ele1 Att1='hello'> <Ele2 Att2='goodbye'/> </Ele1> </Doc> In XSLT I need to generate an attribute value which contains part of this document as a text string, ie: <MyOutput XML="&lt;Ele1 Att1='hello'> &lt;Ele2 Att2='goodbye'/> &lt;/Ele1>"/> I can output it easily enough at child elements (copy-of), or as a CDATA string in the element content, but I cannot find any way to get it into an attribute. What should I be doing? use &l...

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...

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 ...

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 ...

Need help with strings, read text and writing text to file...
Hi all; I have writen a program to read in a list of filenmaes and to output javascript and html code. The resulting html code is then run thru a html to js program ( Easy HTML To Any Script Converter]. All this to display the pictures in a slideshow. The code did work at one stage... before I fully tested. But now I don't know whats gone wrong. As the html and javascript look right, as does the js code. There are three slide show, each with their own buttons... However some work, while others don't! #include <stdio.h> #include <string.h> #include <stdlib.h> #define FALSE 0 #define TRUE 1 #define LINESIZE 255 int setupoutfiles(char filename[], FILE **header, FILE **body) { char tempstr[LINESIZE]="\0"; strcpy(tempstr, filename); strcat(filename, "header.htm"); *header=fopen(filename, "w+"); if(!header) return -1; strcat(tempstr, "body.htm"); *body=fopen(tempstr, "w+"); if(!body) return -1; return 0; } int setupinfile(char filename[], FILE **infile) { *infile=fopen(filename, "r+"); if(!infile) return -1; return 0; } void therest(FILE **header, char b[]) { fprintf(*header, "\n%scounter=%sImages.length-1\n", b, b); fprintf(*header, "%si=0\n\n", b); fprintf(*header, "function %sfirst()\n", b); fprintf(*header, "{\n"); fprint...

help with extracting nodes and their children as text
I'm loading an xml data file and then trying to take a particular node and add it, as html, to an element on my page using inner HTML. The xml is like what is below, with the ... representing eliminated detail: <?xml version="1.0" encoding="iso-8859-1"?> <table> <descriptions> <fielddesc id="1"> ... </fielddesc> ... </descriptions> <recordset> <record id="1"> <field id="1">1</field> <field id="2">Hydrogen</field> <field id=&qu...

Help trying to get the tagName of a Text Node
Hello, I have parsed my XML document into a Document object and now I'm running through each node. When I get to a Text Node I want to be able to grab that node's tag name (ex. <wsa:meta>text</wsa:meta> and grab the "wsa:meta"). With Element nodes it's easy. I can cast the Node as an Element and use .getTagName(). But casting a Text Node as an Element throws an exception and a similar getTagName method does not exist for Nodes. I've done a ton of research online and can't seem to find a solution. Anybody have any ideas? Thanks! In article <a138d440-4c5c-4270-9b8d-109b874c94ab@y21g2000yqn.googlegroups.com>, scoobster <ilikefatalbert@netzero.net> wrote: > Hello, > I have parsed my XML document into a Document object and now I'm > running through each node. When I get to a Text Node I want to be > able to grab that node's tag name (ex. <wsa:meta>text</wsa:meta> and > grab the "wsa:meta"). With Element nodes it's easy. I can cast the > Node as an Element and use .getTagName(). But casting a Text Node as > an Element throws an exception and a similar getTagName method does > not exist for Nodes. I've done a ton of research online and can't > seem to find a solution. Anybody have any ideas? > Thanks! The problem is that the Text Node in your scenario isn't the "wsa:meta" part at all, but rather the "text" portion. S...

XSL. howto create an element of a text node?
Hello, I have a XML file <car> <brand>Mercedes</brand> </car> I want to transform it to this form: <car> <Mercedes> </car> So in fact in XSL I want to create an element which has the name of a text node. This might be a really simple question but I am getting confused with XPath now, with {}, with // with self:: with parent:: ..... :-( <xsl:template match="car"> <xsl:element name="XXXX"/> </xsl:template> How would be the valid XXXX expression? Thanks for help Bernd blabla120@gmx.net wrote: > I want to transform it to this form: > > <car> > <Mercedes> > </car> I think you mean this (note the closure of the empty tag) <car> <Mercedes/> </car> <xsl:template match="car"> <xsl:element name="{./brand}"/> </xsl:template> I wouldn't do this though. Dynamically creating new element names is a whole can of worms and you really don't want to go there. ...

Web resources about - xslt help needed with element nodes embedded in text node - comp.text.xml

GNOME Mobile & Embedded Initiative - Wikipedia, the free encyclopedia
... about the topic. If notability cannot be established, the article is likely to be merged , redirected , or deleted . The GNOME Mobile & Embedded ...

Facebook’s New Like, Share Buttons Now Available To All Pages; Width Can Be Set On Embedded Posts
... like and share buttons it introduced last month are now available to all pages, and that page administrators can now adjust the width of embedded ...

Embedded Posts Now Available to Everyone
We introduced Embedded Posts in July to make it easy for publishers to add any public post from Facebook to their blog or web site. Today, we're ...

Facebook gives embedded posts a visual renovation
Post by ESPN . Facebook rolled out embedded posts last year , and today the company has announced a more aesthetic redesign . Now, photos and ...

Embedded.com (@embedded_com) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Embedded.com @ embedded_com ...

Rich photo experience now in embedded Tweets - Twitter Blogs
Every day, publishers and journalists all over the world share the best of Twitter with their readers by embedding Tweets in their articles. ...

Embedded Timelines - Twitter Developers
Overview Embeddable timelines make it easy to syndicate any public Twitter timeline to your website with one line of code. Just like timelines ...

Embedded Systems Design - LinkedIn
Embedded Systems Design was created specifically to meet the information needs of the senior-level developers who create complex embedded systems. ...

Can we begin to change embedded attitudes about violence against women?
How do we teach them to pause in that moment before emotion turns to action?

US driver arrested with tree embedded in car’s front grille
It's a sight that would make anyone stop and rub their eyes in disbelief: a car, driving down a busy four-lane road in Roselle, Illinois, with ...

Resources last updated: 3/13/2016 9:11:45 PM