<? xml version="1.0" ?> < report > < title > Database Access Sample </ title > < section > < title > Employees by Last Name </ title > < dbaccess driver ="COM.ibm.db2.jdbc.app.DB2Driver" database ="jdbc:db2:sample" tablename ="wstkadmin.employee" where ="*" fieldnames ='lastname as "Last Name", firstnme as "First Name", workdept as "Department"' order-by ="lastname" group-by ="lastname, firstnme, workdept" /> </ section > </ report > <? xml version="1.0" ?> < xsl:stylesheet xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" version ="1.0" > < xsl:output method ="xml" /> < xsl:template match ="*" > < xsl:element name ="{name()}" > < xsl:for-each select ="@*" > < xsl:element name ="{name()}" > < xsl:value-of select ="." /> </ xsl:element > </ xsl:for-each > < xsl:apply-templates select ="*|text()" /> </ xsl:element > </ xsl:template > </ xsl:stylesheet > <? xml version="1.0" encoding="UTF-8" ?> < report > < title > Database Access Sample </ title > < section > < title > Employees by Last Name </ title > < dbaccess >< driver > COM.ibm.db2.jdbc.app.DB2Driver </ driver >< database > jdbc:db2:sample </ database >< tablename > wstkadmin.employee </ tablename >< where > * </ where >< fieldnames > lastname as "Last Name", firstnme as "First Name", workdept as "Department" </ fieldnames >< order-by > lastname </ order-by >< group-by > lastname, firstnme, workdept </ group-by ></ dbaccess > </ section > </ report > 指定的XPath是一个点号,表示当前节点本身,由于当前节点是XML元素,因此也就输出元素的文本内容,相当于输出XmlElement的InnerText 属性值。 转载于:https://www.cnblogs.com/meilibao/archive/2012/09/15/2686120.html