ccm_paper
asked on
generating XML from xsl
Hi,
I need to write an xsl file that is used to generate XML file.
I need to write something like this
XSL file gets a value pass of fail.
Depending on this value (either pass of fail) when xml file is generated
it should have appropriate link or html page where request is to be
directed.
Does anyone has a sample code, or link wherein i can get something like
what i want.
thanks in advance,
regards,
Shashank
I need to write an xsl file that is used to generate XML file.
I need to write something like this
XSL file gets a value pass of fail.
Depending on this value (either pass of fail) when xml file is generated
it should have appropriate link or html page where request is to be
directed.
Does anyone has a sample code, or link wherein i can get something like
what i want.
thanks in advance,
regards,
Shashank
ASKER
Hi satish,
Thanks for you for the keen interest shown.
In brief, my source code is using this xsl file to generate the xml file. MSXML 4.0 is used as parser.
The xsl file uses <xsl:stylesheet xmlnssl="http://www.w3.org/TR/WD-xsl">
Here if i changes the namespace it gives me a error.
I don't have much clue whether i can change the namespace. I tried to change
it in the xsl file but it gave me error
The namesspace used here is <xsl:stylesheet xmlnssl="http://www.w3.org/TR/WD-xsl">
which does not recognise param if i use it with my namespace.
Can u suggest any turnaround.
Thanks once again.
regards
Thanks for you for the keen interest shown.
In brief, my source code is using this xsl file to generate the xml file. MSXML 4.0 is used as parser.
The xsl file uses <xsl:stylesheet xmlnssl="http://www.w3.org/TR/WD-xsl">
Here if i changes the namespace it gives me a error.
I don't have much clue whether i can change the namespace. I tried to change
it in the xsl file but it gave me error
The namesspace used here is <xsl:stylesheet xmlnssl="http://www.w3.org/TR/WD-xsl">
which does not recognise param if i use it with my namespace.
Can u suggest any turnaround.
Thanks once again.
regards
When you change the namespace, remember to include the version attribute,
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
Could you post the error message you are getting?
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
Could you post the error message you are getting?
ASKER
i have used the namespace with version i.e.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
I am getting this error.
Expected token 'eof' found '['. .-->[<--.='Application Does not Exist']
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
I am getting this error.
Expected token 'eof' found '['. .-->[<--.='Application Does not Exist']
I think its not because of the namespace, should be a problem with XPATH used in the stylesheet. Could you post the entire stylesheet?
ASKER
Hi , here is the xsl file.Hope it will help you.Plz read the comment i have that i have written starting with your name.
Thanks
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<!--display Host Name ,Time,Date in the title -->
<head>
<title>show Report-<xsl:value-of select="//Header/Host_Name "/>-
<xsl:value-of select="//Header/Time"/>-
<xsl:value-of select="//Header/Date"/>
</title>
</head>
<body>
<h2>Checks Report</h2>
<!-- Display All the Header Information in tabular form-->
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<!-- some values i have deleted to focus on the issue-->
<tr>
<td>Date</td>
<td><xsl:value-of select="//Header/Date"/></ td>
</tr>
</table>
<!-- the Overal Summary -->
<h4><xsl:value-of select="*/Overall_Summary" /></h4>
<h3>Summary</h3>
<!--Display the Summary in a tabular form-->
<table border="1" cellpadding="0" cellspacing="0" width="100%" align="center">
<!--Display the column names of the summary -->
<tr>
<td><b>Check Type</b></td>
<td><b>Passed</b></td>
<td><b>Failed</b></td>
<td><b>Warnings</b></td>
<td><b>Not Executed</b></td>
<td><b>Total</b></td>
</tr>
<!--Display the actual summary -->
<xsl:for-each select="*/Summary/*">
<tr>
<td><xsl:value-of select="@Type"/></td>
<td><xsl:value-of select="@Passed"/></td>
<td><xsl:value-of select="@Failed"/> </td>
<td><xsl:value-of select="@Warnings"/></td>
<td><xsl:value-of select="@Not_Executed"/></ td>
<td><xsl:value-of select="@Total"/></td>
</tr>
</xsl:for-each>
</table>
<!--Display the Details Checks in tabular form -->
<xsl:for-each select="*/Installation-Che cks/Softwa re-Checks" >
<!-- Display the contents in table -->
<table border="1" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr style="text-align:left">
<td><b>Check Name</b></td>
<td><b>Required Value</b></td>
<td><b>Actual Value</b></td>
<td><b>Result</b></td>
</tr>
<xsl:for-each select="cerity_check">
<tr style="text-align:left">
<td> <xsl:value-of select="@Check-Name"/></td >
<td> <xsl:value-of select="@Expected-Value"/> </td>
<td><xsl:value-of select="@Actual-Value"/></ td>
<td><xsl:value-of select="."/> </td>
<!--HERE I WANT TO COMPARE THE VALUE OF"<xsl:value-of select="."/>" IT WITH 'PASSED' OR 'FAILED' AND DEPENDING
ON THE RESULT HYPERLINK FAILED or PASSED (which i will be seeing in the .xml file) TO SOME OTHER HTML FILE -->
</tr>
</xsl:for-each>
</table>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Thanks
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<!--display Host Name ,Time,Date in the title -->
<head>
<title>show Report-<xsl:value-of select="//Header/Host_Name
<xsl:value-of select="//Header/Time"/>-
<xsl:value-of select="//Header/Date"/>
</title>
</head>
<body>
<h2>Checks Report</h2>
<!-- Display All the Header Information in tabular form-->
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<!-- some values i have deleted to focus on the issue-->
<tr>
<td>Date</td>
<td><xsl:value-of select="//Header/Date"/></
</tr>
</table>
<!-- the Overal Summary -->
<h4><xsl:value-of select="*/Overall_Summary"
<h3>Summary</h3>
<!--Display the Summary in a tabular form-->
<table border="1" cellpadding="0" cellspacing="0" width="100%" align="center">
<!--Display the column names of the summary -->
<tr>
<td><b>Check Type</b></td>
<td><b>Passed</b></td>
<td><b>Failed</b></td>
<td><b>Warnings</b></td>
<td><b>Not Executed</b></td>
<td><b>Total</b></td>
</tr>
<!--Display the actual summary -->
<xsl:for-each select="*/Summary/*">
<tr>
<td><xsl:value-of select="@Type"/></td>
<td><xsl:value-of select="@Passed"/></td>
<td><xsl:value-of select="@Failed"/> </td>
<td><xsl:value-of select="@Warnings"/></td>
<td><xsl:value-of select="@Not_Executed"/></
<td><xsl:value-of select="@Total"/></td>
</tr>
</xsl:for-each>
</table>
<!--Display the Details Checks in tabular form -->
<xsl:for-each select="*/Installation-Che
<!-- Display the contents in table -->
<table border="1" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr style="text-align:left">
<td><b>Check Name</b></td>
<td><b>Required Value</b></td>
<td><b>Actual Value</b></td>
<td><b>Result</b></td>
</tr>
<xsl:for-each select="cerity_check">
<tr style="text-align:left">
<td> <xsl:value-of select="@Check-Name"/></td
<td> <xsl:value-of select="@Expected-Value"/>
<td><xsl:value-of select="@Actual-Value"/></
<td><xsl:value-of select="."/> </td>
<!--HERE I WANT TO COMPARE THE VALUE OF"<xsl:value-of select="."/>" IT WITH 'PASSED' OR 'FAILED' AND DEPENDING
ON THE RESULT HYPERLINK FAILED or PASSED (which i will be seeing in the .xml file) TO SOME OTHER HTML FILE -->
</tr>
</xsl:for-each>
</table>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
In this case you are not using any parameter, right? So, straightaway you can insert the condition (without using xsl:param),
(replace the comment with the following segment)
<td>
<xsl:choose>
<xsl:when test=".='PASSED'"><a href='PASSED.htm'>PASSED</ a></xsl:wh en>
<xsl:otherwise><a href='FAILED.htm'>FAILED</ a></xsl:ot herwise>
</xsl:choose>
</td>
(or)
<td>
<xsl:if test=".='PASSED'"><a href='PASSED.htm'>PASSED</ a></xsl:if >
<xsl:if test=".='FAILED'"><a href='FAILED.htm'>FAILED</ a></xsl:if >
</td>
(replace the comment with the following segment)
<td>
<xsl:choose>
<xsl:when test=".='PASSED'"><a href='PASSED.htm'>PASSED</
<xsl:otherwise><a href='FAILED.htm'>FAILED</
</xsl:choose>
</td>
(or)
<td>
<xsl:if test=".='PASSED'"><a href='PASSED.htm'>PASSED</
<xsl:if test=".='FAILED'"><a href='FAILED.htm'>FAILED</
</td>
ASKER
Hi sathis,
I tried with the line of code u send.
I am getting this error.
Expected token 'eof' found '='. .-->=<--Passed
Thanks and Regards
I tried with the line of code u send.
I am getting this error.
Expected token 'eof' found '='. .-->=<--Passed
Thanks and Regards
Try assigning the value to a variable and comparing the value:
<xsl:variable name="tagvalue" select="."/>
<xsl:if test="$tagvalue='PASSED'"> </xsl:if>
BTW, how are you running the transformation?
<xsl:variable name="tagvalue" select="."/>
<xsl:if test="$tagvalue='PASSED'">
BTW, how are you running the transformation?
ASKER
hi sathis,
I can't this syntax because the namaspace(that i am using) does not support variable
I am getting this error.
Keyword xsl:variable may not be used in namespace http://www.w3.org/TR/WD-xsl.
regards
I can't this syntax because the namaspace(that i am using) does not support variable
I am getting this error.
Keyword xsl:variable may not be used in namespace http://www.w3.org/TR/WD-xsl.
regards
Can you explain how you are running the transformation?
http://www.w3.org/TR/WD-xsl is a old namespace. The parser should support the http://www.w3.org/1999/XSL/Transform namespace.
http://www.w3.org/TR/WD-xsl is a old namespace. The parser should support the http://www.w3.org/1999/XSL/Transform namespace.
ASKER
Hi sathis,
I have already a running code written in VC++ .It has some xml files which it uses from the code.
It uses the XSL file to generate the final report in XML.
I have given the code and told to provide the feature (of hyperlink which i explained above).
I don't know much about XSL/XSLT. and how i can change the namespace.I tried to change the namespace from the xsl (which i guess is wrong) but it gave me an error.
Does the above info of any help to you.
Regards
I have already a running code written in VC++ .It has some xml files which it uses from the code.
It uses the XSL file to generate the final report in XML.
I have given the code and told to provide the feature (of hyperlink which i explained above).
I don't know much about XSL/XSLT. and how i can change the namespace.I tried to change the namespace from the xsl (which i guess is wrong) but it gave me an error.
Does the above info of any help to you.
Regards
Sorry, I'm still not sure how the whole scheme works.
MSXML 4.0 definitely supports the new namespace. When you install latest versions of MSXML parser it needs to be installed in replacement mode (though this is given for MSXML 3.0 only) by running the tool (xmlinst.exe) given in the page:
http://www.microsoft.com/downloads/details.aspx?familyid=1e6185d7-e4e4-43b1-8056-0e5ecd15a88a&languageid=f49e8428-7071-4979-8a67-3cffcb0c2524&displaylang=en
Hope this helps.
MSXML 4.0 definitely supports the new namespace. When you install latest versions of MSXML parser it needs to be installed in replacement mode (though this is given for MSXML 3.0 only) by running the tool (xmlinst.exe) given in the page:
http://www.microsoft.com/downloads/details.aspx?familyid=1e6185d7-e4e4-43b1-8056-0e5ecd15a88a&languageid=f49e8428-7071-4979-8a67-3cffcb0c2524&displaylang=en
Hope this helps.
ASKER
Hi sathis,
I will get back to u 2marow with detailed Information.
Thanks for co-operation.
regards
I will get back to u 2marow with detailed Information.
Thanks for co-operation.
regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:param name="flag"/>
<xsl:template match="/">
<html>
<body>
<a><xsl:attribute name="href"><xsl:choose><x
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Hope this helps.
Cheers,
Sathish