Questions tagged [xslt-2.0]

Use this tag for questions specific to XSL Transformations version 2.0 and no other version.

XSL Transformations version 2.0, the successor to XSLT 1.0. It introduces the following features:

  • xsl:function: user defined functions that can be invoked from within XPath expressions

  • XPath extension mechanism: a formal means of invoking methods written in other languages from within an XSLT expression

  • unparsed-text-available(): checking a URL to insure that it returns text content

  • unparsed-text(): loading non-XML content into an XSLT transformation

  • Sequences: collections of atomic data types or XML objects

  • Date/Time API: functions to manipulate date formats

  • Numeric iterations: expressions that facilitate loops without recursion

  • xsl:analyze-string: text processing of a string based on a regular expression

  • xsl:next-match: allows multiple template rules to be applied to the same source node

  • xsl:result-document: send output to a file or web service

  • xsl:for-each-group: allows nodes to be organized and referenced as a group

  • Inline control keywords: XQuery extensions for iterating and conditional statements in XPath

  • xsl:character-map: map entities to some output form, to replace disable-output-escaping

  • tunnel attribute: allows pass-through of a parameter to a nested template which depends on it

There are several standalone XSLT 2.0 processors, including:

Online Training Courses

Books available online

See also:

  • Saxon CE is an implementation of XSLT 2.0 that runs in any modern browser; it includes extensions that provide declarative handling of user interaction events.

News: As of June 8th 2017, XSLT 3.0 is a Recommendation of the W3C Consortium and therefore the latest version of XSLT.


4654 questions
5
votes
2 answers

Can you use to go through attributes?

Is it possible to use the command on attributes? I want this to be able to run without knowing the attribute names. Here's a quick (terrible) example: In my head (this doesn't work) it…
user673869
  • 221
  • 1
  • 3
  • 10
5
votes
2 answers

Determining the context for position() in a template with multiple predicates

I'm having some trouble determining the correct context for a node set. I have a template match that looks a bit like this (using XSL 2.0):
Christina
  • 1,349
  • 1
  • 12
  • 22
5
votes
3 answers

Assigning a string to a variable depending on condition in xslt

I want to assign a value to a variable if a particular attribute returns a particular value. In here I want to assign the value "young" to vaiable "person" if pr:all/[@pr:name=current()/@cx:name]/pr:properties/(@ls:middlename) is "cengie". Is that…
harsh
  • 2,399
  • 9
  • 29
  • 47
5
votes
3 answers

Flat to Nested structure based on attribute value using XSLT

I have a flat structured XML file as below:
Cylian
  • 10,970
  • 4
  • 42
  • 55
5
votes
2 answers

XSLT Generating Folders

I am trying to parse an XML file into smaller XML files and place them into folders. The folders get generated based on some of the elements in XML. How do I generating folders in XSLT? I was able to generate files using xsl:result-document, but so…
user1325843
  • 199
  • 2
  • 7
4
votes
1 answer

How does code a fall-back for functions not yet available it XSLT?

How do I make the unparsed-text-lines() function effectively available to both XSLT 2.0 and XSLT 3.0 processors in the one style-sheet? I thought that I could use the function-available() function like so, but this returns a syntax error for an XSLT…
Sean B. Durkin
  • 12,659
  • 1
  • 36
  • 65
4
votes
2 answers

Referencing current node's position in xpath expression

(Note: This post has been edited to show specific use case. See bottom.) I want to use the current node's value of position() inside an xpath expression (in which the context changes). Unfortunately, I don't see any simple way of doing this because…
David R
  • 994
  • 1
  • 11
  • 27
4
votes
4 answers

xsl: Can a named template return a node list?

I am using a recursive template that searches for some specific elements like this:
Kangkan
  • 15,267
  • 10
  • 70
  • 113
4
votes
1 answer

XSLT 2.0: How to iterate over stored values of an array inside a for-each loop with conditional check?

I am writing xsl stylesheet to extract information from iTunes Music Library. xml file. I want to store track information of playlists in an array and later iterate over them to get more information. I am confused how to store values in an array in…
Rakesh Singh
  • 858
  • 1
  • 12
  • 31
4
votes
2 answers

How to check if xml textnode has Chinese characters with RegEx in a XSLT

On this website http://gskinner.com/RegExr/ (which is a RegEx test website) this regex match works Match: [^\x00-\xff] Sample Text: test123 或元件数据不可用 But if I have this input XML: test123…
therealmarv
  • 3,692
  • 4
  • 24
  • 42
4
votes
4 answers

What is the range of count attribute in xslt?

I am using one xslt file for count the number of elements in an XML file that have a particular value (to verify uniqueness) and stored in xsl variable name. This xml file is created programatically and value of the number of the elements sometimes…
Saravanan
  • 11,372
  • 43
  • 143
  • 213
4
votes
1 answer

Grouping section of xml

I'm having some problems grouping a part of an input tree into a container element and leaving other parts intact. I am trying to use the for-each-group as an exercise. Logic: Process elements with template matches and try to detect when an element…
Zug_Bug
  • 186
  • 10
4
votes
4 answers

How to split text and preserve HTML tags (XSLT 2.0)

I have an xml that has a description node: A first sentence here. The second sentence with some link The link. The third one. I am trying to split the sentences using dot as…
Lycaon
  • 73
  • 7
4
votes
1 answer

Enumerated Values based on distinct ones XSLT 2.0

I have a long list of values in XML with named identifiers. I need to make separate output files for each of the distinct identifiers grouped together and uniquely named. So, for example, let's say I have:
Jon W
  • 15,480
  • 6
  • 37
  • 47
4
votes
1 answer

Can an XSLT 2.0 function return arbitrary types?

I am trying to write an XSLT 2.0 function that returns a result of a specific type--let's say one or more elements. Here's what I've tried, to no avail:
Ignatius
  • 235
  • 3
  • 10