xslt-2.0

Using grouping to pull together text and then test it

So in this grotty extruded typesetting product, I sometimes see links and email addresses that have been split apart. Example: <p>Here is some random text with an email address <Link>example</Link><Link>@example.com</Link> and here is more random text with a url <Link>http://www.&lt;/Link&gt;&lt;Link&gt;example.com&lt;/Link&gt; near ...

Problem in sorting xml in XSLT 2.0 any ideas?

Hello I am trying to sort my xml by number of occurence of element 'answer' with attribute 'id' and get simply summary. <person id="1"> <answer id="A"/> <answer id="B"/> </person> <person id="2"> <answer id="A"/> <answer id="C"/> </person> <person id="3"> <answer id="C"/> </person> I want simply summary text on output: A = 2...

Typing an XSLT template/function as a sequence constructor?

Very simply, is it possible to type an XSLT template or function to return a named sequence constructor? e.g. in FpML, there is the Product.model group, which simply contains two elements (ProductType and ProductId). I'd like to be able to create a typed template which returns that sequence, but have no idea what the "as" attribute shou...

Getting the stylesheet directory from within the XSL file- for configureable xml location

I have a xsl file for an xml. The location of the the xml files should be configurable (that's done by configuring the href path to stylesheet in the xml) but the xsl is using some images and some othe javaScript files and need to hav teh path to them. The path is right near the stylesheet file so once I can get the xsl directory I can g...

How to find a word within text using XSLT 2.0 and REGEX (which doesn't have \b word boundary)?

I am attempting to scan a string of words and look for the presence of a particular word(case insensitive) in an XSLT 2.0 stylesheet using REGEX. I have a list of words that I wish to iterate over and determine whether or not they exist within a given string. I want to match on a word anywhere within the given text, but I do not want t...

XSLT: attribute value used as numeric predicate

Given <xsl:variable name="datePrecision" as="element()*"> <p>Year</p> <p>Month</p> <p>Day</p> <p>Time</p> <p>Timestamp</p> </xsl:variable> The expression $datePrecision[5] returns a nodeSet containing one text node with value "Timestamp", as expected. Later in a template, with a context element having an attribute @pr...

XML transform element appearing in wrong place in document

I am having some problems with an XML transform and need some help. The stylesheet should iterate through all suffix elements and place the contents without the suffix tag next to the last text node within its first ancestor quote-block element (see desired ouput). It works when only a single suffix is present, but not when 2 are prese...

Adding <span> tags to all text nodes between custom self closing tags.

I have a pair of custom self closing tags s1 and s2 defined in namespace x in my xhtml. For each tag pair s1, s2 having the same id, I want to add span tags to all the text nodes between them. Each s1, s2 tag pair have a unique id. i am looking for a XSL based solution for the same. I am using Saxon java processor for XSL. Sample input...

How do i select all text nodes between two elements, using XSL?

I want to get the generate-id(.) of all the text nodes after node <m/> and before node </n>. I am looking for some generic XSL and not tightly coupled to the sample input pattern mentioned below. For any input pattern i want to get the ids of all the text nodes between node <m/> and <n/>. Sample input for better understanding: <a> <b...

How do i modify the XSL to change the xml format.

In the below XSL every time the xsl:when gets satisfied I want to append as many <a> and </a> tags. But the data that needs to be populated inside the tags should be only once. I have shown the expected output at the end. <xsl:param name="insert-file" as="document-node()" /> <xsl:template match="*"> <xsl:variable name="input">My text<...

Actual element tags are not getting captured.

I am using the below piece of XSL code to construct a span tag calling a javascript function on mouseover. The input to the javascipt should be a html table. The output from the variable "showContent" gives just the text content but not along with the table tags. How can this be resolved. XSL: <xsl:variable name="aTable" as="...

How do I de-duplicate a list of nodes in XSLT - and return the last node encountered?

I've seen lots of "de-duplicate this xml" questions but everyone wants the first node or the nodes are identical. I have a bit of a bigger puzzle. I have a list of articles in XML, a relevant snippet is shown: <item><key>Article1</key><stamp>100</stamp></item> <item><key>Article1</key><stamp>130</stamp></item> <item><key>Article2</key...

How do I ADD an Attribute to the Root Element in XML using XSLT?

I want to match a root Element “FOO” and perform the transformation (add a version attribute) to it leaving the rest as it is. The Transformation I have so far looks like this: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://schemas.foo.com/fooNameSpace"&gt; <xsl:template match="//FOO"> ...

How to group and sum values in XSLT

For each "agency" node I need to find the "stmt" elements that have the same key1, key2, key3 values and output just one "stmt" node with the "comm" and "prem" values summed together. For any "stmt" elements within that "agency" that don't match any other "stmt" elements based on key1, key2 and key3 I need to output them as is. So after...

How do i select the preceding nodes of a text node starting from a specific node and not the root node?

How do i select the preceding nodes of a text node starting from a specific node whose id i know instead of getting the text nodes from the root node? When i invoke the below piece from a template match of text node, I get all the preceding text nodes from the root. I want to modify the above piece of code to select only the text node...

Grouping on Multiple Field

Hi , I am generating XML file from Database as below... <?xml version = '1.0'?> <T0019> <IFTA_ACCOUNT> <IFTA_CARRIER_ID_NUMBER>705</IFTA_CARRIER_ID_NUMBER> <IFTA_LICENSE_NUMBER>631227666</IFTA_LICENSE_NUMBER> <IFTA_BASE_COUNTRY>US</IFTA_BASE_COUNTRY> <IFTA_BASE_STATE>AL</IFTA_BASE_STATE> <IFTA_STATUS_COD...

xsl:variable does not return a node-set in XSLT 2.0?

Hi all, I'm trying to get a node-set from a xsl variable for calculating. But my code only work with Opera, with other browsers, I keep getting the error. Please help me fix to run with all browser. Thanks in advance. Here are the xslt code: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3...

Add XSLT 2 schema to Visual Studio 2010 for intellisense

I'd like to add the XSLT 2 schema to Visual Studio 2010 to provide intellisense. I've added the schema to C:\Program Files\Microsoft Visual Studio 10.0\Xml\Schemas (removing the XSLT 1 schema), but to no avail. The schema seems to have been parsed by Visual Studio, as I can hover my cursor over the namespace declaration in the stylesheet...

Improving the performance of XSL

I am using the below XSL 2.0 code to find the ids of the text nodes that contains the list of indices that i give as input. the code works perfectly but in terms for performance it is taking a long time for huge files. Even for huge files if the index values are small then the result is quick in few ms. I am using saxon9he Java processor...

XSLT: look for a word and its context

Hello! I need to search a word and its context into an xml. For example <line>hello world, my name is farhad and i'm having trouble with xslt</line> looking for 'and', context of 3 words: <line>hello world, my <span class="context">name is farhad <span class="word">and</span> i'm having</span> trouble with xslt</line> How can i do?...