xslt-1.0

How to search node value using loop in XSLT?

扶醉桌前 提交于 2019-12-25 02:27:12
问题 From below code I want to check whether network B is present in one of the operator station node or not. If present then returns true or false. Actually I want to achieve the code like break statement in loop. But as break is not exist in XSLT then please suggest me solution to achieve it. Please follow the same code and suggest using key or variable value as list of record. XSLT: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:w3="http://www.w3.org"> <xsl

How to sort based on different nodes?

心已入冬 提交于 2019-12-25 01:54:13
问题 I need to sort my tags in a XML file based on multiple different nodes. For example: Consider the following XML: <root> <a> <b>12</b> <e>hello</e> </a> <a> <b>11</b> <e>how</e> </a> <a> <c>13</c> <f>are</f> </a> <a> <b>21</b> <f>you</f> </a> <a> <d>22</d> <e>hello</e> </a> <a> <c>14</c> <f>hi</f> </a> </root> Now I need to find the maximum number from inside all the nodes inside a . I tried doing this: <xsl:template match="root"> <xsl:for-each select="a"> <xsl:sort select="b | c | d" data

Merging data from multiple xml files without duplicates using XSLT

夙愿已清 提交于 2019-12-25 01:49:16
问题 Similar questions have been asked, and I've read them and tried to figure this out using tutorials and what not, but haven't been able to. I am sure it's a matter of writing the correct xpath, but I can't seem to figure it out. I'm trying to take a list of files (basically everything in a folder) and combine them into a different schema format. The trick is that part of the information from the individual files needs to be used as a lookup table in the resulting XML. My solution needs to be

Increase in Metaspace with TransformerFactory's XSLT Transformer

僤鯓⒐⒋嵵緔 提交于 2019-12-25 01:41:46
问题 When I run the following code with multiple different requests, the java metaspace is getting increased. public String applyXsltOnXml(String xmlString, String xsltInput) throws TransformerException { String result = null; try (StringReader stringReader = new StringReader(xmlString); StringWriter writer = new StringWriter()) { TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(new StringReader(xsltInput)));

how to extract particular elements

扶醉桌前 提交于 2019-12-25 01:17:05
问题 I need to extract customer names with "Name" and save it in a variable. Input is any dummy xml like response variable should have only this <customer name="Name">John</customer> <customer name="Name">Kevin</customer> <customer name="Name">Leon</customer> <customer name="Name">Adam</customer used this stylesheet <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:template match="/"> <xsl:variable name="request">

Creating a JSON from xml with date and time logic templates

天大地大妈咪最大 提交于 2019-12-25 01:14:11
问题 I'm trying to create a JSON from a XML which has messages and each message has its date/time. Below is the XML <message> <messageText heading="Temporary Maintenance Message 1">test message1</messageText> <displayScheduleContainer> <startDate>22/05/2019</startDate> <startTimeHrs>12</startTimeHrs> <startTimeMins>45</startTimeMins> <noEndDate>true</noEndDate> </displayScheduleContainer> </message> <message> <messageText heading="Temporary Maintenance Message 1">test message2</messageText>

Make new node using sub-node sub-string

家住魔仙堡 提交于 2019-12-25 00:32:28
问题 I have an xml document that looks like this: <oldEle userlabel="label1"> <ele1>%02d.jpeg</ele1> </oldEle> <oldEle userlabel="label2"> <ele1>%02d.tiff</ele1> </oldEle> I want it to be this: <JPEG userlabel="label1"> <ele1>%02d.jpeg</ele1> </JPEG> <TIFF userlabel="label2"> <ele1>%02d.tiff</ele1> </TIFF> I've tried this. <xsl:template match="//xmlns:oldNode[contains(//xmlsns:oldNode/root:ele1, '.')]"> <xsl:element name="{translate(substring-after(//xmlns:ele1, '.'), 'abcdefghijklmnopqrstuvwxyz',

XSLT date format translation from eg: Aug 23 2018 to 23/08/2018

◇◆丶佛笑我妖孽 提交于 2019-12-25 00:27:26
问题 How to do date format translation from e.g: Aug 23 2018 to 23/08/2018 using XSLT? 回答1: XSLT 1.0 does not have any date functions and you will need to use string manipulation functions to convert from one format to another and translate Aug to 08 using some processing logic. XSLT 2.0 does have format-date() function however the input format expected by this function is YYYY-MM-DD which can then be converted into formats shown in these examples. You can use the below options for converting the

How to translate a flat XML structure into hierarchical XML using XSLT 1.0?

怎甘沉沦 提交于 2019-12-24 23:54:28
问题 Starting from an exemplary, ungainly formatted XML structure: <list> <topic> <title> Paragraph 1 </title> </topic> <topic> <main> Content 1 </main> </topic> <topic> <main> Content 2 </main> </topic> <!-- ... --> <topic> <main> Content n </main> </topic> <topic> <title> Paragraph 2 </title> </topic> <topic> <main> Content 1 </main> </topic> <!-- ... --> <topic> <main> Content n </main> </topic> </list> The contents of "title" and "main" are merely placeholders. The content of "title" is

XSLT Sort grandchild nodes and pick the value of another grandchild

為{幸葍}努か 提交于 2019-12-24 21:01:16
问题 I am trying to figure out the XSLT (CSV output) for the below XML. I would like to sort the grandchildren nodes i.e. sort Month node and pick the Sales_Program-ID node value of the set with the highest month value. XML <Root> <Level1> <EMPLID>123</EMPLID> <Program> <Sales_Program Name="XYZ"> <ID1>ab</ID1> </Sales_Program> <Start_Date>Jan1st</Start_Date> **<Month>1</Month>** </Program> <Program> <Sales_Program Name="ABC"> <ID1>cd</ID1> </Sales_Program> <Start_Date>Feb1</Start_Date> **<Month>2<