我在用lxml解析自己写的xslt文件,将源文件转换成另一种xml格式,但是转换的结果出现了一行没有带标签的。
感觉是自己的xslt文件出来问题了,但是不知道是哪里有问题,求大神帮忙!
源文件截图:
要提取的是concept下title和shortdesc里面的内容
我写的xslt文件:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:variable name="x" select="concept/shortdesc"/>
<xsl:template match="concept/title">
<category>
<pattern><xsl:value-of select="."/></pattern>
<template><xsl:value-of select="$x"/></template>
</category>
</xsl:template>
<xsl:template match="conbody">
<xsl:for-each select="section">
<category>
<pattern><xsl:value-of select="title"/></pattern>
<template><xsl:value-of select="p"/></template>
</category>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>