使用XSLT实现XML到XML的转换
我需要使用XSLT从一种XML格式更改为另一种格式。我有如下类似的XML使用XSLT实现XML到XML的转换,xml,xslt,Xml,Xslt,我需要使用XSLT从一种XML格式更改为另一种格式。我有如下类似的XML <Class xmlns="http://www.test.com/"> <student id='1'> <firstname>James</firstname> <lastname>Chistoper</lastname> <age>35</age> <dob>08/11/1982</dob> <
<Class xmlns="http://www.test.com/">
<student id='1'>
<firstname>James</firstname>
<lastname>Chistoper</lastname>
<age>35</age>
<dob>08/11/1982</dob>
</student>
</Class>
詹姆斯
回采机
35
08/11/1982
我想删除年龄和出生日期,还需要删除学生id。最终的xml应该是这种格式
<Class xmlns="http://www.test.com/">
<student>
<firstname>James</firstname>
<lastname>Chistoper</lastname>
</student>
</Class>
詹姆斯
回采机
谁能给我一个实现它的建议吗。我尝试了许多xslt无法实现的功能。提前感谢:)试试这个:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:a="http://www.test.com/"
version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="a:student/@id|a:age|a:dob" />
</xsl:stylesheet>
请参见上的转换显示您编写的XSL脚本,并指出您在编码方面的具体问题。到目前为止,您编写了哪些XSL?请访问并阅读,当您在代码中遇到不理解的内容时,您需要自己努力并询问。如果您只想删除一些元素,只需编写一个标识转换(在Wikipedia上查找),并为要删除的元素添加空模板