如何将XML文本转换为标记?
有人能告诉我如何使用XSLT将标记中的文本转换成标记名吗 XML:如何将XML文本转换为标记?,xml,xslt,Xml,Xslt,有人能告诉我如何使用XSLT将标记中的文本转换成标记名吗 XML: <a> Some topic: </a> <b> Some text on the topic. </b> <Some_topic> Some text on the topic. </Some_topic> 一些话题: 关于这个主题的一些文本。 需要的结果: <a> Some topic: </a>
<a>
Some topic:
</a>
<b>
Some text on the topic.
</b>
<Some_topic>
Some text on the topic.
</Some_topic>
一些话题:
关于这个主题的一些文本。
需要的结果:
<a>
Some topic:
</a>
<b>
Some text on the topic.
</b>
<Some_topic>
Some text on the topic.
</Some_topic>
关于这个主题的一些文本。
给定此XML
<xml>
<a>
Some topic:
</a>
<b>
Some text on the topic.
</b>
</xml>
一些话题:
关于这个主题的一些文本。
使用这个XSL
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name='element' select="translate( normalize-space( /xml/a ), ' :', '_')"/>
<xsl:element name='{$element}'>
<xsl:value-of select='/xml/b'/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
产生
<?xml version="1.0" encoding="UTF-16"?>
<Some_topic>
Some text on the topic.
</Some_topic>
关于这个主题的一些文本。
让我知道我在你的家庭作业中得到了什么分数-哈哈
<xml>
<a>
Some topic:
</a>
<b>
Some text on the topic.
</b>
</xml>
一些话题:
关于这个主题的一些文本。
使用这个XSL
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name='element' select="translate( normalize-space( /xml/a ), ' :', '_')"/>
<xsl:element name='{$element}'>
<xsl:value-of select='/xml/b'/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
产生
<?xml version="1.0" encoding="UTF-16"?>
<Some_topic>
Some text on the topic.
</Some_topic>
关于这个主题的一些文本。
让我知道我在你的家庭作业中得到了什么分数-哈哈