FAQ Database Discussion Community


HTML output not as expected

xml,xslt-1.0
I have the following XML: <page id="12095325"> <name>DUMMY TEST</name> <description>Includes in- & outbound dial statistics</description> <server>reg6699cic01</server> <created>2015/02/19 11:57:05 AM</created> <adhocmessage/> <workgroups> <workgroup> <name>SSC_UK_Office_All</name> <agents>24</agents> <agentsavailable>0</agentsavailable> <agentsloggedin>16</agentsloggedin>...

Adding a child attribute to the parent element in xslt 1.0

xml,xslt,xpath,xslt-1.0
I have multiple elements that contain an uniqueId(generated and stored in a variable). I have recursively added the element(object class=Bundle with unique id ) with the xsl as follows <xsl:template match="visualChildren"> <object class="Set" > <installChildren> <xsl:call-template name="Bundle"> <xsl:with-param name="i" select="1"/> <xsl:with-param name="limit" select="4" /> </xsl:call-template> </installChildren> </object> </xsl:template> <xsl:template name="Bundle">...

Treat same tag, different namespace as the same

xml,xslt,xslt-1.0,xml-namespaces
I'm working on a project where I have xml files that contain html child nodes; some have the xmlns="http://www.w3.org/1999/xhtml" attribute, some do not. (in a previous process, a script checks the html sections for well-formedness, and uses htmltidy to clean them up if they need it) is there anyway for...

How to get xml Nodes which are in lower case using XSLT 1.0

xml,xslt,xpath,xslt-1.0
I need to get XML nodes which are in lower case and values of it using XSLT 1.0 and display the output as XML <main> <ACAT>Cat Name A </ACAT> <bcat>Cat Name b </bcat> <ccat>Cat Name c </ccat> <dcat>Cat Name d </dcat> <ECAT>Cat Name E </ECAT> <fcat>Cat Name f </fcat> </main>...

XSLT 1.0 select elements in Quiz XML

xml,xslt,xml-parsing,xslt-1.0
Here is a sample XML. <Root> <Story> <body> <quiz>1</quiz>How to select that rightanswer from another Story ? </body> <answer>answer1-1</answer> <answer>answer1-2</answer> <answer>answer1-3</answer> <body> <quiz>2</quiz>And how to push these <qitem/>s into <qitems/> ? </body> <answer>answer2-1</answer> <answer>answer2-2</answer> <answer>answer2-3</answer>...

Merge and update node values of two xmls using xslt

xml,xslt,xslt-1.0,osb
I am new bee in XSLT. But I belive below requirement can be achieved using XSLT :) Now I have a requirement where i need to merge 2 different xmls to one and there should be a check where the xslt should be capable of checking node name like if...

XSLT 1.0: find the maximum value from given date and time

xml,xslt,xslt-1.0
Hi all, I have the xml event in the following format (month,date,year,hour,minute,seconds AM/PM). I would like to mention that, I don't have the control over the generated XML. Now I need to find the maximum or latest "dateevent" and select the corresponding "eventname". The XML looks like <?xml version="1.0" standalone="no"?>...

How do I create recursive template in xslt

xslt,recursion,xslt-1.0
I have a sharepoint list which is designed like below. Here is a sample data of input. Name ID Navigation_URL ParentID IsShow Test1 1 # 0 Yes Test2 2 # 0 Yes Test2.1 3 # 2 Yes Test2.1.14 # 3 Yes How to create an unordered list using xslt function....

Add parent node to gather several children nodes using XSLT

xslt-1.0
Trying to transform that XML file: <collection> <collectionDetails> <owner>David</owner> <creationDate>20140515</creationDate> <movie> <title>The Little Mermaid</title> <stars>5</stars> </movie> <movie> <title>Frozen</title> <stars>3</stars> </movie> </collectionDetails> into that XML file: <collection> <collectionDetails> <owner>David</owner>...

XSL: Search for an element having an attribute equals to one property of the current attribute

xml,xslt,xslt-1.0
I've an XML which looks currently like this: <?xml version="1.0" encoding="utf-8" ?> <RootConfig> <RandomNode RefId="519263a7-e01e-4cc8-911e-7660dca717bf"> <Id>101010101010</Id> </RandomNode> <Item Value="519263a7-e01e-4cc8-911e-7660dca717bf;bf139890-2f7c-4784-8041-68aa5fe7beb1" Type="SomeUniqueType" /> <Item Value="519263a7-e01e-4cc8-911e-7660dca717bf;5fb8bea0-c79a-4a26-a532-4df59543bc5c" Type="SomeUniqueType" /> <Item...

How to add one extra row to the table using XSLT?

asp.net,xslt,xslt-1.0
We have ASP.NET application and use XSLT that produces the table, with structure that looks as following: <xsl:template match="Tickets2/Item"> <tr class="tdNewDesign"> <xsl:choose> <xsl:when test="OddEven = 'Odd'"> <td bgcolor="#FFFFFF" class="text" style="border-left: 1px dashed #AAA;"> <xsl:value-of select="Seats" /> </td> <td bgcolor="#FFFFFF" class="text" style="border-left: 1px dashed #AAA;"> <xsl:value-of select="SeatType" /> </td> <td bgcolor="#FFFFFF"...

How best to re-use XSLT code when different groups of documents have different optional tag attributes for the same tags?

xslt,xslt-1.0,xsl-fo
Here is the scenario. I have XML documents with tags that look like this: <para a="A" b="B" c="C"> appearing in different classes of XML documents. The a and b attributes are completely generic and are handled exactly the same way in all documents. The optional c attribute is document class...

XSLT parsing our more data than I'm selecting

xml,xslt,xslt-1.0
I'd really appreciate any help on understanding why I'm getting more data out of the transformation than I'm actually selecting in the stylesheet. So here's my XML sample: <?xml version="1.0" encoding="UTF-8"?> <e:root xmlns:e="http://www.yahoo.com"> <e:first>Hi</e:first> <e:cds> <e:cd> <e:title>Eric</e:title> </e:cd> <e:cd> <e:title>Tara</e:title> </e:cd> </e:cds> </e:root> Here is my stylesheet: <?xml version="1.0" encoding="UTF-8"?>...

xslt sum node values where node value

xslt,xslt-1.0
I have an XSLT file that is collecting information from an XML document, and then presenting it out to a CSV file. Presenting all of the information works fine, however what I need to do now is to sum all information of a node i:totalDurationInSeconds where i:issueBatchNumber = D12345 This...

Group and split Xmldocument on nth level descendant

xslt,xslt-1.0,muenchian-grouping
I want to split an XmlDocument into an array of XmlDocuments, where each splitted XmlDocument contains records of a certain period (Year/Month combination). The complicating factor, imo, is that the grouping should occur on nested elements. Example input: <?xml version="1.0" encoding="utf-8"?> <Example> <RecordA> <RecordA1> <RecordA11> <ElementA11></ElementA11> </RecordA11> </RecordA1> <RecordA2> <ElementA2></ElementA2>...

How to rename generic XML elements using the elements of a header node

xml,xslt,xslt-1.0
I get XML output from an online service that I can't manipulate. The TableHeader node contains the column names. Using XSLT 1.0, how can I rename the generic Attribute elements using the elements in TableHeader? XML input: <?xml version="1.0" encoding="UTF-8"?> <SearchResults> <TableHeader> <ColumnName>Surname</ColumnName> <ColumnName>FirstNames</ColumnName> <ColumnName>Gender</ColumnName> <ColumnName>Age</ColumnName> </TableHeader> <Object>...

update the empty elements with some default value

xml,xslt,xslt-1.0
I have this request. <request> <event> <st1>ky</st1> <st2>de</st2> <st3></st3> <st4></st4> <st5></st5> <ty> <st_in> <stno>1</stno> <stid></stid> </st_in> </ty> <mt_in> <mt_mem> <mt_id></mt_id> <mt_1></mt_1> </mt_mem> </mt_in> </event> </request> If there is empty I want to update it to some default value of NO except for elements ty and mt_in. So the output will...

How to remove attribute or replace attribute value using XSL/XSLT?

xml,xslt,xslt-1.0
I have a following in my XML file: <Hits> <Hit status="good"> <batter ref="4">Sample Text 1</batter> <contexts ref="5">Sample Text 2</contexts> </Hit> <Hit status="bad"> <batter ref="7">Sample Text 3</batter> <contexts ref="" /> </Hit> </Hits> I am trying to produce a XSL that will remove the ref attribute in any element or just replace...

Compare two xmls and get the common nodes

xml,xslt,xpath,xslt-1.0
I have two xml's . Need to read these two and create new xml with only common elements First XML: <Items> <array> <item name="A"> <name>A</name> <indate>20141112</indate> <inno>2</inno> <status>1</status> <level>12</level> <size>.1</size> <text>item a text </text> </item> <item name="B"> <name>B</name> <indate>20141012</indate> <inno>5</inno> <status>1</status>...

Formatting table columns to ignore duplicates XSLT-1.0

xslt,xslt-1.0,xsl-fo
I was hoping that someone could point me in the correct direction with a concept in XSLT 1.0. I am generating a PDF so the code is a bit long and I thought it would be more appropriate to include only the relevant bits. I have XML similar to the...

xslt select a node value based on the value of another node

xslt,xslt-1.0
I am being tasked with creating a csv file using XSLT to produce the information. So far I have almost everything that I need however, there is one bit that i am struggling to get as per the example below. <issuesExport xmlns="http://www.mynamesapce.co.uk/import"> <materials> <material> <code>WB821</code> <name>CONCENTRATE</name> </material> <material> <code>WB820</code> <name>ADDITIVE</name>...

Using basename to name output file in java

java,find,xslt-1.0,filenames,zsh
I have a recursive structure of directories containing some foo files that I want to convert to bar files using a XSLT 1.0 stylesheet. I have: dir |-- subdir | |-- file1.foo | |-- file2.foo | |-- file3.foo And I want to obtain: dir |-- subdir | |-- file1.foo |...

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> ...

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>...

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> ......

Iterating through a returned node set in XSLT 1.0

xslt,xslt-1.0
Following my question about returning a set number of random node sets using xslt 1.0 Display X distinct random node sets using XSLT 1.0 Using this code: <msxsl:script language="JScript" implements-prefix="my">function random() { return Math.random(); }</msxsl:script> <xsl:template match="/"> <output> <xsl:call-template name="pick-random"> <xsl:with-param name="node-set" select="NewDataSet/Vehicle"/> <xsl:with-param name="quota" select="5"/> </xsl:call-template> </output>...

Check attribute value of XML element with a regular expression pattern

xpath,xslt-1.0
I have this code, which does not work. I want to iterate trough all p elements below the body element and look for an element named object. Then use the match() function to look for a certain pattern in the attribute node data. <xsl:template match="/xhtml:html/xhtml:body//xhtml:p"> <xsl:for-each select="xhtml:object[matches(@data,'*mov$')]"> <halloMovie><xsl:value-of select="@data"/></halloMovie> </xsl:for-each>...

How to transform xml data into rows and columns?

xml,xslt,xslt-1.0
Here is my input XML: <data> <node>1</node> <node>2</node> <node>3</node> <node>4</node> <node>5</node> <node>6</node> <node>7</node> <node>8</node> </data> Required HTML output table: row = 2 1 | 3 | 5 | 7 2 | 4 | 6 | 8 row = 3 1 | 4 | 7 2 | 5 | 8 3...

Split Coordinates in XSLT

xml,xslt,xslt-1.0
I have an XML node of coordinates which contains the fully geolocated lat/long combination. However on a new system it must be sent as individual nodes. The XMl is transfomed with XSLT before its sent so I was wondering how i could effectively seperate it into the component parts. XML...

Testing conditions in XSLT with xsl:when

xslt,xslt-1.0
I have the below xsl tag in which i am fetching out the values of fpml:periodMultiplier and fpml:period as shown below ... tags in xml are :- <fpml:periodMultiplier>1</fpml:periodMultiplier> <fpml:period>Y</fpml:period> extracting in xsl as shown below <Payindextenor> <xsl:value-of select="../fpml:calculationPeriodDates /fpml:calculationPeriodFrequency /fpml:periodMultiplier" /> <xsl:value-of select="../fpml:calculationPeriodDates /fpml:calculationPeriodFrequency /fpml:period" />...

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...

How to transform a CSV matrix to a HTML table via XSLT 1.0?

csv,xslt-1.0
The XML matrix with csv rows <matrix ROWS="3" COLS="4"> <row>"1,2,3,4"</row> <row>"5,6,7,8"</row> <row>"9,10,11,12"</row> </matrix> is to be transformed with XSLT 1.0 without extensions into a HTML table <table> <tr><td>1</td><td>2</td><td>3</td><td>4</td></tr> <tr><td>5</td><td>6</td><td>7</td><td>8</td></tr>...

How to get rid of the '\n' character while reading string from xsl?

java,xslt,xslt-1.0,xsl-fo
I'm reading xsl file using XSLReader class, and one of the columns contains strings but sometimes this string have enter in the (\n), so when I read this and print it I'm printing the string with the \n: those are two addresses, the first one have enter in the xsl...

How do I split string of values in XSLT1.0?

xslt,xslt-1.0
I have a string of single values and ranges, and I want to split them and put them in order of single values together (comma separated) and ranges together (comma separated), using XSLT1.0. I don't want the result in form of XML nodes, I do want the result on the...

How to use inline conditional (if then else) in XSLT?

xslt,sharepoint,sharepoint-2010,xslt-1.0,dataviewwebpart
Is it possible to do inline conditionals (if then else) in XSLT? Something like: <div id="{if blah then blah else that}"></div> Or a real use-case/example: <div id="{if (@ID != '') then '@ID' else 'default'}"></div> ...

get node name from namespace

xslt,xslt-1.0
this is my xml <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:end="http://endpoint.ggg.com/"> <soapenv:Header/> <soapenv:Body> <end:onlineExpressRemit> <channelCode>NBPS</channelCode> </end:onlineExpressRemit> </soapenv:Body> </soapenv:Envelope> and this is my xslt <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"...

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...

Changing field name in XML file using XSLT

xml,xslt-1.0
I need to create an xslt transform file that essentially reads an xml file and changes the field names while keeping the same field values, then outputs a new xml file with these changes. I am having difficulty getting the values from the second and third field tags. Here is...

Greater than(>) and less than(<) operator not working in XSLT

xml,xslt-1.0,ibm-datapower
Below is my XSL where I am trying to check the condition if size of the file is greater then the preset value and try to stop the processing, but it looks like the condition is not getting executed. I am not sure if it is not formatted right way....

How to move an attribute and its value from one element to another

xml,xslt,attributes,xslt-1.0
I have the following XML: <?xml version="1.0" encoding="UTF-8"?> <Orders> <Order Weight="1.00"> <Items> <Item ItemLength="5.00" ItemQty="1"> <ItemCharge Description="Chair" Amount="5.50"></ItemCharge> </Item> </Items> </Order> <Order Weight="2.50"> <Items> <Item Length="5.00" ItemQty="1"> <ItemCharge Description="Chair" Amount="8.50"></ItemCharge> </Item> </Items> </Order> </Orders> I need the attributes and values in the...

XSLT processing with jaxb for a small transformation performance

java,performance,jaxb,xslt-1.0
I have a simple transformation. I have a java object to transform into different java object. so i used xslt. jaxb is my processor. TransformerFactory transformerFactory = TransformerFactory.newInstance(); StreamSource streamSource = new StreamSource( new File("conv.xsl")); Transformer transformer = transformerFactory.newTransformer(streamSource); JAXBContext jc =JAXBContext.newInstance(Bags.class); JAXBSource jAXBSource = new JAXBSource(jc, device); jAXBResult =...

xslt transform using second xml document

xslt-1.0
I have an xml data file that will contain a large number of repeating fields, each which are associated to about 10 unique facility names, like this: <Dailyreport> <msg> <msgdate>05/27/2015</msgdate> <facility>North</facility> <ispass>0</ispass> </msg> <msg> <msgdate>05/27/2015</msgdata> <facility>South</facility> <ispass>1</ispass> </msg> </Dailyreport> I have an XSL stylesheet version 1.0 that is working where...

Constructing, not selecting, XSL node set variable

xslt,xslt-1.0,msxsl
I wish to construct an XSL node set variable using a contained for-each loop. It is important that the constructed node set is the original (a selected) node set, not a copy. Here is a much simplified version of my problem (which could of course be solved with a select,...

xslt grouping and removing duplicates

xml,xslt,xslt-1.0,xslt-grouping,muenchian-grouping
<Items> <array> <item name="A"> <name>A</name> <indate>20141112</indate> <inno>2</inno> <status>1</status> <level>12</level> <size>.1</size> <text>item a text </text> </item> <item name="B"> <name>B</name> <indate>20141012</indate> <inno>5</inno> <status>1</status> <level>13</level> <size>.5</size> <text>item b text </text>...

XSLT Issue trouble

xml,xslt,xslt-1.0
have this problem Inside one XML file I might happen to have one or multiple request tag, like following: <notification> <data> <admin originator="" event_time="2015-02-28T02:26:42+02:00"> <input> <request_set tx_id="Y2xfMDFfMDE6LWFjODQ2MTQ6Y2E3Mjo1NGVmYjA3NjoxNTE3ODA=#YWM4NDYxNDpjYTcyOjU0ZWZiMDc2OjE1MTc5Ng==" tx_timeout="2015-02-28T00:36:51.824Z" tx_command="start"> <request report=""> <update> <account_data id="2005637" parent="3615732" Status="2" instance="1"> <info>...

XSLT copy elements from second XML if an attribute is set in the first XML

xml,xslt,xslt-1.0
I have the following input XMLs: car.xml: <car ref-id="parts.xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <color>red</color> <tire>michelin</tire> <engines override="false"> <engine> <model>Z</model> </engine> </engines> <hifi>pioneer</hifi> </car> parts.xml: <?xml version="1.0" encoding="UTF-8"?> <parts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <engines> <engine>...

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...

What is best XSLT XPath performance in my scenario?

xml,performance,xslt,xpath,xslt-1.0
I have a question about XSLT XPath performance. If we look in the following example. Which of following options has best performance: <xsl:for-each select="//cd"> or <xsl:for-each select="//catalog/cd"> XML data: <?xml version="1.0" encoding="UTF-8"?> <root> <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> </cd> <cd> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> </cd> </catalog> <catalog>...

Remove Duplicates from a list XSLT 1.0 based on element value

xslt-1.0
I need help with writing a function in xslt 1.0 that I can pass a list and it'll return the list with duplicates removed. It needs to be a template that I can easily clone or modify for other lists since there are several lists that I want to be...

Displaying output based on attribute value of xml tag

xml,xslt,xslt-1.0
<?xml version="1.0" encoding="UTF-8"?> <provinces> <name num="5">Alberta</name> <name num="3">British</name> <name num="1">Manitoba</name> <name num="4">New Brunswick</name> <name num="2">Newfoundland</name> </provinces> I want output as 1. Manitoba 2. Newfoundland 3. British 4. New Brunswick 5. Alberta I am using the following xslt <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet version="1.0"...

XML/XSLT attribute output

xml,xslt,xslt-1.0
I'm working on a little XML/XSLT project and I'm having trouble retrieving more than one element from the XML file. I want to retrieve the client name(Attribute) and the transaction amount(Attribute) but it doesn't work. The only element attribute I can output is client name. I've tried to change <xsl:template...

cutting the initial string dynamically in xslt

xslt,xslt-1.0
I have the below xml tag as shown its value can be .. <fpml:floatingRateIndex>GBP-LIBOR-BBA</fpml:floatingRateIndex> <fpml:floatingRateIndex>JPY-LIBOR-BBA</fpml:floatingRateIndex> now I have the below xsl tag to extract the value from xml as shownn below.. <abc> <xsl:value-of select="../fpml:floatingRateIndex" /> </abc> the above xsl tag display value as GBP-LIBOR-BBA JPY-LIBOR-BBA now can you please advise...

How to calculate max string-length of a node-set?

xml,xslt,xslt-1.0,libxslt
I am trying to use XSLT to turn an XML document into plain text tables for human consumption. I am using xsltproc, which only implements XSLT 1.0 (so max is from EXSLT actually). I tried the below, but the commented-out definition fails because string-length returns only a single value (the...

Copy only the nodes where the name contains “a”

xml,xslt-1.0
I have an asigment that basically read like this : I have this XMl structure <?xml-stylesheet href="monfichier.xsl" type="text/xsl" ?> <a> <ab x="x"><b>Test</b><a>z</a></ab> <z x="x"><a>z</a></z> </a> And I need to copy all node where the name contains "a" but where the parent also contains an "a". In my example, that would...

Count unique values in comma separated value in xslt 1.0

xpath,xslt-1.0
I have an node in an XML file: <TEST_STRING>12,13,12,14</TEST_STRING> I need to count how many unique numbers/values this string has. For example, in this case there are 2 unique values i.e. 13 and 14. Honestly speaking i could not build anything yet. It seems it is difficult in XSLT 1.0...

Xslt sorting nested nodes before parent by custom string values

xml,sorting,xslt,xslt-1.0
<?xml version="1.0" encoding="UTF-8" ?> <DriverRights> <STAFF> <EmpDetails> <StaffID>123456789</StaffID> <Type>Lorry ABC</Type> </EmpDetails> <EmpDetails> <StaffID>123456789</StaffID> <Type>Jeep</Type> </EmpDetails> </STAFF> </DriverRights> <DriverRights> <STAFF> <EmpDetails> <StaffID>7899878887</StaffID> <Type>Lorry ABC</Type> </EmpDetails> <EmpDetails>...

How do I get a value from an xml file by using an xsl file - the files are in different directories

xml,xslt,xslt-1.0
I'm a newbie to xml and xsl, I've looked everywhere on the web and I know this is probably a straight forward answer but I can't seem to be able to get it to work. The problem I have is that I have a .xml file and a .xsl file...

XSLT Muenchian sorting

xslt,svg,xslt-1.0,muenchian-grouping
I'm trying to get a better understanding of the Muenchian grouping. I'm restricted to XSL 1.0. I was able to do groupings by attributes but I can't seem to get a grouping by element value to work. My XML looks like this: <?xml version="1.0"?> <orders> <order date="2015-01-01"> <product amount="8">Apple</product> <product...

XSL XML transformation, changing namespace value

java,xslt,namespaces,xslt-1.0,saxon
i'm trying to remove some elements from xml using xsl and also to change a namespace value declared in sub1 element. The problem is, when i change the namespace value, the old namespace declaration is inserted into a child element (sub2 in the example), how can i change the code...

How to split table after certain number of columns

xslt-1.0,xsl-fo
I have a little issue that I've been struggling with for a couple of days now. Here is input xml: <Facture> <Mensualite> <Lines> <Line> <NumeroMensualite>1</NumeroMensualite> <AnneeEcheance>2015</AnneeEcheance> <DateEcheance>20150618</DateEcheance> <Montant>163.14</Montant> </Line> <Line> <NumeroMensualite>2</NumeroMensualite> <AnneeEcheance>2015</AnneeEcheance> <DateEcheance>20150718</DateEcheance>...

XSLT 'value-of select' on multiple attribute check at different level

xml,xslt,xslt-1.0
This is a simplifed Xml example for the problem I am facing.I have to set attribute Class value in output xml by matching on NameID & SRNo in <Info> and </Address> . Note: Attributes are at different level. <Detail DetailKey="11119612" DetailNo="123456" DetailType="A"> <Infos> <Info InfoKey="11111599613" SRNo="1" Class="C"> <NameID NameID="121212" />...

how to sum up with recent date in xsl

xml,xslt,xslt-1.0
Input is as follows: <Response> <item> <dt>20141106</dt> <nbr>33456</nbr> <cnt>2</cnt> </item> <item> <dt>20141107</dt> <nbr>33457</nbr> <cnt>1</cnt> </item> <item> <dt>20141207</dt> <nbr>33457</nbr> <cnt>3</cnt> </item> <item> <dt>20140507</dt> <nbr>33458</nbr> <cnt>1</cnt> </item> <item> <dt>20141109</dt>...

Extracting multiple substrings from a string in XSLT 1.0

xml,string,xslt,substring,xslt-1.0
Spent far too long on this seemingly impossible issue today, I'm at my wits end. Would appreciate any help, have search stackoverflow high and low. I have a string I'm trying to manipulate with XSLT e.g. 'man START red END woman START child END rabbit START goose END blue' I'm...

XSLT Transforming XML into a cross referenced, nested HTML lists when source nodes are siblings and nesting is based on attribute values

html,xml,xslt,transform,xslt-1.0
Problem: I need to create a nested HTML unordered list from XML this is not nested. Additionally I need to cross reference the XML with an 'allowed nodes' section that is also contained in the document. Example XML: <content> <data> <navigation> <link name="about us" url="#"/> <link name="staff" url="staff.asp" parent="about us"/>...

Why is substring-before() not working for me in XSLT?

xml,string,xslt,xslt-1.0
I was trying to extract the part of the filename in XSLT using some string functions and cannot understand why it does not work. Here is the sample of XSLT I ran: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:str="http://exslt.org/strings"> <xsl:output method="text"/> <xsl:variable name="A" >some.filename.test.CCYYMMDD.xml</xsl:variable> <xsl:variable name="fileDateSplitChar" select="'.'"/> <xsl:template match="/">...

Obtaining Previous element in xslt 1.0 sort order, not dom order

xml,xslt,xslt-1.0
I have a CD list with entries that are not in any specific sort order: <?xml version="1.0" encoding="UTF-8"?> <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> <cd> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <country>UK</country> <company>CBS...

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...

Nested grouping using XSLT muenchian-grouping

xslt-1.0,muenchian-grouping
I had to group a xml document in xslt 1.0 using Oracle Service Bus. This is the sample input file(Simplified): <?xml version="1.0" encoding="UTF-8"?> <EMailData> <property name="A"> <property name="B"> <property name="C"> <row> <property name="C1"> <value>ValC1</value> </property> <property name="C2"> <value>ValC2</value> </property> <property name="C3"> <value>Valc3</value> </property> <property name="C4">...

XSLT muenchian grouping with the help of key

xml,xslt,xslt-1.0
I am trying to get to a solution and so far have got nothing. What I am trying to achieve is to transform Input: <?xml version="1.0" encoding="utf-8"?> <Root> <Query> <ID>123123</ID> <NameOfTeam>Team1</NameOfTeam> <RaisingYear>2014</RaisingYear> <Brief>N/A</Brief> <TeamMembers> <Member> <Name>Person1</Name> <Role>Role1</Role> </Member> <Member> <Name>Person2</Name> <Role>Role2</Role> </Member>...

XSLT 1.0 pass to call-tempate a set of node names (analog of x in [a1, a2, a3])

xslt,xpath,xslt-1.0
It is an extension of this question. I have an XML fragment like this <lines> <item><code>1.1</code><amt>1000.00</amt></item> <item><code>1.3.1</code><amt>2000.00</amt></item> <item><code>1.3.2</code><amt>3000.00</amt></item> <item><code>2.1</code><amt>4000.00</amt></item> ... </lines> And I want to add up some predefined set of codes. Thanks to an advise, now I can do like this:...

XSLT : storing accumulated values in array like structures

xml,xslt,xslt-1.0
I have a urgent requirement and I am really stuck. I need some expert guidance on this. PFB input xml and the desired output. InputXML <Shipment xmlns="http://www.example.org"> <Container> <ContainerID>C1</ContainerID> <PackedItem> <ItemID>A123</ItemID> <Quantity>4</Quantity> <Total>0</Total> </PackedItem> <PackedItem> <ItemID>A123</ItemID> <Quantity>4</Quantity> <Total>0</Total> </PackedItem> </Container>...

XSLT sort by attribute and attribute value (with exclude)

sorting,xslt,attributes,xslt-1.0,alphabetical
I have a following XML code: <module> <component> <output> <output-test> <exclude-output/> <orderEntry type="specific"/> <orderEntry type="other"/> <orderEntry type="module" module-name="module1"/> <orderEntry type="module" module-name="module3"/> <orderEntry type="module" module-name="module2"/> <orderEntry type="library" name="library1"/> <orderEntry type="library" name="library3"/> <orderEntry type="module" module-name="module4"/> <orderEntry...

XSLT effective sequence based on values

xml,xslt,xslt-1.0
I need to generate an effective sequence where the sequence number should reset after every change of value. Example: <parent> <child> <name>A</name> <date>02/01/2015<date> </child> <child> <name>A</name> <date>02/05/2015<date> </child> <child> <name>A</name> <date>02/05/2015<date> </child> <child> <name>A</name> <date>02/10/2015<date> </child> <child> <name>A</name>...

Pass absolute file path from java code to xslt document()

java,xml,xslt,jaxb,xslt-1.0
In my xslt I'd like to look up an xml file. I need to pass the path to this file from java code.I have the followings: ... Transformer transformer = TRANSFORMER_FACTORY.newTransformer(); transformer.setParameter("mypath", "/home/user/repository"); xslt: <?xml version="1.0"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:param name="mypath"/> ... <xsl:template match="connection[@id]"> <xsl:variable name="lookupStore"...

Complex Grouping using XSLT 1.0

xml,xslt-1.0
I've revised the data file and added a Grouping column. I could not figure out a logic for grouping otherwise. The data contains information for a stamp collection. Here is sample XML: <?xml version="1.0" encoding="UTF-8"?> <stamps> <stamp> <Group>25</Group> <Scott>3133</Scott> <Title>32¢ Thornton Wilder</Title> <Series>Literary Arts</Series> </stamp> <stamp> <Group>26</Group> <Scott>3134</Scott> <Title>32¢ Charlie...

XSLT 1.0 count following-siblings

xml,xslt,xpath,xslt-1.0
I have a simple xml like this <root> <story> <strongp> <color>Attention</color> Text of the single strongp color. </strongp> <p>Text</p> <strongp> <color>Attention</color> Text of strongp color. </strongp> <strongp> Text of interest1 <a id="1234-3457">here</a>. </strongp> <p>sometext</p> <p>sometext</p> <el>sometext</el> <h5>Header H5</h5> <strongp> <color>Attention</color>...

Unique xml node

xslt,xml-parsing,xslt-1.0
I have a simple xml as below, I have to extract the unique rows of p-node <T1> <S1> <p1>0</p1> <p2>0</p2> <p3>0</p3> <p4>0</p4> <p5>0</p5> <p6>0</p6> </S1> <S1> <p1>0</p1> <p2>0</p2> <p3>0</p3> <p4>0</p4> <p5>0</p5> <p6>0</p6> </S1> <S1> <p6>0</p6> <p7>0</p7> <p8>0</p8> <p9>0</p9> <p10>0</p10>...

Opening my XML that references a XSL opens everything in a line

xml,xslt,xslt-1.0
I have an XML file that references a XSL so that when I open the XML file in a browser it automatically applies the transformation. However, when I open the file it all appears in the same line with no format at all. However, if I form an output file...

Apply XSLT on XML get the ancestor value based on current for-each loop count

xml,csv,xslt,xslt-1.0
I am new to XML and XSLT. What I am trying to do is generate a CSV file by applying an XSLT. This is my XML file: <people> <person> <codes> <code>53-8907</code> </codes> <first-name>Matt</first-name> <licenses> <license> <state>TX</state> </license> </licenses> </person> <person> <codes> <code>66-8907</code> </codes> <first-name>Mike</first-name> <licenses> <license> <state>NY</state>...

xslt 1.0 consolidate empty element names

xml,xslt,xslt-1.0
A quick question on using xslt 1.0 that you might be able to help me with. I'm still a noob... so appreciate all the help and support I can get. I have an Input xml that looks like below <Root> <FirstName>Bob</FirstName> <LastName>Marley</LastName> <ID>BM1234</ID> <Songs> <Song> <EmptyElements></EmptyElements> <SongName>No woman no cry</SongName>...

Iterate through siblings until a specific element type

xslt,xslt-1.0
I have a flat XML structure looking like this: <root> <header>First header</header> <type1>Element 1:1</type1> <type2>Element 1:2</type2> <header>Second header</header> <type1>Element 2:1</type1> <type3>Element 3:1</type3> <header>Third header</header> <type1>Element 3:1</type1> <type2>Element 3:2</type2> <type1>Element 3:3</type1> <type2>Element 3:4</type2> </root> Essentialy there is an...

Summing based on matching values XSLT-1.0

xslt,xslt-1.0,xsl-fo
I'm currently trying to work with grouping in XSLT 1.0. I have XML similar to this: <table> <row> <PRODUCER type="VARCHAR" value="PRODUCER 1"/> <PUBLICATION_CODE_-_NAME type="VARCHAR" value="PUBLICATION A"/> <DOMESTIC type="DECIMAL" value="20"/> <FOREIGN type="DECIMAL" value="4"/> </row> <row> <PRODUCER type="VARCHAR" value="PRODUCER 1"/> <PUBLICATION_CODE_-_NAME type="VARCHAR" value="PUBLICATION B"/> <DOMESTIC type="DECIMAL" value="57"/> <FOREIGN type="DECIMAL"...

XSL order of templates for nested elements

xml,xslt,xslt-1.0
I have an XML file like so: <text> <a>foo1</a> <a><b>foo2</b></a> </text> I have an XSL file designed to process <a> and <a><b> differently with templates 1 and 2: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> <xsl:output method="xml" indent="yes"/> <xsl:template match="text"> <xsl:copy>...

XSLT How to grab the value of the following first

xml,xslt,xslt-1.0
I am new to XSLT. I have an XML like this: <root> <story> <p>Text</p> <p>Text</p> <p>Text</p> <strongp> <color>Attention</color> SomeText </strongp> <p> Text of interest1 <a id="1234-3457">here</a> </p> <p>Text</p> <p>Text</p> <h5>Header H5</h5> <strongp> <color>Attention</color> SomeText </strongp> <p> Text of interest2 <a id="8909-3457">here</a> </p>...

XSL group by multiple conditions

xml,xslt,xslt-1.0
I want to group items first by some element value, then to group the results items by other element value with 'or' condition. I'll try to explain myself with the following XML example <root> <request> <id_master>222</id_master> <id_x>1</id_x> <text>hey</text> </request> <response> <id_master>222</id_master> <id_y>1</id_y> <text>hello</text> </response> <request> <id_master>222</id_master> <id_y>1</id_y>...

Replace inner text of sibling of node having some inner text using XSLT

xml,xslt,xslt-1.0
I am having an xml and I am trying to find a node having inner text as 123 then find its following or preciding sibling duration and then replacing its value. XML: <?xml version="1.0" encoding="utf-8" ?> <classes> <class> <id>123</id> <duration>100</duration> <price>price</price> </class> <class> <id>234</id> <duration>10</duration> <price>100</price> </class> <class> <id>123</id> <duration>120</duration>...

Unanticipated behavior

xml,xslt,xslt-1.0,xsl-fo
I've been trying to figure out how to best modularize my XSLT stylesheets to facilitate re-use. I hit upon the idea of using <xsl:apply-imports/> as a way of introducing document-specific attributes to standard tag transformations. This is not working the way I expected it would, and I can't even begin...

XSLT copy elements from second XML if not exist in the first XML

xml,xslt,xslt-1.0
I have the following XMLs: car.xml: <car ref-id="parts.xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <color>red</color> <tire>michelin</tire> <engines> <engine> <model>Z</model> </engine> </engines> <hifi>pioneer</hifi> </car> parts.xml: <?xml version="1.0" encoding="UTF-8"?> <parts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <engines> <engine> <model>X</model> </engine>...

Namespace removal for modified element in XSL

xml,xslt-1.0,xml-namespaces
I am having a input XML, in which one elements schema got changed. So as per the new schema, I renamed it. Now for that particular element, I am getting an extra namespace in the output XML. I used exclude prefixes, but it didnot removed. I want only that particular...

How to remove Multiple tags if present

xml,xslt,xslt-1.0
I have an xml which may or may not produce multiple system number. It should keep only one value if system number and external ID are same. input : <?xml version = '1.0' encoding = 'UTF-8'?> <ns0:updatePersonCrossReference_Input xmlns:ns0="http://xmlns.oracle.com/apps/mdm/customer"> <xsdLocal3:ListOfSwiPersonPublishIO xmlns:xsdLocal3="http://www.siebel.com/xml/SwiPersonPublishIO"> <xsdLocal3:Contact> <xsdLocal3:IntegrationId>0100004568</xsdLocal3:IntegrationId>...

XSLT: Copy an attribute from one node to another

xml,xpath,xslt-1.0
I am relatively new to XSLT and i am working on a project involving xml and xslt1.0. I have a xml code (simplified version) that looks like <visualChildren> <object class="com.zerog.ia.installer.InstallSet" > <installChildren> <object class="com.zerog.ia.installer.InstallBundle" objectID="33110emc908m"> <property></property> </object> <object class="com.zerog.ia.installer.InstallBundle" objectID="43110emc9667m"> <property></property> </object> </installChildren>...

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...

How to retrieve max value with xsl:sort

xml,xslt-1.0
I have a xml file which contains multiple elements of type 'advert'. This last contains as a sub-element price. I wanna extract the max price value using xsl:sort and xsl:for-each which browse all the items....

XSL cannot parse with Firefox

css,xml,xslt,xslt-1.0
When I run xml file in Firefox I get: "Error loading stylesheet: Parsing an XSLT stylesheet failed." And when I run it in Chrome I get blank page. This is XML file: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="g.xsl"?> <forma> <unos> <ime>Marija</ime> <prezime>Rahman</prezime> <ulica>Glasinacka 8</ulica> <postBroj>11000</postBroj> <grad>Beograd</grad> <drzava>Srbija</drzava>...

XPath 1.0, Interpret hex attribute as a number

xslt,xpath,xslt-1.0
I need to compare XML attributes which represent integers, but may be given in decimal or hex (with 0x prefix), using XPath/XSLT-1.0. Here is a (not working) XSLT to demonstrate: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" encoding="iso-8859-1" omit-xml-declaration="yes" /> <xsl:template match="//node"> <xsl:if test="@value &gt; 2"> <xsl:value-of select="@value"/> </xsl:if>...

How to apply two templates and group the result by size and used template with xslt

xml,xslt,xslt-1.0,nokogiri
I am trying to parse an XML and produce an HTML which could be used for printing. The content of the elements in the XML are presented like cards and have information for the frontside as well as the backside. Eight cards would fit on a page. To make life...

XSLT every nth node with a filter

xml,xslt,xslt-1.0
I'm using XSLT for some output formatting, and I want a wrapper element around every N nodes of the output. I've read xslt - adding </tr><tr> every n node?, but my problem is that the source nodes have to come from a lookup: <xsl:for-each select="key('items-by-product', $productid)"> rather than just a...

XSLT add not existing nodes

xslt,xslt-1.0
I have an XML fragment like this <lines> <item><code>1.1</code><amt>1000.00</amt></item> <item><code>1.3.1</code><amt>2000.00</amt></item> <item><code>1.3.2</code><amt>3000.00</amt></item> <item><code>2.1</code><amt>4000.00</amt></item> ... </lines> I want to make a sum of all 1* nodes. The full list is known so I can write something like: <xsl:value-of...

XPath: how to select node that have a sibling containing text?

xpath,xslt-1.0,siblings
I have a Word XML document that is a report template. There are data indentifiers in the document in the places where real data is placed then (at report generation). The question is: what xpath expression should I use to put table row, designated with a given data identifier (i.e....

How to extract domain name from url using xslt 1.0

xml,xslt,xslt-1.0
If you searched in google scholar for example: http://scholar.google.com/scholar?q=filetype:pdf, you can see at the right side the download links for those with pdf (picture below). How can I extract the domain name from the url using xslt? In the picture above, google scholar just displayed the domain names for the...