现在我用的是Stylus Studio 2007 XML Enterprise Suite,我推荐大家使用这个IDE开发xsl非常方便 下面简单介绍一下: 先建立xml和xsl文件如下:BasicInfo.XML<?xml version="1.0"?><Data> <ME> <UserID>1</UserID> <BasicInfo> <UserID>1</UserID> <Gender>true</Gender> <Age>27</Age> <UserName>Eric Liu</UserName> <Height>184</Height> <Marriage>1</Marriage> <Education>2</Education> <Income>5</Income> <City>861105</City> <Desc>南方人了,普通话说不好,人比较笨,父母是农民,自小放牛、插秧、割稻、砍柴都干过了。自己条件也不知道算好还是差,竹竿一只,不过各个部件还算运转正常,长得不好看,父母也没有对不起我了,就是一般一般那种。没车没房,唉,一说这条全国人民都跑了,在别人看来,是在一家还算不错的公司一个也算不错的职位,应该也会有不错的前景。性格比较温和,也比较迷糊,在百合这里就是碰,看看是否可以碰到了。不过我想看完我的介绍,估计所有的鸭子都飞了,唉,坦白也是一种错嘛? 如果有阶层观念或者对父母不是很好的就别和我说话了,我从事IT相关的,但是平时也会给媒体供稿,每天晚上一碗面条就将我养活了</Desc> <LoveType>12</LoveType> <PhotoUrl>SW1hZ2VHVUlEJDF8UERUQnwyMDA2XDhcMVx8MjAzMmI1OTYtZDM5Mi00YWE5LTg5YjEtNDU0MDJjZjhjNThlfEpQRUc=</PhotoUrl> <MinAge>21</MinAge> <MaxAge>26</MaxAge> <MinHeight>166</MinHeight> <MaxHeight>180</MaxHeight> <MatchMarriage>1</MatchMarriage> <MatchEducation>6</MatchEducation> <MatchOccupation>131071</MatchOccupation> <MatchIncoming>126</MatchIncoming> <MatchLocation>8611</MatchLocation> <IsVIP>true</IsVIP> <IsAuthenticated>false</IsAuthenticated> <HeartCode>000000</HeartCode> <LoveStatus>1</LoveStatus> </BasicInfo> <SupplyInfo> <UserID>1</UserID> <Gender>true</Gender> <Birthday class="sql-timestamp">1980-11-17 00:00:00.0</Birthday> <Nationality>1</Nationality> <Astrology>8</Astrology> <AnimalSign>9</AnimalSign> <Weight>66</Weight> <BodyType>2</BodyType> <Occupation>4</Occupation> <JobTitle>架构师</JobTitle> <Industry>1</Industry> <Institution></Institution> <PhysicalLooking>8</PhysicalLooking> <NativePlace>863508 </NativePlace> <HaveChildren>1</HaveChildren> <WantChildren>1</WantChildren> <Religion>1</Religion> <Smoking>2</Smoking> <Drinking>2</Drinking> <Favorites> <FavoriteItem> <Name>读书</Name> <Value>1</Value> <Category>Interest</Category> </FavoriteItem> <FavoriteItem> <Name>听音乐</Name> <Value>1</Value> <Category>Interest</Category> </FavoriteItem> <FavoriteItem> <Name>计算机/互联网</Name> <Value>1</Value> <Category>Interest</Category> </FavoriteItem> <FavoriteItem> <Name>看电视</Name> <Value>1</Value> <Category>Interest</Category> </FavoriteItem> <FavoriteItem> <Name>喝咖啡</Name> <Value>1</Value> <Category>Interest</Category> </FavoriteItem> <FavoriteItem> <Name>轻音乐</Name> <Value>1</Value> <Category>Music</Category> </FavoriteItem> <FavoriteItem> <Name>中国流行乐</Name> <Value>1</Value> <Category>Music</Category> </FavoriteItem> <FavoriteItem> <Name>港台流行乐</Name> <Value>1</Value> <Category>Music</Category> </FavoriteItem> <FavoriteItem> <Name>蓝调(Blue)</Name> <Value>1</Value> <Category>Music</Category> </FavoriteItem> <FavoriteItem> <Name>欧美流行乐</Name> <Value>1</Value> <Category>Music</Category> </FavoriteItem> <FavoriteItem> <Name>羽毛球</Name> <Value>1</Value> <Category>Sports</Category> </FavoriteItem> <FavoriteItem> <Name>跳舞</Name> <Value>1</Value> <Category>Sports</Category> </FavoriteItem> <FavoriteItem> <Name>极限运动</Name> <Value>1</Value> <Category>Sports</Category> </FavoriteItem> <FavoriteItem> <Name>爱情</Name> <Value>1</Value> <Category>Movie</Category> </FavoriteItem> <FavoriteItem> <Name>武打动作</Name> <Value>1</Value> <Category>Movie</Category> </FavoriteItem> <FavoriteItem> <Name>动作片</Name> <Value>1</Value> <Category>Movie</Category> </FavoriteItem> <FavoriteItem> <Name>警匪枪战</Name> <Value>1</Value> <Category>Movie</Category> </FavoriteItem> <FavoriteItem> <Name>清淡</Name> <Value>1</Value> <Category>Food</Category> </FavoriteItem> </Favorites> </SupplyInfo> <PPSettings> <UserID>1</UserID> <AllowAll>true</AllowAll> <AllowLoginUser>false</AllowLoginUser> <AllowCredentialUser>false</AllowCredentialUser> <AllowAuthorizedUser>false</AllowAuthorizedUser> <AllowVIPUser>false</AllowVIPUser> <Password>1</Password> </PPSettings> </ME> <OPP> <UserID>1913037</UserID> <BasicInfo> <UserID>1913037</UserID> <Gender>true</Gender> <Age>25</Age> <UserName>leoliu</UserName> <Height>175</Height> <Marriage>1</Marriage> <Education>2</Education> <Income>3</Income> <City>861111</City> <Desc></Desc> <LoveType>15</LoveType> <PhotoUrl>SW1hZ2VHVUlEJDF8Rk1TUHwyMDA3XDVcMjJcfGQzOWE5MDM5LWFhYWMtNGJiYi04MjkwLWU3NzIyMTg5YzM1ZnxKUEVH</PhotoUrl> <MinAge>17</MinAge> <MaxAge>30</MaxAge> <MinHeight>160</MinHeight> <MaxHeight>180</MaxHeight> <MatchMarriage>1</MatchMarriage> <MatchEducation>30</MatchEducation> <MatchOccupation>131071</MatchOccupation> <MatchIncoming>129</MatchIncoming> <MatchLocation>8611</MatchLocation> <IsVIP>false</IsVIP> <IsAuthenticated>true</IsAuthenticated> <HeartCode>000000</HeartCode> <LoveStatus>1</LoveStatus> </BasicInfo> <SupplyInfo> <UserID>1913037</UserID> <Gender>true</Gender> <Birthday class="sql-timestamp">1982-03-28 00:00:00.0</Birthday> <Nationality>1</Nationality> <Astrology>1</Astrology> <AnimalSign>11</AnimalSign> <Weight>75</Weight> <BodyType>8</BodyType> <Occupation>17</Occupation> <Industry>1</Industry> <PhysicalLooking>8</PhysicalLooking> <NativePlace>864201 </NativePlace> <HaveChildren>1</HaveChildren> <WantChildren>3</WantChildren> <Religion>1</Religion> <Smoking>1</Smoking> <Drinking>2</Drinking> <Favorites> <FavoriteItem> <Name>运动</Name> <Value>1</Value> <Category>Interest</Category> </FavoriteItem> <FavoriteItem> <Name>轻音乐</Name> <Value>1</Value> <Category>Music</Category> </FavoriteItem> <FavoriteItem> <Name>电子音乐</Name> <Value>1</Value> <Category>Music</Category> </FavoriteItem> <FavoriteItem> <Name>说唱</Name> <Value>1</Value> <Category>Music</Category> </FavoriteItem> <FavoriteItem> <Name>羽毛球</Name> <Value>1</Value> <Category>Sports</Category> </FavoriteItem> <FavoriteItem> <Name>乒乓球</Name> <Value>1</Value> <Category>Sports</Category> </FavoriteItem> <FavoriteItem> <Name>篮球</Name> <Value>1</Value> <Category>Sports</Category> </FavoriteItem> <FavoriteItem> <Name>足球</Name> <Value>1</Value> <Category>Sports</Category> </FavoriteItem> <FavoriteItem> <Name>爱情</Name> <Value>1</Value> <Category>Movie</Category> </FavoriteItem> <FavoriteItem> <Name>武打动作</Name> <Value>1</Value> <Category>Movie</Category> </FavoriteItem> <FavoriteItem> <Name>清淡</Name> <Value>1</Value> <Category>Food</Category> </FavoriteItem> <FavoriteItem> <Name>能填饱肚子就好</Name> <Value>1</Value> <Category>Food</Category> </FavoriteItem> </Favorites> </SupplyInfo> <PPSettings> <UserID>1913037</UserID> <AllowAll>false</AllowAll> <AllowLoginUser>false</AllowLoginUser> <AllowCredentialUser>false</AllowCredentialUser> <AllowAuthorizedUser>false</AllowAuthorizedUser> <AllowVIPUser>true</AllowVIPUser> <Password></Password> </PPSettings> </OPP></Data> BasicInfo.xsl<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:BitHelper="BitHelper"> <xsl:output method="html" omit-xml-declaration="no" standalone="yes" indent="yes"/> <xsl:include href="lovetype.xsl"/> <xsl:include href="codeTab.xsl"/> <xsl:include href="city.xsl"/> <xsl:include href="ppsettings.xsl"/> <xsl:template match="/"> <xsl:variable name="curUserID" select="Data/ME/BasicInfo/u" /> <xsl:variable name="oppUserID" select="Data/OPP/BasicInfo/UserID"/> <xsl:variable name="oppGender" select="Data/OPP/BasicInfo/Gender"/> <xsl:variable name="oppAge" select="Data/OPP/BasicInfo/Age"/> <xsl:variable name="oppHeight" select="Data/OPP/BasicInfo/Height"/> <xsl:variable name="oppEducation" select="Data/OPP/BasicInfo/Education"/> <xsl:variable name="oppCity" select="Data/OPP/BasicInfo/City"/> <xsl:variable name="oppIncome"> <xsl:call-template name="GetIncome"> <xsl:with-param name="Income" select="Data/OPP/BasicInfo/Income"/> </xsl:call-template> </xsl:variable> <div class="RightContent"> <!--<%@include file="Control/TabHeader.jsp" %>--> <div id="TabContainer" class="TabContainer"> <div class="BasicContent"> <div class="PagePart"> <div class="BasicInfo"> <div class="UserName">goody9807.个人资料</div> <div class="FocusFont">(重点关注对象)</div> <div> <table border="0" cellspacing="0" cellpadding="5" width="100%"> <tr> <td>性别:<xsl:if test="$oppGender='true'">男</xsl:if> <xsl:if test="$oppGender='false'">女</xsl:if> </td> <td>年龄:<xsl:value-of select="$oppAge"/>岁</td> </tr> <tr> <td>身高:<xsl:value-of select="$oppHeight"/>厘米</td> <td>婚姻状态:<xsl:call-template name="GetMarry"><xsl:with-param name="Marry" select="Data/OPP/BasicInfo/Marriage"/></xsl:call-template></td> </tr> <tr> <td>学历:<xsl:call-template name="GetDegree"><xsl:with-param name="Degree" select="Data/OPP/BasicInfo/Education"/></xsl:call-template></td> <td>月收入(元):<xsl:call-template name="ppsettings"> <xsl:with-param name="PrivateContent" select="$oppIncome"/></xsl:call-template></td> </tr> <tr> <td colspan="2">居住地: <!--<xsl:call-template name="GetCity"><xsl:with-param name="City" select="Data/OPP/BasicInfo/City"/></xsl:call-template>--></td> </tr> </table> </div> <!-- script type="text/javascript" src="http://www1.baihe.com/serviceproxy.aspx?Type=/PageModules/Comm/Match2/CreditIdentify&OppositeID=1"></script--> <div class="credit"></div> </div> <div class="MatchInfo"> <!--<%@ include file="Control/MatchControl.jsp" %>--> </div> <div class="clear"></div> </div> <div class="PagePart"> <img src="Images/0302mes_tit_she.jpg" width="74" height="61" alt=""/> <img src="Images/0302mes_tit_bz.jpg" width="114" height="61" alt=""/> <img src="Images/0302mes_tit_wei.jpg" width="392" height="61" alt=""/> <br/> <div class="TextPart">希望心中的他应该是:<br/> 年龄:<xsl:value-of select="Data/OPP/BasicInfo/MinAge"/>岁~<xsl:value-of select="Data/OPP/BasicInfo/MaxAge"/>岁, 身高:<xsl:value-of select="Data/OPP/BasicInfo/MinHeight"/>cm~<xsl:value-of select="Data/OPP/BasicInfo/MaxHeight"/>cm, 婚姻状况:<xsl:call-template name="GetMatchMarry"> <xsl:with-param name="MatchMarry" select="Data/OPP/BasicInfo/MatchMarriage"/></xsl:call-template>, 从事职业:<xsl:call-template name="GetMatchOccupation"> <xsl:with-param name="MatchOccupation" select="Data/OPP/BasicInfo/MatchOccupation"/></xsl:call-template>, 教育程度:<xsl:call-template name="GetMatchEducation"> <xsl:with-param name="MatchEducation" select="Data/OPP/BasicInfo/MatchEducation"/></xsl:call-template> ,平均月收入(元):<xsl:call-template name="GetMatchIncome"> <xsl:with-param name="MatchIncome" select="Data/OPP/BasicInfo/MatchIncoming"/></xsl:call-template>, 居住地: <!--<xsl:call-template name="GetCity"><xsl:with-param name="City" select="Data/OPP/BasicInfo/MatchLocation"/></xsl:call-template>--></div> </div> <div class="PagePart"> <img src="Images/0302mes_tit_she.jpg" width="74" height="61" alt=""/> <img src="Images/0302mes_tit_js.jpg" width="114" height="61" alt=""/> <img src="Images/0302mes_tit_wei.jpg" width="392" height="61" alt=""/> <br/> <div class="TextPart"> <xsl:choose> <xsl:when test="/Data/OPP/BasicInfo/Desc!=''"> <xsl:value-of select="/Data/OPP/BasicInfo/Desc"/> </xsl:when> <xsl:otherwise> 欢迎你与我沟通,期待与你相识。 </xsl:otherwise> </xsl:choose> </div> </div> </div> </div> <div> <!--<%@include file="BottomBtnList.jsp" %>--> </div> </div> <br class="Clear"/> </xsl:template></xsl:stylesheet> 建立xsl时需要把xml文件设置为xsl文件的源 然后设置使用哪个编译器,这里我们设置XalanJ 点击运行按钮即可看到结果 是不是很方便! 这个IDE提示功能相当强大,非常智能,只有你使用了才知道它的方便 还有自动缩进功能,你写得代码非常乱,点个按钮系统就自动帮你整理好了! 以上都是xsl文件中系统提供的功能 XML文件中系统提供了一个XPath查询功能 你输入XPath路径即可查询到对应路径的XML文件中的结点