Я пытаюсь удалить узел, но вставлять содержимое в узел предков. Это XML:XSLT Удалить узел, но сохранить содержимое
<w lemma="comment2" type="adv." ana="comment">comment</w>
<name ref="roland"><w lemma="roland" type="nom propre" ana="roland">roland</w></name>
<w lemma="faire" type="vindps3" ana="fyt"><choice><orig>fyt</orig><reg>fist</reg></choice></w>
<name ref="yvon de montauban"><w lemma="yvon" type="nom propre" ana="yvon">yvon</w>
<w lemma="de" type="prép" ana="de">de</w>
Мое желание удалить completedly <reg>
и его содержимое, чтобы удалить тег <choice>
и удалить тег <orig>
НО поместить его содержимое в <w>
тега. Может кто-нибудь, пожалуйста, помогите мне?
XSLT является сейчас, как это:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:output method="xml"/>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:for-each select="./@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="div">
<xsl:element name="{local-name()}">
<xsl:for-each select="./@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="s">
<xsl:element name="{local-name()}">
<xsl:for-each select="./@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="name">
<xsl:element name="{local-name()}">
<xsl:for-each select="./@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="pb">
<xsl:choose>
<xsl:when test="@ed='bnf'">
<xsl:element name="{local-name()}">
<xsl:for-each select="./@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="w">
<xsl:choose>
<xsl:when test="descendant::orig">
<xsl:element name="w">
<xsl:for-each select="./@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:when>
<xsl:when test="descendant::reg">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:element name="w">
<xsl:for-each select="./@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="choice"/>
<xsl:template match="orig">
<xsl:apply-templates select="*" />
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="reg"/>
</xsl:stylesheet>
Спасибо за вашу помощь :) Михи
Мое желание удалить completedly REG-тег и его содержимое, чтобы удалить выбор-теги и удалить Orig-тег НО поместить его содержимое в w-tag. – Micha
Ваш XML не является корректным. Вы не представили ожидаемый результат. Пожалуйста, обновите свой вопрос. –