Re: [xsl] Problem with "value-of" tags in XSLT to be placed at desired location in Text Output

Subject: Re: [xsl] Problem with "value-of" tags in XSLT to be placed at desired location in Text Output
From: "Jon Gorman" <jonathan.gorman@xxxxxxxxx>
Date: Mon, 22 May 2006 15:14:43 -0500
These "value-of" tags in XSLT are not getting replaced
by values in XML file at the place in wanted in Output

They are getting replaced, but by nothing.

How to get all 3 insert statements in the output(My
current output is stuck after first insert staement ..
not going back to XML file )?

Hmmm, I think you need to learn a bit more about xslt/xpath.

I'll comment in more detail in the section with more detail ;).

XSLT File:-
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="2.0"
        <xsl:output method="text" indent="yes"/>
         <xsl:template match="domain-name/server">

^^^ ok, first issue. So you match server nodes that have a parent of domain-name. I don't see anything like that in the input element. I see a domain-name that is a sibling of a server element, but not as a parent. In fact, I'm not sure why you're getting any output besides the text values of the nodes. Are you sure the xslt that you posted is giving the output you described?

insert into server (

) values (
    <xsl:value-of select="/comp/weblogic-version"/>,

Remember like in Unix path names, in XPath / is a special symbol that indicates the start of the document and hence indicates an absolute path. So it goes up to the very top of the document and looks for the element comp. There is no element comp in the top of the document. Hence things break.

It looks like you want something like...
<xsl:template match="server" >
<xsl:value-of select="comp/weblogic-version" />


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="file.xslt" type="text/xslt"?>

<!--Sample XML file generated by XMLSpy v2006 sp1 U
<inventory xmlns="http://xx";

^^^ another issue. Your elements are in a in a namespace. I really don't understand how you managed to get any output (or anything besides the text value of the nodes in the tree).

So you need a prefix in your xslt

<xsl:stylesheet version="2.0"

and in your xpath indicate that:

<xsl:template match="x:server" >
<xsl:value-of select="x:comp/x:weblogic-version" />

Not to sound rude, but you're asking some pretty basic questions.  I'd
recommend getting some good beginner material or google for tutorials.
Start with some very simple xml and xslt samples until you have a
better grasp of XPath.

Jon Gorman

Current Thread