My Boss gave me a xml file. after that told me, use java servlet or any thing that can transform xml file to html. I find some infomation about processing XML and xsl also. with some easy example. my code can run and have a output file ( html ). But with this file, i cant get value of elements.
Here is my xml file
<OMeS>
<PMSetup startTime="2013-05-14T23:00:00.000+07:00:00" interval="60">
<PMMOResult>
<MO>
<DN><![CDATA[PLMN-PLMN/RNC-14]]></DN>
</MO>
<MO>
<DN><![CDATA[PLMN-PLMN/HOS-14/SCID-51321]]></DN>
</MO>
<MO>
<DN><![CDATA[PLMN-PLMN/MCC-452/MNC-1]]></DN>
</MO>
<MO>
<DN><![CDATA[PLMN-PLMN/LAC-20180/CI-51393]]></DN>
</MO>
<MO>
<DN><![CDATA[PLMN-PLMN/MCC-452/MNC-1]]></DN>
</MO>
<PMTarget measurementType="AutoDef_ISHO_v2">
<M1015C0>21</M1015C0>
<M1015C1>21</M1015C1>
<M1015C2>6927</M1015C2>
<M1015C3>224</M1015C3>
<M1015C4>45890</M1015C4>
<M1015C5>25</M1015C5>
</PMTarget>
</PMMOResult>
<PMMOResult>
<MO>
<DN><![CDATA[PLMN-PLMN/RNC-14]]></DN>
</MO>
<MO>
<DN><![CDATA[PLMN-PLMN/HOS-14/SCID-51393]]></DN>
</MO>
<MO>
<DN><![CDATA[PLMN-PLMN/MCC-452/MNC-1]]></DN>
</MO>
<MO>
<DN><![CDATA[PLMN-PLMN/LAC-20180/CI-51393]]></DN>
</MO>
<MO>
<DN><![CDATA[PLMN-PLMN/MCC-452/MNC-1]]></DN>
</MO>
<PMTarget measurementType="AutoDef_ISHO_v2">
<M1015C0>29</M1015C0>
<M1015C1>29</M1015C1>
<M1015C2>8385</M1015C2>
<M1015C3>239</M1015C3>
<M1015C4>62130</M1015C4>
<M1015C5>37</M1015C5>
</PMTarget>
</PMMOResult>
</PMSetup>
</OMeS>
Here is my xsl file
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My data</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>MO</th>
</tr>
<xsl:for-each select="OMeS/PMSetup/PMMOResult">
<tr>
<td>
<xsl:value-of select="MO/DN"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I use java servlet to transform this xml to html. so, it shows no thing. Please help me ! and have any tut for xsl that i can learn ?
When I add the missing xsl:stylesheet start tag to your code
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
it runs just fine.
If that really was your error, then you need to look at how you are running the code to make sure that the next time you make a simple mistake, you display the diagnostics somewhere you can see them. Generally I would debug a stylesheet in some IDE or command line environment rather than "in situ" as a servlet.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.