xslt-2.0

Looping over distinct values

Given a variable which returns a list of distinct States using the distinct-values() function, is there a way to tokenize the variable in a for-each loop? <States> <State>AL</State> <State>AL</State> <State>NM</State> </States> The following variable returns AL and NM, but I can't iterate over it using for-each. Is there a way around...

Applying templates to elements in a variable/sequence

When I use "apply-templates" and select a variable sequence, does the template act upon the context of the element in the sequence, or does it act upon the context of the element in the document? In the below example, it seems to do either, or none, but I don't understand why. <root> <a/> <b/> <c><a/></c> <a/> </root> <?xml version="...

XSLT 2.0 How to do counters and variables across various loops and structure

So, I know you can't access variables outside scope, that they're immutable, that XSLT is functional not imperative, etc... But I need a general purpose approach to something that would be trivial with global mutable variables (that sounds evil just saying it :). Here's an example... <xsl:template match="t1"> <xsl:if test="someLogic"...

It is possible to set a priority on a "group-starting-with"-clause?

Hello, this is an example of my input file. <root> <!-- [...] --> <bbb>Foo 1</bbb> <aaa>xxxxxxxx</aaa> <aaa>xxxxxxxx</aaa> <aaa>xxxxxxxx</aaa> <bbb>Foo 2</bbb> <ccc>Foo 2.1</ccc> <aaa>xxxxxxxx</aaa> <aaa>xxxxxxxx</aaa> <aaa>xxxxxxxx</aaa> <bbb>Foo 3</bbb> <ccc>Foo 3.1</ccc> <aaa>xxxx...

XSLT 2.0 How to change default formatting for numbers?

In XSLT 1.0 (using Xalan), outputting the result of: <xsl:variable name="source0" select="number(num3)"/> <xsl:value-of select="$source0"/> was the number spelled out as 2011234. But in XSLT 2.0 (using Saxon), it shows up as 2.011234E6. I want it to always display as 2011234 in the Saxon/2.0 case. Is there a way to set the default pi...

Retain number of digits during processing input->number->output during XSLT processing

For this XSLT: <xsl:variable name="source0" select="number(num2)"/> <xsl:variable name="source1" select="number(num3)"/> s0 plain: <xsl:value-of select="$source0"/> s1 plain: <xsl:value-of select="$source1"/> test11: <xsl:value-of select="format-number($source0, '#.#')"/> test12: <xsl:value-of select="format-numb...

what do I need to use XSLT 2.0 with Delphi

what do I need to use XSLT 2.0 with Delphi(win32)? At the moment I use MSXML6 for all my xml transformation. But MSXML6 has no support for XSLT 2.0. The solution (by ErvinS) Using the AltovaXML library. After installation you have to import the AltovXML typelibrary. Then you can use a source like this: procedure TfrmMainAltovaXmlDemo.b...

Convert dateTime to unix epoch in xslt

Hi. I have a dateTime variable, and I want to convert it to a decimal value of epoch. How can this be done? I tried using: seconds-from-duration($time, xs:dateTime('1970-01-01T00:00:00')) but it just returns 0. Please advice. Thanks. ...

When will xslt 2.0 be finished

I really want to start developing in xslt 2.0 but I have been hearing that xslt 2.0 is not supported in browsers yet. Is there an expected date that xslt 2.0 will be done and when will it be supported in browsers? ...

xslt Parsing in .NET

Hi all, Consider following snippet code for xml. <rootnode> <child id="child1" ><![CDATA[child 1]]></child> <child id="child2" ><![CDATA[child 2]]></child> <child id="child3" ><![CDATA[child 3]]></child> <child id="child4" ><![CDATA[child 4]]></child> <child id="child5" ><![CDATA[child 5]]></child> <child id="chi...

retrieving XML value dynamically using XSL function

my input xml file looks like <root> <sub> <element1 value="abc"/> <element2 value="123"/> </sub> <sub1> <element1 value="ert"/> <element2 value="abc"/> </sub1> </root> i need an XSLT function which reads below XML file and pulls the xpath expression value specified at map/domain/instance/@xpath from above f...

How to set the base URI for an XSLT script?

Is there a way to set the base URI in XSLT so it applies for the whole document like in XQuery? I.e. declare base-uri = "someuri"; ...

General substitution over all XML (XSLT)

Basically, what I'm doing right now is running an XSLT, then opening the result in Visual Studio and doing a find and replace for one word - for this example, I want to change all instances of "bar" to "myBar". All instances of "bar" may be assumed to be in text elements like so: <someElement>bar.whatever</someElement> This would be t...

A question about <xsl:sort> using XSL 2.0 and datatype extensions

Does anyone know of an example of defining a datatype using xml schema and using it in a XSL template with a xsl:sort instruction Thanks in advance. ...

Substituting values over many XML elements [XSLT 2.0]

Hello everybody, This question is an extension of this one. I have many values, as seen below: <myStuff> <elem1>asdf</elem1> <elem2>foo bar</elem2> <elem3>foo bar foo</elem3> <elem4>foofoo</elem4> </myStuff> I've been doing a copy-of over MOST the elems (the select in the copy-of is very specific) and then doing a fin...

XSLT for-each question

I have an xml <Root> <Parent> <Child1>A</Child1> <Child2>B</Child2> <Child1>X</Child1> <Child2>Y</Child2> </Parent> </Root> Child2 always will be with child1. I need to know how I can loop through using xsl:foreach and create an XML output example. <TransformedXML> <Child attribute1="A" attribute2="B"/> <Chil...

xslt grouping question

Possible Duplicate: xslt grouping question I have an xml <Root> AAABBB XXXYYY EEEFFF GGGHHH Child2 always will be with child1. I need to know how I can loop through using xsl:foreach and create an XML output example. I may have other nodes like but my concern is only Child1 and Chid2 nodes ...

xslt grouping question

I have an xml <Root> <Parent> <Child1><Node1>AAA</Node1><Node2>BBB</Node2></Child1> <Child2><NodeX>XXX</NodeX><NodeY>YYY</NodeY></Child2> <Child1><Node1>EEE</Node1><Node2>FFF</Node2></Child1> <Child2><NodeX>GGG</NodeX><NodeY>HHH</NodeY></Child2> <OtherChild></OtherChild> </Parent> </Root> Child2 always will b...

What are XSLT Result Trees

I am reading a book on XSLT 2.0. I am on the chapter of XSLT Result Trees. Frankly, i don't understand it a bit. What are result trees? What is it used for? Why is it important? ...

Test if document is well formed before parsing

I need to analyze a few thousand XML documents to see if some of them contains a certain construct. The problem is that some of the documents doesn't contain well formed XML. The basic idea was to use fn:collection() and search inside nodes returned. But this only works if all documents in the collection are well formed. Is it possible...