Menu
  • HOME
  • TAGS

Apply a predicate to the current node

xslt,xpath,xpath-1.0

The syntax .[predicate] is not allowed in XPath 1.0 on account of the syntax rules (see the end of this post for the gritty details). 100% of the advice I have found says that the only option is to use self::node() for this: self::node()[Featured = 'true'] This XPath tester is...

Xpath to select all and exclude child and its children

xml,xpath,xpath-1.0

This expression selects all nodes, but does not include in the result set any nodes that are RejectedRecords or that have RejectedRecords as an ancestor: //*[not(descendant::RejectedRecords) and not(ancestor-or-self::RejectedRecords)] Here is a link to the result in XPath Tester...

In XSLT 1.0 how to create a lookup function on XML data embedded in the XSLT using key and document('')?

xslt,key,document,lookup,xpath-1.0

In XSLT 1.0, the key() function works only in the context of the current document (in XSLT 2.0 it has a third argument, allowing you to select the context). In order to use the key on nodes in another document, you must first switch the context to that document -...

What is the official definition of number literals in XPath 1.0?

xml,xslt,xpath,xslt-1.0,xpath-1.0

80% of the way through typing this question I found my answer, so I figured I should follow through and post it here in case anyone else is ever looking for this obscure bit of trivia. The production for Numbers is defined in the Lexical Structure section: [30] Number ::=...

Xpath count non-empty descendants

xml,xpath,xpath-1.0

I think you want count(//*[not(*) and normalize-space()]) i.e., those that themselves don't have child elements but do have some text. If you want to count actual, physical text nodes, that would be count(//*[not(*)]/text()) With your input that results in two text nodes being selected, but it would also count empty...

Distinct values with XSLT 1.0 when XPath has multiple criteria

xslt,xpath,xslt-1.0,distinct,xpath-1.0

Here's a different implementation of Muenchian grouping - one that allows you to parametrize the criteria by which the movies are selected. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:param name="genre" select="'Comedy'"/> <xsl:param name="director" select="'B'"/> <xsl:key name="year" match="year" use="." /> <xsl:template...

How do I produce the required XML output grouping and sorting by like source nodes?

xml,xslt,xpath-1.0

As I suggest in my comment, the technique you're looking for is called Muenchian grouping. This works by defining a key that groups related nodes together, then using a trick with generate-id or count to construct a node set consisting of one "representative" node for each group. In your case,...

Round up in XPath 1.0

xpath,numbers,number-formatting,xpath-1.0

You can use the ceiling() function. It takes a number as an argument and it will replace the number by the next integer which is larger than the number. In XPath you also have the round() function which replaces the number by its nearest integer (larger or smaller), and floor()...