Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. XSLT transformation with indexed xpath not working.
Forum Updated to NodeBB v4.3 + New Features

XSLT transformation with indexed xpath not working.

Scheduled Pinned Locked Moved Unsolved General and Desktop
xmlxsltxpath
2 Posts 2 Posters 510 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    baratiistok3
    wrote on 12 Nov 2022, 21:05 last edited by baratiistok3 11 Dec 2022, 21:06
    #1

    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?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 Nov 2022, 20:30 last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      2/2

      13 Nov 2022, 20:30

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved