xslt

xslt concatenate text from nodes

I have an xml file that looks like this: <args> <sometag value="abc"> <anothertag value="def"> <atag value="blah"> </args> keep in mind that tag names within args could be named anything (I don't know ahead of time) Now i have this xml file stored in a variable called $data which I loaded using a document() call in the xslt styl...

Sorting by selectbox in XSLT

I have this selectbox on a site Im currently building and what I want to do, is sort a list of items displayed on the page by the value that's being selected. The problem is that I got different kinds of data types, e.g. location and price. If I want to sort on location, no problem it sorts perfectly on alphabetic order of the location...

XSLT parse text node as XML?

In the middle of an XML document I'm transforming, there is a CDATA node which I know itself is composed of XML. I would like to have that "recursively parsed" as XML so that I can transform it too. Upon searching, I think my question is very similar to http://stackoverflow.com/questions/1927522/handling-node-with-inner-xml-in-xslt. T...

Converting plain text into html style lists using xstl, or grouping elements according to their contents and their positions using xslt

Trying to convert a plain text document into a html document using xslt, I am struggling with unordered lists. I have: <item>some text</item> <item>- a list item</item> <item>- another list item</item> <item>more plain text</item> <item>more and more plain text</item> <item>- yet another list item</item> <item>even more plain text</ite...

Convert XML to CSV using XSLT

How to convert XML to CSV (to be shown in Excel file) using XSLT? Provided XML value itself contains comma, e.g. <name>The,Bad Boy</name> My logic considers "The" & "Bad boy" as separate values as it goes in different columns after opening in Excel file. ...

Changing file extensions within a XML file

This one is a bit of a tricky one. I have a contents.xml file that references a host of other files. These other files use to be .xml, and have been altered to .dita, my question is how can i renames all the .xml file extensions to .dita? The file paths are a varying levels in the tree and have an inconsistent number of subfolders in ...

Transform with XSLT a XML list into a comma-separated with 'and' for the last entries and a final .

I have a list like: <members> <name>Lorem Ipsum</name> <name>Lorem Ipsum</name> <name>Lorem Ipsum</name> <name>Lorem Ipsum</name> </members> That I need to conver to: Lorem Ipsum, Lorem Ipsum, Lorem Ipsum and Lorem Ipsum. How this can be done? I suppose that in XSLT 1.0 I will need to loop for-each, but how to apply...

XSLT table lookup and sum(preceding-sibling::...)?

I have an XML document that has nodes in it that look like this: <Variable name="var1" dataType="INT32"/> <Variable name="var2" dataType="INT16"/> <Variable name="var3" dataType="INT8"/> I can loop over the variables and display the name and data type just fine, but I'd like to display the size of the variable, as well as the offset o...

Transforming XML so it can be read with DataSet.ReadXML

I have been given an XML document in a rather strange format and I need to load it into a DataSet, but unsurprisingly I get an error when I try to do so. I can see how I could transform the document into something that would work, but I'm kinda going around in circles with the XSLT stuff... The document looks something like this: <map>...

XSLT 1.0 Unique Elements

Hi, I am attempting to use preceding-sibling to select unique elements from a group. Using the folliwng xml as an example.. <items> <item> <options> <option> <option-data> <data-ab>TEST1</date-qualifier> <date>20101026</date> </option-data> <option-data> <data-ab>TEST2</date-qualifier> <date>20101...

Merging sequences of elements in XSLT

I've got wads of autogenerated HTML doing stupid things like this: <p>Hey it's <em>italic</em><em>italic</em>!</p> And I'd like to mash that down to: <p>Hey it's <em>italicitalic</em>!</p> My first attempt was along these lines... <xsl:template match="em/preceding::em"> <xsl:value-of select="$OPEN_EM"/> <xsl:apply-templa...

XSL Use a specific template inside another one

Hello, I've got some problems with XSL : is it possible to use a template from another one, when it uses an apply-templates to print childs ? I don't want to use current node, but really create a new element matching the template. Example of what I'm searching : XML file : <root> <toto name="foo"> <b>hello</b> </toto> </root>...

How do I write an xsl-stylesheet to translate parts of a document based on content of matching tags...sort of?

I have a xml-structure thar looks a little like this: <Page> <Id>Page1</Id> <Content> <Header>This is the Header</Header> <Body>This is the body</Body> <Nested> <NestedItem> <Id>N1</Id> <Content>This is a nested element</Content> </NestedItem> <NestedItem> <Id>N2</Id> <Content>This too is a nested elemen...

XSL: translate() with html in replacing string

Hi, I have an xml document that looks like this. <?xml version="1.0"?> <services> <service sn="1" family="2 Week Wait"> <service_name>2 Week Wait Dermatology</service_name> <speciality>2 Week Wait</speciality> <clinic_types>2 Week Wait Skin</clinic_types> <tag>Malignant neoplasm of skin , Pigmented skin lesion </tag...

List every node in an XML file.

Simple situation... With any random XML file, I want to create a list of every node that it contains, but without any duplicates! So something like: <root name="example"> <child id="1"> <grandchild/> </child> <child id="2"/> <child id="3"/> </root> Is translated to: /root /root/@name /root/child /root/child/@id /root/chil...

How does one insert XSLT elements with attributes inside of javascript inside of a html attribute?

Question summary: What changes do I have to make to make the following xslt document valid. The following is a simplified version of a theme document I am trying to modify for a Gizmox WebGUI DataGrid control. The issue I am having with it is the horrendous onclick event attribute on the button element. I have tried the code both this...

How to add templates to existing XSLT that uses for-each loops to generate HTML?

I have a stylesheet that generates HTML for XML files. Example XML file: <?xml version="1.0" encoding="utf-8" ?> <?xml-stylesheet type="text/xsl" href="trial.xsl"?> <wholeEnchilada> <Interface> <Messages> <Message name="blah"> <Variable name="DialogIdentifier" dataType="UINT16"/> <Variable name="ReplyCount" ...

Consolidate xmlns attributes to the root element?

I'm converting a set of XML documents from one format, which doesn't include namespace prefixes, to another, which does. Everything is relatively straightforward, but it's a bit repetitive in the XMLNS output. Below is an example. (Very Simple) Input XML <?xml version="1.0"?> <a/> XSLT <!-- xmlns="http://www.w3.org/1999/xhtml" --> ...

Get N characters introduction text with XSLT 1.0 from XHTML

How I can get first n characters with XSLT 1.0 from XHTML? I'm trying to create introduction text for news. Everything is UTF-8 HTML entity aware (&nbsp; &amp;), one entity = one character HTML tag aware (adds missing end tags) Input HTML is always valid If input text is over n chars add '...' to end output Input tags are restricted t...

Can we use values fetched from database table in XSLT ?

Hello Everyone, I have a database with me consisting of certain tables. I have written a query to fetch some fields from a table and stored those fetched values in some variables. Now, I am looking for a way which will allow to assign values fetched from database to the XSL variables. I am trying to generate a HTML page using fetched va...