【发布时间】:2009-10-12 06:20:30
【问题描述】:
我的问题是在执行 xlst 文件后,我在一行中得到了文本输出,但不是所需的 xml。我的xml和xslt文件如下。
<root>
<Jobs Found="10" Returned="50">
<Job ID="8000000" PositionID="600002">
<Title>Development Manager</Title>
<Summary>
<![CDATA[ An experienced Development Manager with previous experience leading a small to mid-size team of developers in a Java/J2EE environment. A hands on role, you will be expected to manage and mentor a team of developers working on a mix of greenfield and maintenance projects.   My client, a well known investment bank, requires an experienced Development Manager to join their core technology team. This t
]]>
</Summary>
<DateActive Date="2009-10-06T19:36:43-05:00">10/6/2009</DateActive>
<DateExpires Date="2009-11-05T20:11:34-05:00">11/5/2009</DateExpires>
<DateUpdated Date="2009-10-06 20:12:00">10/6/2009</DateUpdated>
<Location>
<Country>xxxx</Country>
<State>xxx</State>
<City>xxx</City>
<PostalCode>xxx</PostalCode>
</Location>
<CompanyName>abc Technology</CompanyName>
<BuilderFields />
<DisplayOptions />
<AddressType>1234</AddressType>
</Job>
</Jobs>
</root>
XSLT 样式表:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" media-type="application/xml"
cdata-section-elements="Summary"/>
<!-- default: copy everything using the identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- override: for Location and Salary nodes, just process the children -->
<xsl:template match="Location|Salary">
<xsl:apply-templates select="node()"/>
</xsl:template>
<!-- override: for selected elements, convert attributes to elements -->
<xsl:template match="Jobs/@*|Job/@*">
<xsl:element name="{name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<!-- override: for selected elements, remove attributes -->
<xsl:template match="DateActive/@*|DateExpires/@*|DateUpdated/@*"/>
</xsl:stylesheet>
文本中的当前输出是:
492 50 83000003 61999998 市场领先的公司,新设立的职位 具有责任、可见性和机会的高调职位 必须具有在 SDLC 环境中磨练的扎实 BA 技能 市场领先的公司,新设立的职位 具有责任的高调职位,可见性和机会必须在 SDLC 环境中磨练扎实的 BA 技能 我的客户是市场领导者,他将继续从 2009 年 10 月 5 日 2009 年 11 月 4 日 2009 年 10 月 5 日到 2009 年澳大利亚新南威尔士州悉尼 2000 年技能探索 90,000.00 120,000.00 每年 6 澳元
我想要在 xml 中的这个输出。请帮助我找到解决方案。
【问题讨论】:
-
我建议你阅读 StackOverflow 的标记。您的 XML 不可见。
-
您的 XML 无效 -
标签永远不会关闭.....
标签: xslt