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
1) These "value-of" tags in XSLT are not getting replaced by values in XML file at the place in wanted in Output
2) 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 )?
--------- XSLT File:- ------- <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" > <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 (
'oracleAppVersion',java-version,java-vendor,java-vm-version,java-vm-vendor,java-vm-name,os-arch,os-name,os-version ) 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 (http://www.altova.com)--> <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).
ie <xsl:stylesheet version="2.0" xmlns:x="http://xx" ...
<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.