xslt-1.0

Tokenizing and sorting with XSLT 1.0

I have a delimited string (delimited by spaces in my example below) that I need to tokenize, sort, and then join back together and I need to do all this using XSLT 1.0. How would I do that? I know I need to use xsl:sort somehow, but everything I’ve tried so far has given me some sort of error. For example, if I run the code at the bot...

"Regular expression"-style replace in XSLT 1.0

I need to perform a find and replace using XSLT 1.0 which is really suited to regular expressions. Unfortunately these aren't available in 1.0 and I'm also unable to use any extension libraries such as EXSLT due to security settings I can't change. The string I'm working with looks like: 19;#John Smith;#17;#Ben Reynolds;#1;#Terry Jacks...

When test hanging in an infinite loop

I'm tokenising a string with XSLT 1.0 and trying to prevent empty strings from being recognised as tokens. Here's the entire function, based on XSLT Cookbook: <xsl:template name="tokenize"> <xsl:param name="string" select="''" /> <xsl:param name="delimiters" select="';#'" /> <xsl:param name="tokensplitter" select="','" /> ...

XSLT:How to deal with testing the value of an element ?

I have an xml file in which there is tag namely, <Gender/> It carries either 'M' or 'F' as data, now my work is to test the value and write <Gender_Tag>Male</Gender_Tag> or <Gender_Tag>Female</Gender_Tag> according to the values M or F respectively .. I tried this code .. It used to work in other circumstances.. <xsl:template match="roo...

Performing a "Group By" query in XPath XSL

Hi, Given the following XML: <results name="queryResults"> <int name="intfield1:[* TO 10]">11</int> <int name="intfield2:[10 TO 20]">9</int> <int name="intfield1:[10 TO 20]">12</int> </results> I would like to produce this XML: <results> <field name="numberfield1"> <value name="[* TO 10]">11</value> <val...

How to extract unique characters from a string using XSLT 1.0 ?

one of the toughest challenges I have ever faced in XSLT designing .. How to copy the unique characters in a given string .. Test xml is: <root> <string>aaeerstrst11232434</string> </root> The output I am expecting is: <string>aerst1234</string> ...

(XSLT, Code optimization) How to output the nodes refering to the value of sibling-nodes .. ??

I am transforming XML to XML using XSLT, The objective is to read the value of tag <node1>, if it is null then it must be assigned with the value of <node2>, if incase <node2>, is also null, then default text "Default" has to be assigned .. to both tags .. EDIT: If <node2>is null and <node1> isn't .. then the code shouldn't update <node2...

XSLT 1.0 How to extend with fn (function namespace)

Hello everyone, I was wondering how I can possible extend XSLT 1.0 so that I can use functions from fn function namespace at http://www.w3schools.com/Xpath/xpath_functions.asp I was just told that the system is using MSXML XSLT processor from now on. All my stylesheets were written in 2.0 ... So now I'm stack, nothing is working and d...

(xslt 1.0) How to replace the space with some string from all the text values in xml ?

EDIT: [it started with character replacement and I ended up with discovering string replacements with help of Dimitre Novatchev and Roland Bouman I think the sample codes are sufficient to explain the requirements .. This is the sample XML: <root> <node1>text node</node1> <node2>space between the text</node2> <node3> h...

Grouping every 3 items in xslt 1.0

I'm having troubles to figure out a way to group items xslt 1.0. I have a source xml similar to the one below: <client name="client A"> <project name = "project A1"/> <project name = "project A2"/> <project name = "project A3"/> <project name = "project A4"/> </client> <client name="client B"> <project name = "projec...

XSLT Attribute not being added

Trying to mark radio inputs as selected with XSLT 1.0 using the below xslt code but this does not produced the desired result desrired result <input type="radio" value="available" title="email" selected="selected" /> Actual output <input type="radio" value="available" title="email" selected /> Anyone any ideas why not please?...

XSLT 1.0 recursion

I'm stuck with recursion, was wondering if anyone can help me out with it. I have <Receipts> and <Deposits> elements, that are not verbose, i.e. that a <Receipts> element doesn't have an attribute to show what <Deposit> it is towards. I need to figure out <Deposits> "still amount due" and when a last receipt towards it was paid if any. ...

XSLT 1.0 help with recursion logic

Hello guys, I'm having troubles with the logic and would apprecite any help/tips. I have <Deposits> elements and <Receipts> elements. However there isn't any identification what receipt was paid toward what deposit. I am trying to update the <Deposits> elements with the following attributes: @DueAmont - the amount that is still due...

Removing related elements using XSLT 1.0

I'm attempting to remove Component elements from the XML below that have File children with the extension "config." I've managed to do this part, but I also need to remove the matching ComponentRef elements that have the same "Id" values as these Components. <Fragment> <DirectoryRef Id="MyWebsite"> <Component Id="Comp1"> <Fi...

Including a plain text file with XSLT 1.0

How can I include the content of a plain text file in a result document from within an XSLT 1.0 stylesheet? I.e., just like document(), but without parsing it: <xsl:value-of select="magic-method-to-include-plaintext(@xlink_href)" /> I am almost sure, that this doesn't work without extension, because: there is a special XPath functio...

Formatting XML using XSLT1.0

Hi, I have the following xml: <Subscriptions> <Subscription> <Uplink> <Size>15</Size> <Unit>Mbps</Unit> </Uplink> <Name>Class D</Name> </Subscription> <Subscription> <Uplink> <Size>10</Size> <Unit>Mbps</Unit> </Uplink> <Name>Class A</Name> </Subscription> <Subscription> <Downlink> <Size>50</Size> <U...

XSLT 1 Plain Text Spacing

Using Perl's XML::LibXSLT necessitates that I use XSLT 1.0, which means that I am stuck without XSLT 2.0 features. Is there a way that I can still pad text cleanly in a plain-text output from my processing? What I want is: <values> <headers> <header>Header 1</header> <header>Header 2</header> </headers> <va...

XSLT 1.0 count element with the same value in an attribute, and show it

I have a variable containing: <col p1="Newman" p2="Paul"/> ... <col p1="Newman" p2="Paolo"/> <col p1="Newman" p2="Paul"/> i wold in output a table with in the first column the value of p2 and in the second the number of time it appear. For each value of p2 should i have only a row. <table> <tr><td>p2</td><td>num</td></tr> <tr><td>Pau...

XSLT1.0 Rendering sequence of different elements stored in a variable as M x N table

Hello everyone, I have the following XML (it is simplified and most attributes are omitted): <Document> <Transfer Name="" From="" To=""/> <Transfer Name="" From="" To=""/> <OtherElement/> <OtherElement/> <Flight AirLina="" From="" To=""/> <Flight AirLina="" From="" To=""/> <OtherElement/> <Hotel Name="" Duration=""/> ...

XSLT To HTML with Simple Grouping of XML Data using templates instead of for-each

I have been messing with xslt off and on since I became a sharepoint administrator, it uses xslt alot for displaying list data. I have recently started using it to transform database results that I have converted to xml using an extension method. I am trying to produce clean html. My first attempt, worked fine. However I used for-eac...