XSLT transformation with indexed xpath not working.
Unsolved
General and Desktop
-
Hi,
I need to change some xml files, first I try to solve it with xslt, but it seems to not working perfectly.
I have the following xml file:
<t> <property>value1</property> <property type="old">value2</property> <property type="old">value3</property> <property type="old">value4</property> </t>
I want to change the type of the second propery with the following xslt transformation:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:param name="pNewType" select="'newtype'"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy ></xsl:template> <xsl:template match="property[2]/@type"> <xsl:attribute name="type"> <xsl:value-of select="$pNewType"/> </xsl:attribute> </xsl:template> </xsl:stylesheet>
This xslt code worked well with xlstproc and several online tools, but not work with qt. (It works well when I use it without index, its change every attribute, so I think the xslt sytlesheet is correct).
XmlQuery.isValid() returns true, and result is same as input xml.
As the output of the transformation i want to see the following:
<t> <property>value1</property> <property type="newtype">value2</property> <property type="old">value3</property> <property type="old">value4</property> </t>
What can be the problem?
-
Hi and welcome to devnet,
You should provide a minimal compilable example that shows your issue. That way people will be able to analyse what is happening.