Search the Community
Showing results for tags 'xslt'.
-
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?
-
Hi all,I have this XSLT: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/><xsl:template match="/"><xsl:apply-templates select="//prime"/></xsl:template> <xsl:template match="prime"> <xsl:apply-templates select="note[@style='tt']" /> </xsl:template> <xsl:template match="note/rss/channel"> <xsl:apply-templates select="item"></xsl:template><xsl:template match="item"><item> <title> <xsl:value-of select="title"/> </title> <description> <xsl:value-of select="description"/> </description> <pubDate> <xsl:value-of select="pubDate"/> </pubDate></item></xsl:template><xsl:template match="prime"> <xsl:apply-templates select="note[@style='sms']" /> </xsl:template> <xsl:template match="note/rss/channel"> <xsl:apply-templates select="item"></xsl:template><xsl:template match="item"><item> <title> <xsl:value-of select="title"/> </title> <pubDate> <xsl:value-of select="pubDate"/> </pubDate></item></xsl:template></xsl:stylesheet> I want to show note type =tt and note type = sms in the same page because the content of each type is different, the problem with this xslt is that the note type sms is overwritting the note type = tt, in other words, it's only showing the note type= sms. How can I solve this... Thanks all