2017-01-09 2 views
0

XSLTを使ってタグのテキストをタグ名に入れる方法を教えてもらえますか?XMLテキストをタグに変換するには?

XML:

<a> 
    Some topic: 
</a> 
<b> 
    Some text on the topic. 
</b> 

必要な結果:

このXMLを考える
<Some_topic> 
    Some text on the topic. 
</Some_topic> 

答えて

3

<xml> 
<a> 
    Some topic: 
</a> 
<b> 
    Some text on the topic. 
</b> 
</xml> 

このXSLを使用私はあなたの宿題-haヘクタール

に何を得るIグレードを知ってみましょう

<?xml version="1.0" encoding="UTF-16"?> 
<Some_topic> 
    Some text on the topic. 
</Some_topic> 

を生成するために

<?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> 

関連する問題