You need to think of this as two separate changes, rather than a single "move" 1) Remove the Weight attribute for the Order element. Or rather, do not copy the Weight attribute to the output <xsl:template match="@Weight" /> 2) Add a Weight attribute to the Item element when copying it...
java,performance,jaxb,xslt-1.0
From the performance perspective, of course it is not optimal: serialization to xml, transformation of the xml, deserialzation from the xml are costly operations. But, it sometimes makes sense, if you have a lot of 'similar' classes (for example different field names but matching logic (for example one having user...
Strictly speaking, you actually be getting an error when you run the output, as because MathiasMuller says in comments, xsl:element must not be a top-level element (i.e it cannot be a direct child of xsl;stylesheet). I am guessing Ecplise may just be ignoring that. If you are, however, getting only...
You can use this: <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="p"> <xsl:copy> <xsl:value-of select="normalize-space(.)"/> </xsl:copy> </xsl:template> </xsl:stylesheet> ...
It was quite challenging.... Here's my XSLT; please note that your XSL processor must support XSLT extensions (exslt) -- if you're using Xalan or Saxon, it will be OK. Basically, we had to process the Container one after another, and adding information about the Totals already computed. This is done...
How about a simple: <xsl:template match="/AUTHENTICATOR"> <xsl:copy> <xsl:copy-of select="LOGINID | DATE | USERTOKEN"/> <USERINFO> <field name="FirstName" value="{USERINFO/field[@name='First']/@value}"/> <field name="LastName" value="{USERINFO/field[@name='Last']/@value}"/> <field name="Email" value="{USERINFO/field[@name='mail']/@value}"/> </USERINFO> </xsl:copy> </xsl:template> ...
xml,performance,xslt,xpath,xslt-1.0
The only possible answer to this question is "it depends on the processor". As a rule you should avoid using // un-necessarily, but a clever processor may be able to optimise simple //something absolute paths (e.g. using a hash table to look up nodes by name) to be faster than...
java,xslt,namespaces,xslt-1.0,saxon
The problem here is that you are changing the namespace on pref:sub1, but not on any of the other pref: elements. You need something more general: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:oldPref="http://www.myMountain.org/blabla" xmlns:pref="http://www.myHill.org/blabla" exclude-result-prefixes="oldPref"> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="oldPref:*">...
xslt,sharepoint,sharepoint-2010,xslt-1.0,dataviewwebpart
As mentioned in the comments, the if () then else construct is only supported in XSLT/XPpath 2.0. My own preference would be to use the verbose, but readable: <xsl:template match="some-node"> <div> <xsl:attribute name="ID"> <xsl:choose> <xsl:when test="string(@ID)"> <xsl:value-of select="@ID"/> </xsl:when> <xsl:otherwise>default</xsl:otherwise> </xsl:choose> </xsl:attribute> </div> </xsl:template> or perhaps a shorter: <xsl:template match="some-node">...
If you are combining Document elements with the same language within a single Query, then you probably only need one key here <xsl:key name="Document" match="Document" use="concat(../../ID, '+', Language)"/> Then you get the distinct Document elements like so: <xsl:template match="Document[generate-id() = generate-id(key('Document', concat(../../ID, '+', Language))[1])]"> Then, for each child node of...
One thing I would like to apply is following: If Status in the account_data is = 5 then take the account id in the same line. I believe you mean: <xsl:value-of select="/notification/data/admin/input/request_set/request/update/account_data[@Status='5']/@id"/> This will return the id of the (first) account_data whose Status is 5 ("3615734" in your example)....
but the result of the third message is blank. The result is blank, because: str:split($A,$fileDateSplitChar)[last()] returns "xml", and: substring-before('xml, 'xml')" returns an empty string. What I was trying to achieve is to extract the part of the file CCYYMMDD. I am assuming you don't know the ordinal position of...
You can easily achieve this with a substring. <xsl:value-of select="substring-after(string(../fpml:floatingRateIndex), '-')"/> This will return everything after the first -....
If you want to have only unique Scott values within each Group, and only unique Minor values within each Scott subgroup, then yes, you will need three keys. And if the values by which you want to subgroup are not unique to each parent group, then the keys will have...
It's quite hard to follow your question, and there seems to be some typos in your XML, XSL, but here goes... I assume your XML input document that you are trying to translate is: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <MyRequest> <ns:Details xmlns:ns="www.newschema"> <ID>123</ID> <Name> <FirstName>John</FirstName> </Name> </ns:Details> </MyRequest> </soapenv:Body>...
This is exactly the same situation as in your previous question - you're comparing against the (non-empty) string ' ' containing a single space, when what you actually want is to check for empty strings. And you can use the same solution as I suggested for that question, and test...
First of all, your xml and xslt files have 2 issues (as several commentors have pointed out): (xml): The & needs to be encoded: &. (xslt): Attribute names mustn't contain whitespace ( exclude-result-prefixes="msxsl" in the root element ) Back to the problem at hand: One of the default templates seems...
xml,xslt,xslt-1.0,xslt-grouping,muenchian-grouping
I think your code does correctly group the item elements by their name child elements. You also seem to want to eliminate duplicate child elements, I am not sure whether you want to do that by element name only or by element name and element contents. If you want to...
If you make your second template: <xsl:template match="*[not (node() or self::ty or self::mt_in)]"> <xsl:copy> <xsl:value-of select="'NO'"/> </xsl:copy> </xsl:template> you will get the following result: <?xml version="1.0" encoding="UTF-8"?> <request> <event> <st1>ky</st1> <st2>de</st2> <st3>NO</st3> <st4>NO</st4> <st5>NO</st5> <ty> <st_in> <stno>1</stno> <stid>NO</stid> </st_in>...
sorting,xslt,attributes,xslt-1.0,alphabetical
I am not entirely sure if this meets your requirements, but you could explicitly select the ones you want to come first in a separate xsl:apply-templates, then select the others with a sort on their type attribute <xsl:apply-templates select="orderEntry[@type='specific' or @type='other']" /> <xsl:apply-templates select="orderEntry[@type!='specific' and @type!='other']"> <xsl:sort select="@type" order="descending" />...
One way to achieve this to use a key, to group the non-header elements by their first preceding header element <xsl:key name="type" match="*[not(self::header)]" use="generate-id(preceding-sibling::header[1])" /> You would then start off by selecting just header elements <xsl:apply-templates select="header" /> And within the template that matches this header element, you can then...
Try it this way? <xsl:template match="/Data"> <Imdb> <xsl:for-each select="Movie"> <Film> <xsl:copy-of select="writer"/> </Film> </xsl:for-each> </Imdb> </xsl:template> I don't know what you mean by: I need to achieve the above mentioned task only with for each loop or for each group by loop. Surely you want to achieve the above task...
I know nothing about SharePoint, I can only help you with the XSLT part. Once you have an XML document such as: XML <root> <Item> <Name>Test1</Name> <ID>1</ID> <ParentID>0</ParentID> </Item> <Item> <Name>Test2</Name> <ID>2</ID> <ParentID>0</ParentID> </Item> <Item> <Name>Test2.1</Name> <ID>3</ID> <ParentID>2</ParentID> </Item> <Item> <Name>Test2.1.1</Name>...
You want to check if you are a last <Item>, if so then add the invisible row. <xsl:if test="not(following-sibling::Item)"> <tr class="tdNewDesign" style="display: none;"> <td>A</td> <td>B</td> <td>C</td> <td>D</td> </tr> </xsl:if> ...
Your test always returns true, because you are comparing two node-sets - and such test returns true if one of the nodes in set A matches a node in set B. The result is always "CONCENTRATE" because <xsl:value-of select="//i:materials/i:material/i:name"/> returns the value of the first node of the set matching...
@lingamurthy, Just <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:strip-space elements="*"/> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="Code[. = preceding-sibling::Code]"/> </xsl:stylesheet> ...
As Ian commented, substring-before and substring-after can handle this for you: This XML: <coordinates>-3.166610, 51.461231</coordinates> Given to this XSLT transformation: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="coordinates"> <xsl:copy> <latitude> <xsl:value-of select="normalize-space(substring-before(., ','))"/> </latitude>...
Did you try with : replaceAll("\\n","") And escapeJava() is not what you need, you need is unescapeJava() but like it says in the javadoc : Unescapes any Java literals found in the String. For example, it will turn a sequence of '\' and 'n' into a newline character, unless the...
xslt,xml-parsing,xslt-1.0,xslt-2.0
As per the error, it looks like you are using unsupported version of validation engine. Please choose Saxon-HE/PE/EE 9.5.1.7 instead of Saxon6.5.5 If you are using eclipse or Oxygen editor, you can find this settings under preferences > XML > XSLT-FO-XQuery. In Oxygen editor, you can choose engine from drop-down...
It could be done with grouping, it can also be done with preceding-sibling. I would note that you say "dozens" ... I would not worry about using grouping. I ran this sample with 2000 rows, execution is 2.3 seconds (in debugging mode in oXygen with Saxon), 0.1 seconds without debugging....
There is no xsl:value in XSLT. The instruction is called xsl:value-of. Stylesheet <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl ="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <table border="1"> <tr> <th>Ime</th> <th>Grad</th> </tr> <xsl:for-each select="forma/unos"> <tr> <th> <xsl:value-of select="ime"/> </th> <th> <xsl:value-of select="grad"/> </th>...
This is because of XSLT's built-in template rules. Since you're using xsl:value-of in your e:cd template you can just add this template: <xsl:template match="text()"/> Another alternative is to narrow the scope of what you're processing: <xsl:template match="/"> <xsl:apply-templates select="e:root/e:cds"/> </xsl:template> Also, unless you're creating an element name dynamically, there's no...
html,xml,xslt,transform,xslt-1.0
This is a classic case for using keys: XSLT 1.0 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="utf-8" indent="yes"/> <xsl:key name="allowed-link" match="allowedlinks/link" use="@name" /> <xsl:key name="link-by-parent" match="link" use="@parent" /> <xsl:template match="/content"> <ul> <xsl:apply-templates select="data/navigation/link[not(@parent) and key('allowed-link', @name)]"/>...
Try: <xsl:template match="class[id='123']/duration"> <xsl:copy> <xsl:text>abc</xsl:text> </xsl:copy> </xsl:template> or: <xsl:template match="duration[../id='123']"> <xsl:copy> <xsl:text>abc</xsl:text> </xsl:copy> </xsl:template> instead of: <xsl:template match="id[text()='123']"> <xsl:copy> <xsl:if test="count(following-sibling::duration) or count(preceding-sibling::duration)"> <xsl:text>abc</xsl:text> </xsl:if>...
The collapsible tree format is simply the way a browser displays XML files that don't have any stylesheet associated with them. When you ask a browser to apply a stylesheet the browser (quite rightly) assumes that the purpose of the stylesheet is to transform the input XML into something that...
As stated in the comments for other members, max simply could be used as is without the need of xslt sort and xslt for-each. To be able to use the xsl in xsl as is, here is a simple piece of code to try: <xsl:variable name="the_max"> <xsl:for-each select="Node/Item/year"> <xsl:sort data-type="number"...
If it can be assumed that the Root element always contains exactly 2 Story elements, one with the Q&As and one with the correct answers, then you could do simply: XSLT 1.0 <?xml version="1.0" encoding="UTF-8"?> <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:strip-space elements="*"/> <!-- identity transform --> <xsl:template...
You can try this way : <xsl:value-of select="sum(../i:issue[i:issueBatchNumber=$thisBatchId]/i:dispenseDurationInSeconds)"> above xpath return sum of all dispenseDurationInSeconds from parent issue elements having child issueBatchNumber equals current $thisBatchId value....
java,find,xslt-1.0,filenames,zsh
Here's a zsh approach, since it's tagged it as such. for f in **/*.foo(.); print -- java ... -o $f:r.bar $f Remove the print -- when you're satisfied that it looks good. The (.) says files only. The :r says remove the .foo extension. It's helpful to remember the path...
You can sort first into a variable (which then in XSLT is a result tree fragment), then you can use an extension function like exsl:node-set to convert your result tree fragment into a node-set to be processed further with your existing code. So you need two changes, the template for...
Here's a small stylesheet that will lead you to the expected result. <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="*[contains(name(), 'a')]/*[contains(name(), 'a')] | /*[contains(name(), 'a')]"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates /> </xsl:copy> </xsl:template> <xsl:template match="*"> </xsl:template> </xsl:stylesheet> However I think it's not really clearly stated for the...
Lets make this generic - we want $rows rows of $cols cards each per page, and on the answer side each row needs to be printed in reverse order. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:param name="rows" select="2" /> <xsl:param name="cols" select="2" /> <xsl:variable name="pageSize" select="$rows * $cols" /> <xsl:template match="/"> <html> <body>...
Perhaps it would be better to use a key for this, especially if there are many different RandomNode elements that you want to use for the lookup. Also, no need for named templates or parameters. XSLT Stylesheet The template match for Item can of course be changed to match="*[@Type='SomeUniqueType']" if...
Your question does not show any effort whatsoever, and you do not show any code you might have attempted already. However, I am feeling generous today, use the stylesheet below. XSLT Stylesheet As suggested by Michael already, use Muenchian grouping to identify unique nodes. Define a key that finds unique...
The matches function requires XPath 2.0 (and hence XSLT 2.0) or later, there's no regular expression support in XSLT 1.0. If you just want to check that the value ends with ".mov" you can do that using the substring function substring(@data, string-length(@data) - 3) = '.mov' (XPath 1.0 has starts-with...
<xsl:variable name="max_a_width"> <xsl:for-each select="data"> <xsl:sort select="string-length(@a)" data-type="number" /> <xsl:if test="position() = last()"> <xsl:value-of select="string-length(@a)" /> </xsl:if> </xsl:for-each> </xsl:variable> This is the general method of picking from an ordered list of derived values in XSLT 1.0. If you want to pick the minimum/maximum from actual (natively sortable) values, you can take...
At this time I use xsl:template with match=w:tr[contains(.//w:t,'dataIdentifier')] Try instead: <xsl:template match="w:tr[.//w:t[contains(., 'dataIdentifier')]]"> -- Note: if the full path to w:t is known, it would be better to state it explicitly: <xsl:template match="w:tr[w:tc/w:p/w:r/w:t[contains(., 'dataIdentifier')]]"> ...
Muenchian grouping, i.e. (Just typed in without syntax checking, but should sthg. like this.) create a compound index for CIFContactReference, sth. like (I used to add a foreign character, say '_', for separation of keys, when no. and id are variable length and merge may be duplicated.) then make a...
xslt,svg,xslt-1.0,muenchian-grouping
You've got the Muenchian grouping logic right, but the template wrong - your apply-templates selects product elements: <xsl:apply-templates select="order/product[generate-id(.)=generate-id(key('group-by-product',.)[1])]" /> but your second template matches order elements so it will never fire. You need to change it to something like <xsl:template match="product"> <xsl:variable name="y" select="sum(key('order-by-product',.)/@amount)"/> <svg:rect x="{40 * position()+20}" y="{$baseline...
I don't want the result in form of XML nodes, I do want the result on the same line. If you want to sort the values, you must tokenize them into nodes first. Then sort the nodes and output them back as text values in a single line: XSLT...
I would define the first key as <xsl:key name="key_group_by_master" match="root/*" use="id_master"/> and the second then needs to concatenate the master key with the slave key e.g. <xsl:key name="slave" match="root/*" use="concat(id_master, '|', id_x | id_y)"/> the inner for-each then needs to be <xsl:for-each select="//*[generate-id(.)=generate-id(key('slave', concat(id_master, '|', id_x | id_y))[1])]"> That should...
You could change line #10 from: <xsl:for-each select="*"> to: <xsl:for-each select="*[not(@override='false')]"> You didn't post the expected result, so I am not sure it will be to your liking. This could prove much more complicated than it seems, if you need to merge nodes at different levels....
This is so much easier in XSLT 2 but for old time's sake: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:key name="producerkey" match="row" use="PRODUCER/@value"/> <xsl:template match="table"> <table> <thead> <tr> <th>Producer</th> <th>Publication</th> <th>Domestic</th> <th>Foreigh</th> </tr> </thead> <tbody> <xsl:for-each select="row[ generate-id(.) =...
xml,xslt,out-of-memory,xslt-1.0,xslt-2.0
Lingamurthy CS, Please, add the <xsl:strip-space elements="*"/> declaration, which you removed from the original solution. This strips from the source XML document any whitespace-only text node. Not stripping these nodes may significantly increase the number of nodes and the memory to hold them -- in your case, the required memory...
This should work for you, provided that the supplied column names are also valid XML element names: XSLT 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:strip-space elements="*"/> <xsl:variable name="column-names" select="/SearchResults/TableHeader/ColumnName" /> <!-- identity transform --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/>...
xml,string,xslt,substring,xslt-1.0
We do not know where this string comes from, but assuming an input document like XML Input <?xml version="1.0" encoding="UTF-8"?> <input>man START red END woman START child END rabbit START goose END blue</input> XSLT Stylesheet Write a recursive named template that looks for occurrences of START and END in the...
Here's one way: XSLT 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:strip-space elements="*"/> <!-- identity transform --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="collectionDetails"> <xsl:copy> <xsl:apply-templates...
Given these two XML documents: facilities.xml <facilities> <facility code="North">North Building</facility> <facility code="South">South Building</facility> </facilities> XML (this is the document processed by XSLT) <Dailyreport> <msg> <msgdate>05/27/2015</msgdate> <facility>North</facility> <ispass>1</ispass> </msg> <msg> <msgdate>05/27/2015</msgdate> <facility>North</facility>...
All you need is the identity template to copy existing nodes... <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> Then another template to ignore nodes that aren't lower-case. In XSLT 1.0 this can be done by using the translate statement, to translate uppercase letters to lowercase, and checking if the result...
There isn't a "way around it" in XSLT 1.0 - it's exactly how this is supposed to work. When you have a variable that is declared with content rather than with a select then that content is a result tree fragment consisting of newly-created nodes (even if those nodes are...
I figured out where I went wrong. Below is the correct way to write the condition. I had put unnecessary single quotes. <xsl:when test="$IncomingFileSize > $SetFileSize"> ...
It's possible without nodesets. It's not optimal, of course (hello, Shlemiel The Painter), but it's pretty easy - increment counter only if there is no given string ahead or behind. Template <xsl:template name="calcUnique"> <xsl:param name="str"/> <xsl:param name="back"/> <xsl:param name="count"/> <xsl:if test="$str"> <xsl:choose> <xsl:when test="contains($str, ',')"> <xsl:variable name="part" select="substring-before($str, ',')"/> <xsl:call-template...
This transformation: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="EmptyElements" priority="5"> <xsl:copy> <xsl:apply-templates mode="enumerate" select= "../*[not(self::EmptyElements) and not(node())]" />...
The problem you're having is with your xpaths. Your context is client so all paths have to be relative to that. So if you're trying to get the amount attribute of a child transaction, the xpath would be transaction/@amount. However, if you use <xsl:value-of select="transaction/@amount"/> and there are more than...
If I am guessing (!) correctly, you want to do: <xsl:apply-templates select="DriverRights"> <xsl:sort data-type="number" order="descending" select="4*(STAFF/EmpDetails/Type='Lorry ABC') + 2*(STAFF/EmpDetails/Type='SUV IX') + (STAFF/EmpDetails/Type='Jeep')"/> </xsl:apply-templates> ...
Here is an XSLT 1.0 stylesheet adapted to your latest sample where the elements to be grouped are a nesting level further down the tree: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:strip-space elements="*"/> <xsl:output indent="yes"/> <xsl:key name="group" match="/*/*/*/property" use="@name"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy>...
XSLT 1.0 has no concept of dates (and even XSLT 2.0 only recognize dates in ISO-8601 format). So you need to do this in two steps: Convert your dates to a sortable string in the form of YYYMMDDhhmmss. This is further complicated by the necessity to convert 12-hour time to...
You can modify the identity transformation to copy over everything exactly except for the visualChildren/object elements, which can be copied over as-is plus the RefId attribute you request: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template...
It's difficult to provide an answer without seeing the input. I believe you need to do something like the following: XSLT 1.0 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="visualChildren"> <xsl:variable name="bundles"> <xsl:call-template name="create-bundles"> <xsl:with-param name="n" select="4" />...
It is possible but it would have to be a string operation, meaning it might not be possible in some cases if the text is more complex than this. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" exclude-result-prefixes="xs xd" version="2.0"> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="anons"> <ol> <xsl:for-each select="tokenize (./string(),...
I am trying to produce a xsl that will ... replace the attribute ref value with something hardcoded The main problem with your approach is that your second template is never applied, because your first template does not apply any templates. Try it this way: XSLT 1.0 <xsl:stylesheet version="1.0"...
Try it this way: <xsl:variable name="rows" select="2" /> <xsl:template match="/data"> <table> <xsl:for-each select="node[position() <= $rows]"> <xsl:variable name="i" select="position() mod $rows"/> <tr> <xsl:for-each select="../node[position() mod $rows = $i]"> <td><xsl:value-of select="."/></td> </xsl:for-each> </tr> </xsl:for-each> </table> </xsl:template> ...
In this case since it's a straight sum you could just do <xsl:value-of select="sum(item[code=1.1 or code=1.2 or code=1.3.1 or code=1.3.2]/amt)"/> ...
Try this: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="item"> <xsl:if test="not(../item[nbr = current()/nbr and dt > current()/dt])"> <xsl:copy> <xsl:apply-templates /> </xsl:copy> </xsl:if> </xsl:template> <xsl:template match="cnt"> <xsl:copy> <xsl:value-of select="sum(../../item[nbr = current()/../nbr]/cnt)"/> </xsl:copy> </xsl:template> <xsl:template match="@* | node()">...
That's a rather awkward arrangement to have, and the solution - at least in XSLT 1.0 - is no less awkward: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="/car"> <xsl:variable name="local-names"> <xsl:for-each select="*"> <name><xsl:value-of...
I want to position them based on the attribute "num" value how do i do that?? This kind of manipulation is called sorting. Sorting the input elements inside xsl:apply-templates is what you need: <xsl:apply-templates select="name"> <xsl:sort select="@num"/> </xsl:apply-templates> Also, to avoid getting all the text on a single line,...
<xsl:variable name="set" select="'(1.1)(1.2)(2.1)'"/> <xsl:template match="/"> <answer> <xsl:call-template name="sum-it"> <xsl:with-param name="set" select="$set"/> <xsl:with-param name="items" select="lines/item"/> </xsl:call-template> </answer> </xsl:template> <xsl:template name="sum-it"> <xsl:param name="set"/> <xsl:param name="items"/> <xsl:value-of select="sum( $items[contains($set,concat('(', code ,')'))]/amt)"/> </xsl:template> ...
I couldn't understand your XSLT. To simplify the matter to the question of creating a separate table for every N lines, where each line forms a column, consider the following stylesheet: XSLT 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:variable name="col-limit" select="5" /> <xsl:variable name="rows" select="/Facture/Mensualite/Lines/Line[1]/*" /> <xsl:template...
how to now iterate through this returned node sets to add html styling to specific nodes Instead of: <xsl:otherwise> <xsl:copy-of select="$selected"/> </xsl:otherwise> you could do: <xsl:otherwise> <xsl:apply-templates select="$selected"/> </xsl:otherwise> then add templates matching the "specific nodes" you want to style. Hard to be more specific than that without seeing...
Use this XSLT: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:data="data"> <xsl:output method="xml" indent="yes"/> <xsl:variable name="xml2" select="document('xml2.xml')//item" /> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="item"> <xsl:variable name="item" select="$xml2[@name = current()/@name]"/> <xsl:if test="$item">...
So, my original answer proved not to work because of the unfortunate way that <xsl:apply-imports/> works when there is no matching template. See the answer to this question for details. The bottom line is it resorts to default templates, which ends up messing the output when you use it the...
And here goes the solution using Muenchian's grouping: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:strip-space elements="*"/> <xsl:output method="xml" indent="yes"/> <xsl:key name="group" match="property" use="@name"/> <xsl:template match="/EMailData/property/property | /EMailData/property/property/property/row"> <xsl:variable name="id" select="generate-id()"/> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:for-each...
Well XSLT uses URLs and not file paths so I would start with <xsl:variable name="file" select="'file:///C:/Test.xml'"/>. But these days chances are that security restrictions on local file system access hamper free navigation and access across it so make sure you check the error console whether it shows any messages.
Googling around, I found the answer here: Extracting Domain from URL in XSLT <xsl:template match="/"> <xsl:variable name="url_ini" select="/root/url"/> <xsl:variable name="url_minus_http" select="substring-after($url_ini,'//')"/> <xsl:value-of select="substring-before($url_minus_http,'/')"/> </xsl:template> ...
You can use an outer loop with position() mod $num_per_div to get one "iteration" per chunk, then within that select out the members of that chunk out of the whole key(...) node set by their position: <xsl:for-each select="key('items-by-product', $productid) [position() mod $num_per_div = 1]"> <xsl:variable name="iter" select="position()" /> <xsl:variable name="first"...
This is a grouping problem, so you can use Muenchian grouping for this: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:key name="kSequence" match="child" use="concat(name, '+', date)"/> <xsl:template match="/*"> <xsl:copy> <xsl:apply-templates select="child[generate-id() = generate-id(key('kSequence', concat(name, '+', date))[1])]" mode="group" /> </xsl:copy> </xsl:template> <xsl:template match="child"...
There were three mistakes here: You have elements named NameID, not Name (this was wrong in two places) @Class is an attribute on NameID, so you don't need a ../ before it. Once these are fixed, it works as expected: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/"> <Detail>...
You can try using local-name(soapenv:Envelope/soapenv:Body/*), for example, the following XSL transformation : <xsl:stylesheet version="1.0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:end="http://endpoint.ggg.com/" > <xsl:output method="text" omit-xml-declaration="yes"/> <xsl:template match="/"> <xsl:element name="root"> <xsl:value-of select="local-name(soapenv:Envelope/soapenv:Body/*)"/> </xsl:element>...
I agree that the behaviour of apply-imports is difficult to understand. The problem is that apply-imports always finds a template that matches the current node, even if the user did not define it. In that case, the default template applies. The following stylesheet works: XSLT Stylesheet <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet...
xslt,xslt-1.0,muenchian-grouping
I think you can use Muenchian grouping to identify the first item in each group, then you need to recreate the tree for each group: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:key name="group" match="RecordB11112" use="substring(Dates/StartDate, 1, 7)"/> <xsl:template match="/"> <Examples> <xsl:apply-templates select="//RecordB11112[generate-id() = generate-id(key('group',...