FAQ Database Discussion Community


XSLT select first non missing value on different path

xml,xslt
I have a XML document along the lines of this: <?xml version="1.0"?><?xml-stylesheet type="text/xsl"?> <Document> <Person> <Name>Joe</Name> <Address> <Country></Country> </Address> <Address> <Country>FR</Country> </Address> <Phone> <Number>11111111</Number> </Phone> <Phone> <Number></Number> </Phone> </Person> <Person> <Name>Jim</Name> <Address>...

xslt variable set based on condition

xslt
I would like to set an xsl variable based on a condition. The xsl below is not currently working for me. I've been able to make two different matchers (<xsl:template match="rule/condition" and <xsl:template match="condition/condition") which enables me to put the ;display:none on just condition/condition matches but that results in the...

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

ProcessBuilder or Runtime.getRuntime().exec won't complete jar execution

java,xml,xslt,cmd,processbuilder
I have a jar which converts one XML to other XML format using XSLT in Java. The jar copies the output to some folder. It is working absolutely fine when am running it on command prompt but running it via Runtime.getRuntime().exec or ProcessBuilder, doesn't complete the process. Just 25 files...

How to display a text only once within an xsl:for-each

xml,xslt
I have an XML with "Drivers" node which can have multiple "Driver" nodes as children. (/Motor/Drivers/Driver) Each "Driver" has a childnode "Accident" which can have a value either Y or N. Now I have an xsl to convert this xml to PDF using Apache FOP. And I have a requirement...

XPath Recursive Descent behaves differently between match and select

xslt
Info Why is there different behaviour of Recursive Descent operator between ● template's match attribute where it is ignored and only children are selected ignoring their descendants ● for-each's select attribute where it works properly Two examples of test.xsl are given which both operate on the following test.xml. test.xml <?xml...

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

Convert meters to foot in xml data via xsl transformation

xml,xslt,openstreetmap
I would like to modify my xml file by converting some values ([email protected]) from meter to foot. I am a newbie to xml and this should be no problem for one of you. The formular is: 1 meter are 3.2808 feet I want to convert the attribute value of node/[email protected]

Adding explicit namespace attribute to particular xml tags

xml,perl,xslt
In a quick-and-dirty conversion from XML generated by one program (htlatex) to another (ArborText Editor), I need to replace all XML of the following form <math xmlns="http://www.w3.org/1998/Math/MathML"> <mn> .... </mn> </math> with <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"> <m:mn xmlns:m="http://www.w3.org/1998/Math/MathML"> .... </m:mn> </m:math> Is there a cleaner easy way to achieve this rather than...

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

Transform XML structure using XSLT

xml,xslt,xpath
I want to transform an XML structure with XSLT. <detaileddescription> <para>Some text</para> <para> <bold>Title</bold> </para> <para>Intro text: <itemizedlist> <listitem> <para>Text</para> </listitem> <listitem> <para>Text</para> </listitem> </itemizedlist> </para> </detaileddescription> This is what I want: <detaileddescription> <para>Some text</para> <List>...

How to add spaces between nodes when using string() on a tree in XPath

html,xslt,xpath,lxml
I have a HTML tree where I use the 'string()' query on the root to get all the text from the nodes. However, I'd like to add a space between each nodes. I.e. string() on '<root><div>abc</div><div>def</div></root>' will become 'abcdef' string() on '<root><div>abc</div><div>def</div></root>' should become 'abc def '...

XslCompiledTransform Transform Method Not Working

c#,xml,xslt,transform
I have a below xslt file. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:gl-bus="http://www.xbrl.org/int/gl/bus/2006-10-25" xmlns:gl-cor="http://www.xbrl.org/int/gl/cor/2006-10-25" xmlns:gl-gen="http://www.xbrl.org/int/gl/gen/2006-10-25" xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:link="http://www.xbrl.org/2003/linkbase"...

XSL - iterate through elements and update based on the node index from another xml file

xml,xslt
I have an XML file with multiple Shape elements each with a child Material element that contains a Code attribute. I want to update the Code attribute for each Material element based on a value that is obtained from a separate XML file. The problem I have is that the...

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

Selecting data in XSL from different sections of XML

xml,xslt
I am new to XSLT. I have an XML- <root> <fiberList> <fiber> <A>abcd</A> <B>bcde</B> <C>cdef</C> </fiber> </fiberList> <generatorList> <generator> <D>defg</D> <E>efgh</E> </generator> </root> I want to transform this XML into another XML through XSL. The resulting XML should be something like this- <parent> <child> <M>abcd</M> <N>bcde</N> <O>efgh</O> </child> </parent> But...

XSL-FO table-cell with superscript and vertical alignment

html,xml,xslt,xsl-fo
This is the situation: I am converting html to xsl-fo to pdf. I am displaying a heading text like "4.4.1. [Header Text]" by use of a table, because it might happen that the [Header Text] is quite long and in that case shall wrap onto the next line like so:...

group siblings by identifying the first node of a certain type in sequence

xml,xslt,xpath
Not sure if that description is the best...but given this xml: <?xml version="1.0"?> <root> <type1 num="1" first="1"/> <type1 num="2" /> <type2 num="3" /> <type2 num="4" /> <type1 num="5" first="2"/> <type1 num="6" /> <type2 num="7" /> <type2 num="8" /> <type1 num="9" first="3"/> <type1 num="10" /> <type2 num="11" /> <type2 num="12" />...

How do I sort EventTime from xml document?

xml,xslt
I would like to sort the EventTime from the sample xml document I have pasted. I want to display the most recent EventTime. My sample xml document <Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="IXML Case Notification Test" MessageID="67085056" xmlns=""> <Case InternalID="1617090499" ID="12125626" xmlns:user="http://tylertechnologies.com"> <CaseEvent Date="05/22/2015" ID="160828152"...

How do I display the correct LocationProvinceCode either US or Canadian?

xml,xslt
I would like to display the correct <nc:LocationCanadianProvinceCode> or <nc-3.0.1:LocationStateUSPostalServiceCode> based on the /Integration/Party/Address/State found in the xml document and by checking if that state code exist in the referring xml document. My xsl is working but it is displaying both US and Canadian State codes. I just want to...

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

Insert tag if and only if it does not exist

xslt
I would like to do an XSLT transformation on an XML file ensuring that tag <B> is inserted into tag <A> if and only if it is not there. Example: <A>foo</A> should become <A><B>foo</B></A> <A>foo <x>bar</x></A> should become <A><B>foo <x>bar</x></B></A> <A><B>foo</B></A> should remain <A><B>foo</B></A> <A><B>foo <x>bar</x></B></A> should remain...

How to do a XSL transform in Java using a not namespace aware parser?

java,xslt,sax,tag-soup
I use tagsoup as (SAX) XMLREader and set the namespace feature to false. This parser is used to feed the Transformer as SAX Source. Complete code: final TransformerFactory factory = TransformerFactory.newInstance(); final Transformer t = factory.newTransformer(new StreamSource( getClass().getResourceAsStream("/identity.xsl"))); final XMLReader p = new Parser(); // the tagsoup parser p.setFeature("http://xml.org/sax/features/namespaces", false);...

XML, XSL namespaces

xml,xslt,namespaces
I'm new to XML especially namespaces. I made all the documents and everything seems to work fine, but I don't know whether I'm really using namespaces (which is requirement). Except that my html file are not valid because off this: "Attribute xmlns:xsi not allowed here." and "Attribute xmlns:xslformatting not allowed...

Web.config transform Insert as first child

asp.net,xslt
When transforming the web.config, how do I insert a web.config node as the first child of the parent? So I have <configuration> <system.webServer> <rewrite> <rules> <rule name="Foo" stopProcessing="true"> ... </rule> <rule name="Bar" stopProcessing="true"> ... </rule> </rules> </rewrite> </system.webServer> </configuration> And I want to insert another rule as the first rule....

What match=“/” actually returns?

xslt
What exactly does match="/" returns if we assume we have XML shown below? As far as I can tell it returns some imaginary top level node which has <people> element as its child. What is the type of this node among those 7 types of nodes: element, attribute, text, namespace,...

Convert XSL 2.0 count by current-group logic into XSL 1.0 logic

xml,xslt,grouping
I'm a novice with XSL and am trying to summarize some XML data based on grouping of substrings of data. I've been trying to get my head around Muenchian grouping and counting but have not been able to get it to work. I took a look at the XSL 2.0...

using template parameter to concat select path xslt

xml,xslt
I am trying a number of different ways to create a re-usable template but am having problems: <xsl:template name="translation"> <xsl:param name="labelName"/> <xsl:value-of select="concat('/Response/Localisation/',$labelName,'/.')"/> </xsl:template> <xsl:template name="translation"> <xsl:param name="labelName"/> <xsl:value-of select="/Response/Localisation/$labelName/."/> </xsl:template> I want to use the template like so: <xsl:call-template name="translation"> <xsl:with-param...

XSL getting out of context using dynamic XPATH

xslt,xpath
I'm trying to reformat an XML I get from an appliance into an HTML table, and it's format is not usual. It use unique references in node name's, like this: /network/content/host/content/REF_1/content /network/content/network/content/REF_2/content and then, it use the same references to another part of the file, as a value of a...

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

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

Transform XML to another XML using XSL based on some condition

xml,xslt
I have an XML - <root> <gereratorList> <generator> <id>1</id> <A>123</A> </generator> <generator> <id>10</id> <A>456</A> </generator> <generator> <id>111</id> <A>789</A> </generator> </gereratorList> </root> I want to transform this XML into another XML through XSL. The resulting XML should be something like this - <parent> <child> <test>456</test> <child> </parent> But I am...

How can I use XSLT to permutate a node hierarchy, part 2

xml,xslt
This question extends a previous question. In the previous question I asked how to permutate the node hierarchy in a tree of fixed depth. For example for every leaf with the path /x/y/z I wanted the leaf in the output to have the path y/x/z. (permutation 2,1,3). Instead of handling...

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

XQuery XML insert

xml,xslt,xquery,transformation,osb
I have XML based target data: <myTargetData> <myMap> <pairs> <key>KEY_1</key> <value> <myMap> <pairs> <key>INNER_KEY_1</key> <value/> </pairs> <pairs> <key>INNER_KEY_2</key> <value/> </pairs> <pairs> <key>INNER_KEY_3</key> <value> <myMap> <pairs> <key>INNER_INNER_KEY_1</key> <value/> </pairs> <pairs> <key>INNER_INNER_KEY_2</key> <value/>...

XSL apply-templates output issues

xslt,apply-templates
Given this XML: <?xml version="1.0" encoding="iso-8859-2" ?> <products> <p> <id> 50 </id> <name> Murphy </name> <price> 33 </price> </p> <p> <id> 40 </id> <name> Eddie </name> <price> 9999 </price> </p> <p> <id> 20 </id> <name> Honey </name> <price> 9999 </price> </p> <p> <id> 30 </id> <name> Koney </name> <price> 11...

get file name of xml file with xsl

xml,xslt
What's the best way to get the name of a currently accessed xml document with xsl 2.0? I guess it's some combination of resolve-uri and base-uri. Base-uri gives me the absolute path, but I only need the name of the file, without the path. Is there a smart way to...

create a xslt 2.0 transformation pipeline with batch file

xml,batch-file,xslt
I have around 20 xsl scripts which need to be executed in a certain order. They each produce an output document that is the input document for the next stylesheet. I only know very basic batch scripting`(mkdir, cd, a simple for loop,...). What would be the best way to do...

Displaying Groups of Multiple Items with same ID using XSLT

xml,xslt
The following solution is nearly perfect. But I discovered that some items have identical Scott numbers but no Minor field. I need to display items with identical Scott #s that have different <Title> fields and data. For example there are two stamps in Scott #s 3090 & 3152 but only...

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

XSLT How to remove style from div and td tags

xml,xslt
I am new to XSLT. I got stuck while removing style attributes from div, td or li tags. Input XML: <?xml version="1.0" encoding="UTF-8"?> <div xmlns="http://www.w3.org/1999/xhtml"> <table style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; WIDTH: 606px; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word; TABLE-LAYOUT: fixed; BORDER-TOP: medium none; BORDER-RIGHT: medium none" class="MsoNormalTable msoUcTable" tabIndex="-1" border="1"...

Remove illegal characters using xslt 2.0

regex,xslt
I need to perform validation on the name field to see if it has any illegal characters. Below is the way ma currently doing it <xsl:variable name="validChars" select="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. "></xsl:variable> <wd:First_Name> <xsl:variable name="illegalFirst" select="replace($getUserData.firstname, $validChars, '')" /> <xsl:value-of select="replace($getUserData.firstname, $illegalFirst, '')"/> </wd:First_Name> The first replace() captures any/all illegal characters and the...

About sorting based on the counting of subelements

xml,xslt
i have an xml document with properties that belong to agencies: <agency name="Century 42" num="Century42" mail="[email protected]"/> <property agency="Century42" ....> ... I would like to print the info of all agencies. The agencies should be sorted by the number of properties that they own. I tried this but it does not...

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: Get all children of parents with specified attributes

xslt,transform
Given this XML: <?xml version="1.0" encoding="iso-8859-2" ?> <r> <products start="5" stop="8"> <p> <id> 50 </id> <name> Murphy </name> <price> 33 </price> </p> <p> <id> 10 </id> <name> Margarethe </name> <price> 11 </price> </p> </products> <products start="1" stop="4"> <p> <id> 555 </id> <name> XXXX</name> <price> 333 </price> </p> <p> <id> 10...

How to XSLT transform XML nested attribute elements and concatenate name

xml,xslt,transformation,pubmed
I am not savvy with XML/XSLT at all. I'm just trying to learn enough to transform this XML file into something that my Access database can use. The XML data was output in an attribute format and Access only likes the element format. I have the basic transformations down, but...

XML to Word using custom paragraph styles and XSLT

xml,xslt,ms-word
I've got an XML file that contains mostly textual information (list of questions in Moodle XML format). I'd like to convert it to a document that can be opened by MS Word, but I'd like to maintain context (using paragraph styles) so I can convert it back to Moodle XML....

XSLT to copy value in a node to another across repeating nodes

xml,xslt
very new to XSLT and needs some help in transforming the XML. The below XML can have multiple "row" tags <?xml version="1.0" encoding="UTF-8"?> <ns1:row> <ns1:City>BALTIMORE</ns1:City> <ns1:Miscdata> <ns1:Building> <ns1:VendorCode>123</ns1:VendorCode> <ns1:Value>2</ns1:Value> </ns1:Building> <ns1:Building> <ns1:VendorCode>345</ns1:VendorCode> <ns1:Value>8</ns1:Value> </ns1:Building> </ns1:Miscdata> </ns1:row>...

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

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

XSLT not working with display:none

xml,xslt
My xml is as below: <?xml version="1.0" encoding="UTF-8"?> <product> <auto> <admin> <date>01/01/2015</date> </admin> <report> <Fname>John</Fname> <Lname>ABC</Lname> </report> </auto> <auto> <admin> <date>02/02/2015</date> </admin> <report> <Fname>Tim</Fname> <Lname>DEF</Lname> </report> </auto> </product> my XSLT as below: <?xml version="1.0" encoding="UTF-8"?>...

TypeError: kendoWindow is not a function

jquery,css,xslt,kendo-ui
I'm trying to resolve a client-side issue that has me scratching my head. What happens is, on my form, I click a button to open a window, and I get the dreaded "TypeError: kendoWindow is not a function" error. There are a few things I should mention about this environment...

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

XML to XML using XSLT: How to check that element exists in output xml and if not create element with default value

xml,xslt
Newbie here with XSLT. I'm creating one XML from another XML. Each XML follows different XSDs but are very similiar. I've been giving a list of required elements that are to be present in final output xml. So I have the xpath of all the required elements. My question is...

XSLT insert sibling if it doesn't exist - Not being rerunnable for some reason

xml,xslt,xpath
I'm trying to add a sibling to an element only if it doesn't exist. Here's my XML: <?xml version='1.0' encoding='UTF-8'?> <domain xmlns="http://xmlns.oracle.com/weblogic/domain" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/security/xacml http://xmlns.oracle.com/weblogic/security/xacml/1.0/xacml.xsd http://xmlns.oracle.com/weblogic/security/providers/passwordvalidator...

'Select' 2 pieces of info (XSLT file)

magento,xslt,sage-erp
I am trying to link our Magento website with Sage 50 with a piece of software. We would like the customers first name and last name to go into the company field. Below are the 3 lines I assume I have to tweak: <Forename><xsl:value-of select="billing_address/firstname"/></Forename> <Surname><xsl:value-of select="billing_address/lastname"/></Surname> <Company><xsl:value-of select="billing_address/company"/></Company> How...

Copying a complete XML Element using XSLT

xml,xslt
I am translating one XML file to another. I want to copy a single, complete element from the original xml into the new xml. I have tried using the identity transformation but can only get that to work if I copy the entire document. If I try to limit to...

XSLT 1.0 - Multiple Child Nodes Formatted Output

xslt,nodes
I can do this with For-Each but having some problems with Apply_Templates. The XML Data contains varying child nodes but I want to display all child nodes with their parents information. <orders> <order> <customer>1</customer> <items> <item> <name>Widget A</name> <price>10</price> <code>1A</code> </item> </items> </order> <order> <customer>2</customer> <items> <item> <name>Widget A</name>...

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

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

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.

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

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

XSL: Recursive call

xml,xslt
So I'm basically stuck at this part in my assignment which I'm unable to solve due to my noob skills in xml. This is a template in hdfunction.xsl: <xsl:template name="sumProduct"> <xsl:param name="list1"/> <xsl:param name="list2"/> <xsl:param name="sumProductTotal" select="0"/> <xsl:choose> <xsl:when test="count($list1) &gt; 0 and count($list2) &gt; 0"> <xsl:call-template name="sumProduct"> <xsl:with-param name="list1"...

XQuery document node test with an element node test in BaseX 8.2 throws in the presence of comments before the root element. Why?

xml,xslt,xquery,saxon,basex
In BaseX 8.2, I'm trying to assign to an XQuery variable, a document node whose root element has a specific name. The source XML looks like this: <?xml version="1.0" encoding="utf-8"?> <!--A comment--> <myRootElement/> To get the document node, I type-check it using a DocumentTest: declare variable $docnode as document-node(element(myRootElement)) :=...

xslt condition output one by one

xml,function,xslt,if-statement,xpath
hope that someone has a suggestion about this: I need to have in each 'a', all the 'b' that have @n equal or bigger than the @n of the 'a' in which they are. I am using xslt 2.0 and Saxon-HE 9.6.0.5 XML source: <blabla> <a n="2"></a> <a n="6"></a> <b...

XSLT get all nodes with text

xml,xslt
I'm trying to loop through all nodes with text in my document from a certain location. <xsl:template name="interpret_text"> <xsl:param name="location"/> <xsl:for-each select="$location//text()"> <xsl:choose> <xsl:when test="name(.) = tag_im_looking_for"> <!-- various code stuff and closing tags --> This code is functional except you may notice my problem. When I enter the for-each...

XSLT on Tree XML

xml,xslt
Here is my XML <?xml version="1.0" encoding="utf-8"?> <Root> <Personal> <Admin> <Code>111</Code> </Admin> <Report> <DataSet> <History> <Claim no="1"> <Subject> <Name> <First>John</First> </Name> </Subject> </Claim> <Claim no="2"> <Subject> <Name> <First>John</First> </Name> </Subject> </Claim> </History> </DataSet> </Report> </Personal> <Personal>...

Unable to copy and modify attribute in XSLT when using a namespace

xml,xslt,xpath
I'm trying to transform an XML document and modify the attributes of single element but the transform is not getting applied if the root element has a namespace attribute. Simply removing xmlns works fine with my code. My XML: <?xml version="1.0"?> <BIDomain xmlns="http://www.oracle.com/biee/bi-domain"> <BIInstance name="coreapplication"> <SecurityOptions sslManualConfig="false" sslEnabled="false" ssoProvider="Custom" ssoEnabled="false">...

How to convert a text in xml to a hyperlink in html using xslt

html,xml,xslt
How to convert a text in xml to a hyperlink in html using xslt. my Xml code is <Steps> <Filepath>C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png</Filepath> </Steps> to convert it into html my xslt code looks like <td width='15%'> <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="./Filepath"/> </xsl:attribute> <xsl:value-of select="./Filepath"/> </xsl:element> </td> Now this code writes the entire...

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

XLST concating two arrays

arrays,function,xslt
and I'm trying to concat two string arrays in special way. Lets say that arrays look like like this: first array (arg1): 'A', 'B', 'C' second array (arg2): '-3', '', '-4' The result should be (one string): 'A-3/B/C-4' But with my code I'm getting result like this (only last part...

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 remove data if attribute value is higher than threshold

xml,xslt,math,operator-keyword,relational
I am newbie to XSLT. My am is to remove elements from XML based on a field if it is higher than some threshold value which I will be getting as parameter to it. My XML is as shown below: <tns:PM objectClass="MyNode" objectName="" className="com.project.converter.PMFamilyConverter" interfaceName="ComponentPM" xmlns:tns="http://www.myproject/SS/PMSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.myProject.com/SS/PM.xsd"> <tns:family desc="family0"...

Merging XML files using XSL drops matched element

xml,xslt
I have been working on merging XML files using XSL and have a problem. The element I wish to insert the new xml into <Shapes></Shapes> is being dropped and a new unwanted element is being introduced. Here's the XSL I am using: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" extension-element-prefixes="msxsl"...

XSL transformation outputting multiple times and other confusion

xml,xslt,xpath
I'm attempting to transform a section of an XML document (which is mostly HTML) with a templated piece of markup should a particular pattern be matched. I'm inexperienced with XSLT (I've only used xpath, really) and online documentation is sparse so I'm struggling with it... To the following XML document:...

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

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

apply-templates based on attribute id value

xslt
My XML is as below <?xml version="1.0" encoding="UTF-8"?> <product> <admin id="1"> <name>abc</name> </admin> <admin id="2"> <name>kkk</name> </admin> <product> Here is my XSLT <xsl:template match="product"> <ul> <xsl:apply-templates select="admin"/> </ul> I want to apply templates on "admin" based on attribute id value. How to apply templates based on attribute value? New question......

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

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

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

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

Difference between ancestor and ancestor-or-self

xslt,selenium,xpath,selenium-webdriver
I know about ancestor in xpath but what is this ancestor-or-self. when we have to use ancestor-or-self.Please give me any examples.

XSLT sort order to match order of different parent node

xml,xslt
I have two nodes that incidentally share a subset of their data. I need to sort the first set based on the original order of the second. To give an example, consider the following sets of points and lines. Every "start" and "end" point for each line will in every...

XSLT for Mutiple Child structure

xml,xslt
I am converting XML to HTML using XSLT. Here is my running code <?xml version="1.0" encoding="UTF-8"?> <product> <auto> <admin> <date>2015</date> <age>28</age> <level>3</level> <subject> <id>1</id> </subject> </admin> <report> <Fname>John</Fname> <Lname>AA</Lname> <subject> <id>1</id> </subject> </report> </auto> <auto> <admin> <date>02/02/2015</date>...

XSLT for-each statement not iterating proper amount of times

xml,xslt
I am having trouble with my XSLT for-each statements. When I run the XML through the XSLT, it only comes up with the first iteration of the list, and then stops. It doesn't post the values either. Here is the XML code. <?xml version="1.0" encoding="UTF-8"?> <template> <L> <Q>Hey</Q> <Q>There</Q> <Q>Thank...

How do I display NcicCode matching VehicleMake (MncisCode)?

xml,xslt
I have a xml document with <VehicleMake Word="MERC">Mercury</VehicleMake>element. I would like to match it with the <NcicCode>MERC</NcicCode> code. My output is only displaying the first <NcicCode> that matches <MncisCode>. The <MncisCode> in the referring document is the same as <VehicleMakeCode> code in my xml document. Current output <ext:Vehicle> <j:VehicleMakeCode>MERB</j:VehicleMakeCode> </ext:Vehicle>...

XSLT filePath with document as variable

variables,xslt,filepath
I try to use a variable in the filePath, but it isn't working: BodyPart filePath="C:\\FileOutEmail\\($vpDocNr).xml" content-type="" content-id="" content-disposition="" multipart-type="" I also tried with the whole path in a variable without results: BodyPart filePath='$bestand' content-type="" content-id="" content-disposition="" multipart-type="" Is this possible, what is the right syntax?...

Determine year quarter from specific date XSL

xml,date,xslt
I need a function to determine which year quarter a date belongs to. I found an Excel function and tried to apply the same logic in xsl but it does not work <xsl:function name="bi:Quarter"> <xsl:param name="value"/> <xsl:variable name="quarter"><xsl:value-of select="round((((month-from-date($value)-1) mod 3)+1))"/></xsl:variable> <xsl:value-of select="$quarter"/> </xsl:function> Your help will be appreciate. Thanks!...

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

List unique values of an attribute within a group only for specific criteria in XSL 1.0

xml,xslt,unique,groups
I need to list the unique values of an attribute in a group, when another attribute has a specific value. Making this work in XSL 1.0 is very tricky to understand. Thanks to another post, I now have the groupings defined to allow me to perform counts when attributes match...

Math operations in xsl template - XSLTranform geocoordinates from deg to meters

xml,xslt,math
I haven't been able to make this work. I'm trying to make a template for an xsl tranformation of degrees geocoordinates to meters. The function in PHP is like this and works just fine: function degtometers($lon, $lat) { $half_circumference = 20037508.34; $x = round($lon * $half_circumference / 180); $y =...

Check the node is present or not in xslt

xml,xslt
I am new to xslt, Though I manage to work on it. But I struck with one case for which I need a help from expert. I am trying to finding the node which is Exists or not. I already search this same question, in which I didn't get the...

Sorting XML based on several sub-elements using XSLT

xml,sorting,xslt
I'm trying to sort some XML (using XSLT) based on a few child elements and return the result as XML. I know it's probably not that difficult but this is my first experience using XSLT and it's giving me some troubles. Here's the XML: <root> <subject> <courseSubjectHeader> <subjectCode>B</subjectCode> <subjectName>text</subjectName> <unit>text</unit>...

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

removing a parent node dependig upon child node using xslt

xml,xslt
i am looking forwar for an template that removes anode from xml depending upon the value of a chid node,basically i am having an xml like: <EventInfo> <AssignmentEvent> <CreateDateTime>2015-06-02T00:00:00+02:00</CreateDateTime> </AssignmentEvent> <EstimateEvent> <CreateDateTime>2015-06-02T07:38:28.0000000Z</CreateDateTime> <CommitDateTime>2015-06-04T14:29:38.0000000Z</CommitDateTime> <UploadDateTime>2015-06-04T14:29:39.7651796Z</UploadDateTime>...

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