Jump to content

arfo

Members
  • Posts

    5
  • Joined

  • Last visited

arfo's Achievements

Newbie

Newbie (1/7)

2

Reputation

  1. I am trying to achieve the following. All FUNCTION-CONNECTORS nodes are placed under the correct "parent" - OKAll other elements under CONNECTORS shall remain - OKAll attributes under FUNCTION-CONNECTOR shall remain except for @ParentDFT - Fail How do I do that? <xsl:template match="CONNECTORS"> <xsl:variable name="DFTuuid" select="../@UUID"/> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="//FUNCTION-CONNECTOR[@ParentDFT=$DFTuuid]"/> </xsl:copy></xsl:template>
  2. I have a XML file where some of the elements appear in the incorrect place. In the example the attribute @ParentDFT tells which parent DESIGN-FUNCTION-TYPE a FUNCTION-FLOW-PORT belongs to. I want to perform transformation so that "Visiting" is moved from the "Host" to the "ChildMissing" parent. <ELEMENTS> <DESIGN-FUNCTION-TYPE UUID="DFT101"> <SHORT-NAME>Host</SHORT-NAME> <PORTS> <FUNCTION-FLOW-PORT ParentDFT="DFT101" UUID="FFP101-1"> <SHORT-NAME>AtHome</SHORT-NAME> <DIRECTION>OUT</DIRECTION> </FUNCTION-FLOW-PORT> <FUNCTION-FLOW-PORT ParentDFT="DFT102" UUID="FFP102-1"> <SHORT-NAME>Visiting</SHORT-NAME> <DIRECTION>OUT</DIRECTION> </FUNCTION-FLOW-PORT> </PORTS> </DESIGN-FUNCTION-TYPE> <DESIGN-FUNCTION-TYPE UUID="DFT102"> <SHORT-NAME>ChildMissing</SHORT-NAME> <PORTS> </PORTS> </DESIGN-FUNCTION-TYPE></ELEMENTS> I have partly managed to achieve the goal with the following XSLT: [<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/xhtml1/strict" version="1.0"><!-- <xsl:strip-space elements="doc chapter section"/> --><xsl:output method="xml" indent="yes" encoding="UTF-8"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy></xsl:template> <xsl:template match="DESIGN-FUNCTION-TYPE"> xsl:variable name="DFTuuid" select="@UUID"/> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="SHORT-NAME"/> <xsl:apply-templates select="//FUNCTION-FLOW-PORT[@ParentDFT=$DFTuuid]"/> </xsl:copy></xsl:template> </xsl:stylesheet> Problem is that the PORTS element is lost.If I add <xsl:apply-templates select="PORTS"/> the complete PORTS element appears (including all the FUNCTION-FLOW-PORTS) How do I get the PORTS element back in the correct place?
×
×
  • Create New...