FAQ Database Discussion Community


One single XSLT template to transform one XML into another which follows a slightly different XSD?

xml,xslt,xslt-2.0
I am new to the idea/knowledge of XSLT. I've seen it used minimally to transform XML data into HTML to visualize on web pages. I need some help just understanding the approach of how to use XSLT for a particular scenario. For example I have two separate XSDs that are...

How to remove xml tags only using xslt

xml,xslt,xslt-1.0,xslt-2.0
<document> <body> <p> <pPr> <autoSpaceDE/> <autoSpaceDN/> <adjustRightInd/> <spacing/> <rPr> <rFonts/> <b/> <bCs/> <lang/> </rPr> </pPr> <r> <rPr> <rFonts/> <b/> <bCs/> <lang/> </rPr> <t>Title</t> </r> </p> </body> </document> How can i remove some tags without affecting or deleting the text inside this is my expected output after xslt...

How to get repeated element from For-Each in XSLT 2.0

xml,xslt,xslt-1.0,xslt-2.0
I want to get repeated elements in XSLT 2.0. But there is a restriction that i have to do that only with using "For-each" loop. Input XML: <Data> <Movie> <name>A</name> <writer>B</writer> <writer>C</writer> <director>D</director> </Movie> <Movie> <name>A</name> <writer>B</writer> <writer>C</writer> <director>D</director> </Movie> </Data> Expected Output XML: <Imdb> <Film>...

XML-XSLT-XPATH : How to convert multiple XML elements to a string, separated by semicolon

xml,xslt,xpath,xslt-2.0
I have just demonstrated my question as an input and output format as below. I have an input as xml document which consist of following data <Users> <user> <name>Mark Curtain</name> <email>[email protected]</email> <username>mark</username> </user> <user> <name>Zuke Gossip</name> <email>[email protected]</email> <username>zuke</username> </user> <user> <name>Villan Kiosk</name> <email>[email protected]</email>...

Type error when using as=“element” on a variable

xml,xslt,xslt-2.0
I'm consuming a web service which returns escaped XML. I need to un-escape it and do a transform on it. I'm trying to figure out how to do that in a single transform given that I get this error: Required item type of value of variable $result is element(); supplied...

Using XSLT for desired output

xml,xslt,xslt-2.0
I have following XML <Name> <Person> <Car> <brand>Merc</brand> </Car> <Car> <brand>Merc</brand> </Car> </Person> <Person> <Car> <brand>Audi</brand> </Car> </Person> </Name> And my desired output is <People> <Resident> <Number>1</Number> <Vehicle> <CarNumber>1</CarNumber> <CarNumber>2</CarNumber> </Vehicle> </Resident> <Resident>...

XSLT multiple output: copy selected nodes and the rest too

xml,xslt,xslt-2.0
I have the following input xml: <?xml version="1.0" encoding="UTF-8"?> <car xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <extras> <extra> <model>Z1</model> </extra> <extra> <model>Z2</model> </extra> <extra> <model>X</model> </extra> </extras> <color>red</color> <tire>goodyear</tire> </car> I'm trying to generate one output xml for each <extra>..</extra> element in a way that the resulting...

Remove repeated string in xslt

xml,xslt,xslt-1.0,xslt-2.0
I need to remove duplicate entries of a string or merge contents of a complex type element. I want to Change this into this format:: <?xml version="1.0" encoding="UTF-8"?> <EMailData> <property name="EVENTINFO"> <property name="City"> <value>City1111</value> </property> <property name="Country"> <value>Country1112</value> </property> <property name="Zip"> <value>Zip1113</value> </property> <property name="Household"> <row> <property...

XSLT template not applying to newly-created elements

xml,xslt,xslt-2.0,saxon
I am using XSLT 2.0. Inside a xsl:template (template-1), I use xsl:analyze-string to create new span elements with an xml:lang attribute. I have a second template (template-2) that adds a class attribute to elements that contain a xml:lang attribute. In my stylesheet, the newly-created span elements created by the first...

Sorting elements in XSLT 2.0

xml,sorting,xslt,xslt-2.0
I am trying to sort the following XML using XSLT <Name>name3</Name> <Job>x</Job> <Name>name1</Name> <Job>y</Job> <Name>name2</Name> The expected output is <Name>name1</Name> <Job>x</Job> <Name>name2</Name> <Job>y</Job> <Name>name3</Name> The Name elements have to be sorted while keeping the Job elements intact. I am using XSLT 2.0 Although I am able to sort the Name...

Why is xsl:when not working as expected?

xml,xslt,xslt-2.0
I am a beginner to the XSLT and I am a bit confused on how to use xsl:when. Please find my sample XSLT code below with expected output and the actual output I am getting from the XSLT. Could you please suggest your solution and explain what I am doing...

XSLT - Why are multiple nodes getting merged in the output ( Group By)

xslt,xslt-2.0
All- I am trying to understand the root cause for 2 nodes getting merged. The input XML <?xml version='1.0' encoding='UTF-8'?> <Employees> <Employee> <Employee_ID>E00001</Employee_ID> <Legal_Name Descriptor="John Doe" /> <lastName>Doe</lastName> <firstName>John</firstName> <P_From_Date>2015-04-01-08:00</P_From_Date> <P_End_Date>2015-12-31-08:00</P_End_Date> <Transaction> <Plan Descriptor="Plan A" />...

How to print element tags in XML document using XSL

xml,xslt,xslt-1.0,xslt-2.0
Very much a beginner with XSL. I'm trying transform 2 XML documents into a new XML document. I can't seem to get the tags to print to the new document. Only the content of the elements is printing. XML <books> <book> <name>Cat in the Hat</name> <author>Me</name> ... ... </book> ......

Copy all the sub elements of a root element except a given element

xml,xslt,xslt-2.0
I am new to xslt transformation. I need to print all the sub elements except a given element. This is my xslt: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <statuses> <xsl:for-each select="statuses"> <xsl:variable name='test1' select="status[name='bag']"> </xsl:variable> <xsl:copy-of select="$test1" /> </xsl:for-each></statuses> </xsl:template> </xsl:stylesheet> Input XML is mentioned below. The root...

making a transformed element the child of a sibling

xml,xslt,xslt-2.0
I am doing a MODS to MODS transform on the following xml. I have greatly simplified it for clarity: <?xml version="1.0" encoding="UTF-8"?> <OAI-PMH> <metadata> <mods> <genre>Negatives (photographic)</genre> <genre>Cellulose nitrate film</genre> <physicalDescription> <form>Photograph</form> </physicalDescription> </mods> </metadata></OAI-PMH> I need this result, where the genre elements have been been made form elements that...

Apply xslt tokenize function to results of apply-templates

xml,xslt,xslt-2.0
I have a block of XML that is formatted thusly: <line n="2"> <orig>of right hool herte <ex>&amp;</ex> in our<ex>e</ex><note place="bottom" anchored="true" xml:id="explanatory">Although “r” on the painted panels of the chapel is consistently written with an otiose mark when it concludes a word, the mark here is rendered more heavily and...

Condition getting getting called where it is not supposed to be

regex,xslt,xpath,xslt-2.0
I've the below XML. <?xml version="1.0" encoding="UTF-8"?> <body> <para><content-style font-style="bold">18/8/7</content-style> <content-style font-style="italic">(2) Here is the content</content-style>&#x2014;Contributory negligence accident <content-style font-style="italic">second v/w datav. </content-style> </para> </body> and the below XSL. <?xml version="1.0" encoding="UTF-8" ?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"...

How to increment date and time in XSLT 2.0

xml,xslt,xslt-2.0
I have a following date scenario, in which i want to increment in date, But the date format is of as following: 2015-05-03T00:00:00Z. I only want to increment in date of one day. So that if it reaches 31 then the month should be updated. I saw an existing question...

Use XSLT to mark up text matching regex?

xml,xslt,unicode,xslt-2.0,saxon
I am trying to use XSLT 2.0 (Saxon-PE 9.6) on an HTML document to create tags that surround all contiguous runs of characters from a specified non-Latin Unicode block (spaces allowed). I need to apply this process to every text() node in the document. I have made some progress with...

Using XSLT variable in X PATH string

xslt,xslt-2.0
I have an XPath string as follows: /results/server[@name='server1'] I would like to construct a new XPath using a previously defined XSLT variable: /results/server[@name='$server'] I haven't tried 'concat' might be possible with that. I am using XSLT 2.0. XSLT parser complains if I use the string as defined above: XPST0003 XPath...

Reproduce XML with attributes using XSLT 2.0 & Grouping one element

xslt-2.0,xslt-grouping
I'm a newbie to XSLT and had to group/sum one element as a single employee may have two rows of data. I was able to achieve that using tag and sum(current-group()) function. The input xml had attributes and along with the prior need also have to reproduce the xml attributes...

Adjust an alphabetical index from xml grouping to make columns equal

xml,xslt,xslt-2.0,xslt-grouping
Here is a scenario where an alphabetical index is created into 3 columns. But, the approach for dividing them into columns has some scope of improvement. Creating alphabetical index with fixed number of columns in XSLT 2.0 In the above scenario, is there a way if the 3 columns can...

xslt create ordered list from string

xml,xslt,xslt-1.0,xslt-2.0
Have a string in xml <anons> 1. first list item. 2. second list item. 3. third list item. </anons> Is it possible to create an ordered list like this: <ol> <li>first list item.</li> <li>second list item.</li> <li>third list item.</li> </ol> ...

Match attribute on XSLT instead of matching the whole element

xml,xslt,xpath,xslt-2.0
I want to write an xsl template that matches attributes instead of nodes, I would think that having something like this: <xsl:template match="@href | @conref | @conrefend"> <xsl:message select="."/> </xsl:template> would match any of those 3 attribute names and print to console the value of the attribute as the scope...

How to avoid ambiguous match for two different elements

xml,xslt,xslt-2.0
Please suggest for avoid the Ambiguous template match for both 'mfrac' and 'msub' elements. Here scripts are coded to remove the 'Space1' text nodes which are present at first or second child of msub or mfrac with first text node first or second child of msub or mfrac with last...

XSLT Sequence Number Generation

java,xslt,xslt-2.0,xslt-grouping
I am preparing one flat file from XMl using XSLT 2.0. My input XML is <city> <family> <parent>A</parent> <child>A1</child> </family> <family> <parent>A</parent> <child>A2</child> </family> <family> <parent>B</parent> <child>B1</child> </family> <family> <parent>B</parent> <child>B2</child> </family> <family> <parent>B</parent> <child>B3</child>...

Day difference between two dates in XSLT version 2.

xslt,xslt-2.0
Is there a easy way I can get how many days is the difference between two dates in XSLT.

Preserving entity references when transforming XSLT with XSLT

xml,xslt,xslt-2.0
I'd like to transform some XSLT-files with XSLT to get new XSLT-files, which is actually working quite fine. Only one function is providing problems: If I copy / or even if I try to build this function manually <xsl:function name="mr:get_xmlname"> <xsl:param name="name"/> <xsl:value-of...

XSLT convert xml block under a specific node to xml-escaped content of that node

xslt,escaping,xslt-2.0,cdata
Any ideas of how the following problem can be solved would be highly appreciated. INPUT: <p> <div> Original<br/>This is the original <b>acid</b>, a hydroxy monocarboxylic <span class="hl1">acid</span>. </div> </p> Desired Output: <p> <div> Original&lt;br/&gt;This is the original &lt;b&gt;acid&lt;/b&gt;, a hydroxy monocarboxylic &lt;span class=&quot;hl1&quot;&gt;acid&lt;/span&gt;. </div> </p> Attempt 1:...

Is it possible to preprocess xml source within the same XSLT Stylesheet?

xslt,xslt-2.0
Within the same XSLT (2.0) Stylesheet and transformation I would like to: 1) first preprocess the whole XML Datasource (Add a attribute with a specific calculation to certain elements) and then 2: transform the changed XML Datasource with the sylesheet's templates. How can I achieve this? A code example would...

how to remove specific elements but not the text inside it using xslt

xml,xslt,xslt-2.0
This is my Input xml <para> <a><b>this is a text</b></a> </para> this is my expected output <para> this is a text </para> how can i delete all the "a" tags and the "b" tags only and the text will not be affected using xslt thanks...

xslt 2.0 group-starting-with by element contents

xml,xslt,xpath,xslt-2.0,xpath-2.0
I'm new to XSLT 2.0 and XPATH 2.0 and I'm struggling to grouping a list of contacts, my intent is to merge adjacent numbers that belongs to the the previous defined person (note the empty elements). here my input XML <rows> <row> <person>John</person> <tel>1111</tel> </row> <row> <person>George</person> <tel>2222</tel> </row> <row>...

Which way of writing this sum of attribute values is better?

xpath,xslt-2.0
I want to sum two attributes of a descendant element. This XPath expression accomplishes what I want: sum(a/b/@x) + sum(a/b/@y) ...But it seems inefficient to invoke the computation of the a/b path expression twice. It feels even more awkward if I were to need to sum three or more of...

XSLT 2.0 Compare sequence of attribute values to variable

xml,xslt,xslt-2.0
I have elements such as <elem attr1="value1 someValue" attr2="value2 someOtherValue"/> elements with a variable amount of attributes that each have a variable amount of values. Some of these attributes' names and some of their values are saved in variables beforehand and the elements are checked against these variables. I need...

Remove XML Node text using XSLT

xml,xslt,xslt-2.0
I need to modify xml document with XSLT. what I need is to remove some node name from xml document. Example: <link ref="www.facebook.com"> <c type="Hyperlink">www.facebook.com<c> </link> I need to convert this xml as follows (remove the <c> node and attribute form xml), <link ref="www.facebook.com"> www.facebook.com </link> I tried to do...

Using XSLT to recursively load relative XML files and apply transformation

java,xml,xslt,xslt-2.0
I have a xml file whose structure looks like this: <root> <includes> <includeFile name="../other/some_xml.xml"/> </includes> <itemlist> <item id="1" > <selections> <selection name="one" /> </selections> </item> </itemlist> The xslt <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xslt"> <xsl:output method="xml" indent="yes" xalan:indent-amount="4"...

Apply-templates with in Analyze string

regex,xslt-2.0
I've the below XML. <?xml version="1.0" encoding="UTF-8"?> <para align="center"> <content-style font-style="bold">A.1 This is the first text</content-style> (This is second text) </para> Below are my 2 Questions. here i've declared a regex to match the content-style, But when i run this the second one is caught where as it should be...

How do I assign the text of HTML Elements to a XSLT Variable?

html,xslt-2.0
I want to create a dynamic XSLT Variable. It should fetch the content of the first td of each row, something like this: <tr><td>1</td><td>not Important</td></tr> <tr><td>2</td><td>not Important</td></tr> <tr><td>3</td><td>not Important</td></tr> My XSL:Variable looks something like this: <xsl:variable name="name" select="concat('out/',//td[1]/text(),'.html')"/> I want to use the elements content (in my Case 1, 2,...

Get text between two self-closing elements and number of following/preceding element

xml,xslt,xslt-2.0,saxon
<text> <pb n="I"/> <p> <lb/>Lorem ipsum <lb/>Lorem ipsum <lb/>Lorem ipsum <pb n="II"/> <lb/>Lorem gipsum <lb/>Lorem gipsum </p> <p> <lb/>Lorem gipsum <lb/>Lorem gipsum <pb n="III"/> <lb/>Lorem hipsum <lb/>Lorem hipsum <lb/>Lorem hipsum <lb/>Lorem hipsum </p> <pb n="IV"/> <p> <lb/>Lorem dipsum </p> </text> From such a document, I am trying to get all...

Why are fn:matches and fn:replace throwing parse errors in XSLT 2.0?

java,xml,xslt,xslt-2.0
I am trying to use these two string functions (matches and replace) in my XSLT stylesheet. But at runtime I get below error for matches and a similar error for replace: Caused by: org.xml.sax.SAXException: Parse Error in matches function. oracle.xdo11g.xpath.XPathException: Parse Error in matches function. at oracle.xdo11g.xslt.XSLProcessor.reportException(XSLProcessor.java:965) at oracle.xdo11g.xslt.XSLProcessor.newXSLStylesheet(XSLProcessor.java:725) at...

xsl:choose Expression must evaluate to a node-set

c#,xml,xslt,xslt-2.0,xsl-choose
I am working with C# and XSLT 2.0. I am having problem with one of templates, it seems to be falling over <xsl:choose> statement. Values passed are Key - Value pairs and all but two values are decimals. Intention is to format decimals with 2 decimal places and , on...

Axis step child::element('':PRODUCT_LIST) cannot be used here: the context item is an atomic value

xslt,xslt-2.0
Thanks in advance for your support. I have the following xml and xslt <SUBSCRIBER> <PRODUCT_LIST> <PRODUCT_INFO> <ID>BA3</ID> <PRODUCT_TYPE>Chargeable Bonus Product</PRODUCT_TYPE> <NSN1>34178</NSN1> <NSN2>2015-02-18 23:59:59</NSN2> <OFFER>1104</OFFER> <DA_UNIT>time</DA_UNIT> <UA>1003</UA> </PRODUCT_INFO> <PRODUCT_INFO> <ID>SID15</ID> <PRODUCT_TYPE>Rate Cutter</PRODUCT_TYPE>...

HashMap iteration in XSLT 2.0

java,xml,xslt,xslt-2.0,xsl-fo
I have an HashMap object as part of my java model and when I convert it into XML, this is the result... <transaction> <claims> <remarksMap> <entry> <string>XX</string> <string>Description 1</string> </entry> <entry> <string>YYY</string> <string>Description 2</string> </entry> <entry> <string>ZZZZ</string> <string>Description 3</string> </entry> </remarksMap> </claims> </transaction> I would like to...

match cases based on range with alphabets

xslt,xslt-2.0
I've the below XML. <para>39B</para> <para>76</para> Here I'm able to match the exact number, but the problem came up when there is a range mentioned like below. if the range 39A-39P print case1 if the range 72-85 print case2 The code i tried <xsl:template match="text()"> <xsl:analyze-string select="." regex="([\w]+)"> <xsl:matching-substring> <xsl:variable...

using a counter for all groups members in for-each-group

xml,xslt,xslt-2.0
I have a problem where I have an xml content with different keys needs to be grouped together and displayed, when displayed there is a pagination so I can't display all entries on the same page, I'm using for-each-group for grouping the items, and loop through each current-group() and display...

XSLT - Put Content by checking attribute

xml,xslt,xslt-2.0
I'm new to XSLT. and I've a xml to xml transformation task. what I have to do is put some xml node to result xml tree by checking some attribute values in original xml file. example : original xml has <doc> <sec id="sec_1" sec-type="scope"> </sec> <sec id="sec_1" sec-type="norm-refs"> </sec> //more...

Group a number of template matches without a parent element in XSLT 2

xml,xslt,xslt-2.0
I have a very unstructured XML document (taken from a Pandoc converted docx to docbook format) which I am trying to clean with XSLT. The format of the xml is like this; <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> <article> <articleinfo> <title></title> </articleinfo> <informaltable> <tgroup...

equals not matching though declared

xslt,xslt-2.0
I've the below XML Text S1/7/1 And the below XSLT. <xsl:template match="text()"> <xsl:analyze-string select="." regex="(\w+)/(\w+)/(\w+)"> <xsl:matching-substring> <xsl:variable name="ChpnMatch"> <xsl:value-of select="substring(regex-group(1),1,1)"/> </xsl:variable> <xsl:variable name="regex1"> <xsl:choose> <xsl:when test="$ChpnMatch = 'U'"> <xsl:text>HKWB2015EDSUPP2_CH_S4</xsl:text> </xsl:when> <xsl:when test="$ChpnMatch = 'B|D|E|L|R|F|H|K|Q|S'">...

Memory efficient XSLT for transforming large XML files

xml,xslt,out-of-memory,xslt-1.0,xslt-2.0
This question is related to a recent answer by michael.hor257k, which is in-turn related to an answer by Dimitre Novatchev. When used the stylesheet in the above mentioned answer(by michael.hor257k), for a large XML(around 60MB, sample XML is present below) and the transformation was carried out successfully. When tried another...

Add Space Before a tag if it is Present in XSLT

html,css,xml,xslt,xslt-2.0
Iam creating styles using XSLT for my XML file. Here is my code: <xsl:template match="LEXVAR"> <xsl:copy> <xsl:apply-templates/> <xsl:choose> <xsl:when test="./preceding-sibling::LEXVAR"> <span class="neutral"> <xsl:text>, </xsl:text> </span> </xsl:when> <xsl:when test="./preceding-sibling::*"> <span class="neutral"> <xsl:text> </xsl:text> </span> </xsl:when> <xsl:otherwise/> </xsl:choose> </xsl:copy>...

Split XML into multiple files using xslt on string length

xml,xslt,xslt-2.0
I'm looking at trying to split an XML file into 2 separate files. They have to be split on the length of a string in a particular element. I've been attempting to use the <xsl:for-each-group> and <xsl:result-document> elements in order to do this but only get the 1st matching 'object'...

Use XSLT 2.0 to display an image from a directory

xml,xslt-2.0
Team, I'm using XLST 2.0 to create MS Word documents from XML data. I'm working on creating a header and want to call in image file from a local directory to display our company logo. With the software I'm using, I am unable to use an MS Word Template to...

Precision, Rounding, and data types in XSLT2.0

xslt,decimal,rounding,xslt-2.0,data-type-conversion
This is a question about precision, rounding, data types, and using the xs:integer() function in XSLT 2.0. We have the following line of code: <xsl:value-of select="xs:integer(round(InvoiceAmount * 100))"/> When the value of InvoiceAmount in the source XML is -62.84, the result of the value-of is -6283 which is incorrect. We...

XSLT 2.0 using xsl copy/copy-of in for-each, overwriting certain attributes

xml,xslt,xslt-2.0
I'm having troube copying nodes and overwriting elements in a for-each loop. The code: <xsl:for-each select="key('doc_checks', @id, $doc_checks_File)"> <xsl:if test="@id = $curID"> <xsl:copy-of select="."/> </xsl:if> </xsl:for-each> Copies everything, which is fine, but I need to override two attributes (or rather, they should not be copied into the result document). The...

XSLT 2.0 for-each-group, sum based on parent value

xslt,xslt-2.0,xslt-grouping
I have tried to get for-each-group to work without success in my xml, I want to group the areas in my refdes-tags ond calculate the sum of the prices per area. If I have several refdes with the same area under an item it does only count the first one...

Removing empty nodes with empty/no attributes using XSLT

java,xml,xslt,xslt-2.0
I want to: remove all empty nodes with no or all empty attributes f.e. <node/>, <node attr1="" attr2=""/>, <node></node> keep those nodes, which has at least one non-empty attribute f.e. <node attr1="123" attr2="" attr3=""/> and then remove those empty attributes to have <node attr1="123"/> UPDATED keep those empty nodes, which...

xslt resolve hierarchy and copy into new document

xml,xslt,xslt-2.0
I have an xml document like this: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <nodes> <node id="123"> <elemref id="1"/> <elemref id="2"/> <noderef id="222"/> </node> <node id="456"> <elemref id="4"> <elemref id="2828"/> </elemref> <elemref id="5"/> <noderef id="444"/> </node> <node id="222"> <elemref id="6"/> <elemref id="8"/> <noderef id="666"/> </node> <node id="444"> <elemref id="11"/> <elemref...

Is it possible for a template to use itself as the select attribute in a for-each-group?

xml,xslt,xpath,xslt-2.0
As the title, is it possible to make something like this work: <xsl:template match="orderedlist"> <xsl:for-each-group select="." group-adjacent="@level"> <xsl:element name="{name(.)}"> <xsl:for-each select="@*"> <xsl:copy/> </xsl:for-each> <xsl:for-each select="current-group()"> <xsl:apply-templates/> </xsl:for-each> </xsl:element> </xsl:for-each-group> </xsl:template> For use within this transformation to condense the two orderedlist elements with the same level...

How to subtract 1 day (calculate day before) in XSLT 2.0?

xml,xslt,xslt-2.0
Could someone please help calculate one day ago from a given date of type xsd:dateTime using XSLT 2.0? Sample Input: <?xml version="1.0" encoding="UTF-8"?> <objects> <LastRunTime__c> <Last_Run_Time__c>2015-01-29T19:55:15.846Z</Last_Run_Time__c> </LastRunTime__c> </objects> Sample Output: <?xml version="1.0" encoding="UTF-8"?> <objects> <LastRunTime__c> <Last_Run_Time__c>2015-01-28T19:55:15.846Z</Last_Run_Time__c> </LastRunTime__c> </objects> I was...

How to use param variables while creating xml using xslt

xml,soap,xslt-2.0
I have to create a SOAP request using XSLT. I have param(s) defined as below <xsl:param name="EmployeeID"/> <xsl:param name="FirstName"/> <xsl:param name="MiddleName"/> <xsl:param name="LastName"/> Using these, am trying to create an XML (SOAP) as below <cs:Users> <cs:User EmployeeId=""> <cs:Contact> <cs:Name First="" Prefix="" Middle="" Last=""/> <cs:Contact> <cs:User> <cs:Users> I intend to use...

Creating alphabetical index with fixed number of columns in XSLT 2.0

xml,xslt,xslt-2.0,xslt-grouping
I have an XML like this: <xml version="1.0" encoding="UTF-8"?> <countries> <country> <name>Latvia</name> </country> <country> <name>USA</name> </country> <country> <name>Australia</name> </country> <country> <name>Indonesia</name> </country> <country> <name>UK</name> </country> <country> <name>India</name> </country> <country> <name>Argentina</name>...

How to group the elements in XSL?

xslt-2.0
I have an HTML of the following process. <p class="Reference_Unnum" id="RefId_2"><span class="first_name" dir="Author" value="Klingmann">Klingmann, </span><span class="last_name" dir="Author" value="Anna.">A</span>, <span class="first_name" dir="Author" value="John">John, </span><span class="last_name" dir="Author" value="Kumar">K</span>, <span class="first_name" dir="Author" value="William">William, </span><span class="last_name" dir="Author"...

Unkown system function: format-date in XSLT

xslt,xml-parsing,xslt-1.0,xslt-2.0
I am oxygen editor to transform data XML into CSV format. To transform, I am using XSLT. I am using format-date function to convert date value in desired format. <xsl:value-of select="format-date(wd:Evaluate_Employee_Effective_Date,'[M01]/[D01]/[Y0001]')" /> Any help would be highly appreciated. Also, how do I know that which version of XSLT I am...

Replace all tags below a node

xslt-1.0,xslt-2.0
I need to change all tags below a node in transformation. Source XML looks like this: <Address> <s:name>name</s:name> <s:lastName>last name <a:lastName> <s:address1>Address Line 1</s:address1> <s:address2>Address Line 2</s:address2> Required O/p: <Address> <name>name</name> <lastName>last name <lastName> <address1>Address Line 1</address1> <address2>Address Line 2</address2> There are thousand of tags.So, can not write match to...

Changing the value of an attribute depending of the value of a second attribute of the same element

xml,xslt,xpath,xslt-2.0
This is my XML: <?xml version="1.0" encoding="UTF-8"?> <root> <trans> <language type="lang" lang="DE"/> </trans> <trans> <language type="lang" lang="EN"/> </trans> </root> My goal is to replace the value of the attribute "type" depending on the value specified in the "lang" attribute. This is the desired output: <?xml version="1.0" encoding="UTF-8"?> <root> <trans> <language...

Comparing a sequence of elements and replacing on match via XSLT/Xpath

xml,xslt,xpath,xslt-2.0
I'm trying to do an intersect of sorts between two child elements in the same XML document. <links> <old> <xref linkend="zzzzz">/chapter/subchapter[1]/section[2]/@id</xref> <xref linkend="aaaaa">/chapter/section[1]/@id</xref> </old> <new> <xref linkend="xxxxx">/chapter/subchapter[1]/section[2]/@id</xref> <xref linkend="sssss">/chapter/@id</xref> </new> </links> Whenever there is a match between the string path in new/xref and old/xref, I want to join the two...

how to compare and get result from multiple source matching and conditional result to target

xml,xslt,xslt-2.0,jdeveloper,bpel
I have two source xmls (Updated and edited) <?xml version="1.0" encoding="UTF-8"?> <CustomerInformation xmlns="http://updateContactDetails.sc.cz.fc.ofss.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://updateContactDetails.sc.cz.fc.ofss.com UpdateContact.xsd "> <IntegrationID>099009301</IntegrationID> <BrandName>SLOFT</BrandName> <CorrelationId>2312312</CorrelationId> <ProductSystemCustomerDetail>...

count the nodes ignoring blank nodes

xslt,xslt-2.0
I've the below XML. Case 1 <body> <nd> <pnn>1.1</pnn> <h1>PART 54</h1> <ti>Construction</ti> </nd> <nd> <h1>PART 54</h1> <h2>I INTRODUCT</h2> <ti>Time</ti> </nd> <nd> <h1>PART 54</h1> <h2>I INTRODUCT</h2> <ti>Power</ti> </nd> <nd> <h1>PART 54</h1> <h2>II APPLICATIONS</h2> <ti>Filing</ti> </nd> </body> Case 2 <body> <nd>...

Sequence number for static and dynamic rows in XSLT 2.0

xml,xslt-2.0
I'm trying to generate sequence number for my input xml with some static and dynamic rows combination. input xml: (Edited) <data> <oldLine>dat1</oldLine> <modLine>dat2</modLine> <line>para1</line> <line>para2</line> <line>para3</line> </data> <data> <oldLine>dat3</oldLine> <modLine>dat4</modLine> <line>para4</line> <line>para5</line> </data> I need to add three fixed records after every "data" tag in the loop...

How to find first occurence of particular text within element

xml,xslt,xslt-2.0
Please suggest for inserting some element in first position of the particular text within particular element. In the given sample, required to identify the text 'text1' found as first position, then need to insert <first/> after 'text1'. Please suggest. XML: <article> <body> <list>text1 text2</list> <para>The text1 text3 text4</para> <para>The text1...

is there a way to check if there is text between the nodes

xml,xslt,xslt-2.0
I've the below 2 different XML Cases. Case1 <para><content-style font-style="bold">1/3</content-style> This is text</para> Case2 <para>This is text <content-style font-style="bold">1/3</content-style></para> i'm using the template match as below <xsl:template match="para[content-style[matches(., '(\w+)/(\w+)')]]"> but as per this match, both the cases mentioned above are satisfied, i want only first case to be caught ignoring...

Similar type of data not matching the same case

xpath,xslt-2.0
I've the below XML <?xml version="1.0" encoding="UTF-8"?> <body> <para><content-style font-style="bold">1/7 7.</content-style> This is First</para> <para><content-style font-style="bold">1/8 8.</content-style> This is second<content-style format="superscript">6</content-style></para> </body> Here when i'm trying to apply template using my XSLT, though the above 2 paras are of same format, first is working and the second is not. The...

Split the equation based on first dot (.)

xml,xslt,xslt-2.0
Please suggest for how to split the equation into two parts based on first dot. Earlier I got the suggestion to Split the Equation based on BREAK comment text from michael.hor257k, now it is required to split on period. XML: <root> <body><sec><title>The sec 1</title><p>Text 1</p></sec></body> <inline-formula> <math display="inline"> <mi>A</mi> <mn>4.651</mn>...