f



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>

   </xsl:when>
   <xsl:otherwise>

    <xsl:call-template name="myTemplate">
     <xsl:with-param name="value" select="./text()"/>
    </xsl:call-template>

   </xsl:otherwise>
</xsl:for-each>


But this requires me to change every call to myTemplate,
which is alot of code. Can't i change myTemplate so
it works?

Who can help me? Please..
0
tjerk (220)
8/23/2006 12:18:06 PM
comp.text.xml 8781 articles. 0 followers. Post Follow

2 Replies
588 Views

Similar Articles

[PageSpeed] 3


Tjerk Wolterink wrote:

> 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()"/>

That means the value you pass in _is_ a node set (of text nodes) but 
that node set might be empty. I don't see why that should give you an 
error for <xsl:if test="$value">, doing that test on an empty node set 
should simply yield false.

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

What XSLT processor is that? Are you sure the code is as simple as you 
have posted? Have you tried with different XSLT processors?


-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/
0
mahotrash (2052)
8/23/2006 1:08:06 PM
There is nothing wrong with the posted code -- either the reason is in code 
that was not shown or the XSLT processor used is non-compliant.

A typical advise/requirement is to post a complete (but the minimal 
possible) example of the xslt stylesheet and the source xml document, to say 
what is the expected result, what is the actual result and how the actual 
result differs from what was expected.

Cheers,
Dimitre Novatchev.


"Tjerk Wolterink" <tjerk@wolterinkwebdesign.com> wrote in message 
news:echh0i$9hm$1@netlx020.civ.utwente.nl...
>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>
>
>   </xsl:when>
>   <xsl:otherwise>
>
>    <xsl:call-template name="myTemplate">
>     <xsl:with-param name="value" select="./text()"/>
>    </xsl:call-template>
>
>   </xsl:otherwise>
> </xsl:for-each>
>
>
> But this requires me to change every call to myTemplate,
> which is alot of code. Can't i change myTemplate so
> it works?
>
> Who can help me? Please.. 


0
dimitren1 (155)
8/24/2006 3:28:39 AM
Reply:

Similar Artilces:

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

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

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

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

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

removing a node from a node-set
Hi, I have a template "delete-node" with two arguments containing document fragments when called. I want to return a new document fragment which contains all nodes from argument 2 except the one which is contained in argument 1. The code currently looks like this: <xsl:template name="delete-node"> <xsl:param name="todelete" /> <xsl:param name="notprocessed" /> <xsl:copy-of select="$notprocessed[not(@id = $todelete/node/@id)]"/> </xsl:template> And an example for $todelete is: <node id='x'> ... </node> and $notprocessed contains a few of those nodes including the one with id 'x'. Is there a solution to this problem without using exsl:node-set()? ...

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

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

selecting nodes between other nodes
Hi! <root> <foo>bar</foor> <blah /> <blah2 /> <a> <b /> <c /> </> </root> I want to select everything between <foo> and <a>. Is this possible? Timo In article <2jbjjhFvf4ttU1@uni-berlin.de>, Timo Nentwig <tcn@spamgourmet.org> wrote: % <root> % <foo>bar</foor> % <blah /> % <blah2 /> % <a> % <b /> % <c /> % </> % </root> % I want to select everything between <foo> and <a>. Is this possible? How about <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 = '.'/> </xsl:template> <xsl:template match='text()'/> </xsl:stylesheet> ? -- Patrick TJ McPhee East York Canada ptjm@interlog.com ...

xsl variables and node-sets
Hi, I would like to use <xsl:variable> and <xsl:choose> to dynamically set a node-set to a variable. Something like: <xsl:variable name="MyVar"> <xsl:choose> <xsl:when test="$MyVar2='0'"> Here I want to select a node set from the source xml document </xsl:when> <xsl:otherwise> Here I want to select a different node set from the source xml document </xsl:otherwise> </xsl:choose> </xsl:variable> Does anyone know how I can do this? Thanks. Simon ...

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

Inserting Nodes between Nodes
Hi, XML novice here with another question. I need to add a XML node like, [code] <child01> <child02> <text></text> <image>image 1</image> <image>image 2</image> </child02> </child01> [/code] into this node between the ending </child01> and beginning <child01> of the [code] <child01> <child02> <text></text> <image>image 1</image> <image>image 2</image> </child02> </child01> <child01> <child02> <text></text> <image>image 1</image> <image>image 2</image> </child02> </child01> [/code] Does this make sense? I guess im looking for a way to say/do... make a new node with the following values and place it between these other two nodes. I still am learning XML but i think this can be done. On Jan 21, 12:34 am, cesarcesar <ce...@empiresolutions.net> wrote: > Hi, > > XML novice here with another question. I need to add a XML node like, > > [code] > <child01> > <child02> > <text></text> > <image>image 1</image> > <image>image 2</image> > </child02> > </child...

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 "CourseOrMeetingName" 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 //viewentry[ (entrydata[@name='CourseOrMeetingName'][text='Course ABC']) and (entrydata[@name='StartDate'][datetime='20070110'])]" <viewentry position="1" unid="E5FE575692CAB4CD852572140052F751" noteid="893A" siblings="24"> <entrydata columnnumber="0" name="CourseOrMeetingName"> <text>Course ABC</text></entrydata> <entrydata columnnumber="1" name="StartDate"> <datetime>20070110</datetime></entrydata> <entrydata columnnumber="2" name="City"> <text>West chester</text></entrydata> <entrydata columnnumber="3" name="FirstName"> <text>Joe</text></entrydata> <entrydata columnnumber="4" name="MiddleName"> <text></text></entrydata> <entrydata columnnumber="5" name="LastName"> <text>...

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

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

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: node-node adj 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 arc-node adj 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...

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

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

Get XML values from nodes and child nodes
Hi everybody. My XML file is: <Locatore> <NumeroProgressivo>001</NumeroProgressivo> <CodiceFiscale>CSTNDA69P90H523R</CodiceFiscale> <PersoneFisiche> <Cognome>CAST</Cognome> <Nome>NADIR</Nome> <Sesso>F</Sesso> <DataNascita>10091979</DataNascita> <ComuneNascita>RONCA</ComuneNascita> <ProvinciaNascita>BL</ProvinciaNascita> </PersoneFisiche> </Locatore> <Locatore> <NumeroProgressivo>002</NumeroProgressivo> <CodiceFiscale>PRSGRI74L29F443L</CodiceFiscale> <PersoneFisiche> <Cognome>PERISSI</Cognome> <Nome>IGOR</Nome> <Sesso>M</Sesso> <DataNascita>29071970</DataNascita> <ComuneNascita>MONTE</ComuneNascita> <ProvinciaNascita>SA</ProvinciaNascita> </PersoneFisiche> </Locatore> 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 ..... With this: SELECT X.valore.query('NumeroProgressivo').value('.', 'VARCHAR(20)') as NumeroProgressivo, X.valore.query('CodiceFiscale').value('.', 'VARCHAR(16)') as CodiceFiscale FROM Tbulk CROSS APPLY Tbulk.nodes('Fornitura/Documento/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 - xsl variable $node/text() but $node can non-node-set help! - comp.text.xml

Resources last updated: 3/13/2016 10:35:55 PM