[Solved] template condition is not matching [closed]

See http://www.w3.org/TR/xquery-operators/#func-contains, it says about the contains function: “If the value of $arg2 is the zero-length string, then the function returns true.”. You could however check <xsl:when test=”contains(./content-style[1],”https://stackoverflow.com/”) and not(matches(substring-before(./content-style[1],”https://stackoverflow.com/”),’ ‘)) and not(./@align)”> 3 solved template condition is not matching [closed]

[Solved] XML XSLT transformation

**<?xml version=”1.0″ encoding=”UTF-8″?> <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:template match=”https://stackoverflow.com/”> <xsl:element name=”document”> <xsl:apply-templates select=”bill”/> </xsl:element> </xsl:template> <xsl:template match=”//docTitle”> <para format=”6655″ loc=”05″> <xsl:apply-templates/> </para> </xsl:template> <xsl:template match=”//officialTitle”> <para format=”66554″ loc=”11″> <xsl:apply-templates/> </para> </xsl:template> <xsl:template match=”//enactingFormula”> <para format=”6501″ loc=”20″> <xsl:apply-templates/> </para> </xsl:template> <xsl:template match=”//section”> <para format=”6501″ loc=”46″> <xsl:apply-templates/> </para> </xsl:template> <xsl:template match=”num[parent::section]”> <xsl:text>&lt;?xpp fv;1?&gt;</xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match=”heading[parent::section]”> <xsl:text>&lt;?xpp … Read more

[Solved] Separate duplicates from unique

If I understand correctly your explanation, you want to do something like: XSL 1.0 <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output method=”xml” version=”1.0″ encoding=”UTF-8″ indent=”yes”/> <xsl:key name=”cust-by-charge” match=”Customer” use=”chargeto” /> <xsl:template match=”/CustomerRecord”> <Root> <Customer_PO> <xsl:copy-of select=”Customer[count(key(‘cust-by-charge’, chargeto)) > 1]”/> </Customer_PO> <Customer_Falty> <xsl:copy-of select=”Customer[count(key(‘cust-by-charge’, chargeto)) = 1]”/> </Customer_Falty> </Root> </xsl:template> </xsl:stylesheet> Possibly there’s a more elegant approach that would … Read more

[Solved] How to do this xml elimination based on node attribute positions using XSLT ? [closed]

Here is one approach. You define a key to group your items you are looking to remove. I think you are grouping by the @id attribute of the element, together with the @id attribute of the two parent nodes <xsl:key name=”items” match=”*[@method != ”]” use=”concat(@id, ‘|’, ../@id, ‘|’, ../../@id)” /> Next, you could have a … Read more

[Solved] I need to add a text value to an self closing empty tag, using XSLT

You need an identity transformation template: <xsl:template match=”@*|node()”> <xsl:copy> <xsl:apply-templates select=”@*|node()”/> </xsl:copy> </xsl:template> plus a template for the name tag: <xsl:template match=”name[not(node())]”> <name>UNK</name> </xsl:template> Wrap this within the stylesheet tag, and add an xml header: <?xml version=”1.0″ encoding=”ISO-8859-1″?> <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:template match=”@*|node()”> <xsl:copy> <xsl:apply-templates select=”@*|node()”/> </xsl:copy> </xsl:template> <xsl:template match=”name[not(node())]”> <name>UNK</name> </xsl:template> </xsl:stylesheet> 11 solved … Read more

[Solved] Create a dynamic XSL and generate html

I don’t think you need grouping for your Alert issues. It looks like you simply want to output Alert issues which are referenced by “Item/Issue” records. So, what you can do, is define a key like to look up “Item/Issue” records by id. <xsl:key name=”issue” match=”report:Item/report:Issue” use=”@Id”/> Then, to get only Alert elements with referenced … Read more

[Solved] XLST – Copy XML tag and replace attribute value [closed]

XSLT based solution. Input XML <config> <connection port=”4404″ type=”tcp”> <selection name=”test-mode” enabled=”true”/> </connection> <connection port=”4405″ type=”tcp”> <selection name=”test-mode” enabled=”true”/> </connection> <connection port=”4406″ type=”tcp”> <selection name=”test-mode” enabled=”true”/> </connection> <option> <maxNumberOfDownloads>10</maxNumberOfDownloads> </option> </config> XSLT <?xml version=”1.0″?> <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output method=”xml” encoding=”utf-8″ indent=”yes” omit-xml-declaration=”yes”/> <xsl:strip-space elements=”*”/> <xsl:template match=”@*|node()”> <xsl:copy> <xsl:apply-templates select=”@*|node()”/> </xsl:copy> </xsl:template> <xsl:template match=”connection[@port]”> <xsl:copy> <xsl:apply-templates … Read more

[Solved] Group Similar nodes in XML using XLST

This is a pretty straightforward grouping problem. If you’re limited to XSLT 1.0, you need to use Muenchian Grouping. If you’re using XSLT 2.0+, you can use xsl:for-each-group. Examples… XSLT 1.0 <xsl:stylesheet version=”1.0″ xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”> <xsl:output indent=”yes”/> <xsl:strip-space elements=”*”/> <xsl:key name=”class” match=”text” use=”substring-before(substring-after(normalize-space(@class), ‘ ‘),’ ‘)”/> <!–identity template–> <xsl:template match=”@*|node()”> <xsl:copy> <xsl:apply-templates select=”@*|node()”/> </xsl:copy> </xsl:template> <xsl:template … Read more

[Solved] XSLT – XSD files – Where to find the schema.xsd file – Please suggest

You can find the XML Schema for Schemas here. However, you probably do not need it unless you’re trying to validate an XSD (as opposed to validating an XML document instance with against an XSD). See also: xmlns, xmlns:xsi, xsi:schemaLocation, and targetNamespace? How to link XML to XSD using schemaLocation or noNamespaceSchemaLocation? Must an XML … Read more

[Solved] How to parse complex and recurssive xml file having size 1GB and store it in csv using xslt

I couldn’t quite work out your logic but I think you may benefit from using a key here to look up the SecDef element using its MktSegGrp attribute value <xsl:key name=”MktSeg” match=”SecDef” use=”MktSegGrp/@MktSegID” /> So, for a given MktDef, you would get the SecDef elements for it like so <xsl:variable name=”secDef” select=”key(‘MktSeg’, @MktSegID)” /> Try … Read more

[Solved] Merge different products belong to each standard – V2 [duplicate]

This XSLT will do the thing: <xsl:stylesheet xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:x=”http://ws.wso2.org/dataservice” xmlns=”http://ws.wso2.org/dataservice” exclude-result-prefixes=”x” version=”1.0″> <xsl:output indent=”yes” method=”xml” /> <xsl:template match=”x:Standards”> <Standards namespace=”{namespace-uri()}”> <xsl:apply-templates select=”.//x:Standard” /> </Standards> </xsl:template> <xsl:template match=”x:Standard”> <Standard> <xsl:copy-of select=”x:ProductID” /> <xsl:copy-of select=”x:Prefix”/> <xsl:copy-of select=”x:SNumber”/> <RelatedProducts> <xsl:apply-templates select=”.//x:RelatedProduct”/> </RelatedProducts> <xsl:copy-of select=”x:S1″/> <xsl:copy-of select=”x:S2″/> </Standard> </xsl:template> <xsl:template match=”x:RelatedProduct”> <xsl:element name=”RelatedProduct”> <xsl:element name=”RelationType”> <xsl:value-of select=”name(..)” /> </xsl:element> … Read more

[Solved] XML to HTML table using XSL

Just as a different approach and also handling the colours for the same bus_types.Demo <?xml version=”1.0″?> <xsl:stylesheet xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” version=”1.0″> <xsl:output method=”html”/> <xsl:template match=”https://stackoverflow.com/”> <table> <tr> <td colspan=”9″>ACME BUS SERVICE</td> </tr> <tr> <td colspan=”9″> Month: <xsl:value-of select=”//Month”/> </td> </tr> <tr> <td>Season</td> <td>Location</td> <td>Bus Name</td> <td colspan=”2″>RED</td> <td colspan=”2″>GREEN</td> <td colspan=”2″>BLUE</td> </tr> <tr> <td></td> <td></td> <td></td> <td>Bus … Read more