xslt

quick xslt for-each question

Let's say I have an XML document that has this: <keywords> <keyword>test</keyword> <keyword>test2</keyword> <keyword>test3</keyword> <keyword>test4</keyword> </keywords> And i want to use XSLT to print it out in HTML like this: <ul> <li>test</li> <li>test2</li> <li>test3</li> <li>test4</li> </ul> What would my XSLT look like? I tr...

Using JQuery to manipulate HTML elements created from XSLT

Sorry if the title doesn't explain things well. I have a situation where I am using DHTMLX AJAX component to display XSLT out to HTML. So the idea is this: There is a containing HTML page with a DIV which the xslt will be displayed into. The xslt file of course which is very simple.. just display a couple of XML elements into <p> tag...

Not able to calculate in XSLT after switching the PHP locale

To get "," instead of "." as a decimal point, I set the locale via setlocale("de_DE");. When I now transform an XSLT stylesheet that contains a calculation like: <xsl:variable name="a"> <xsl:choose> <xsl:when test="$someboolean"> <xsl:value-of select="0.5"/> </xsl:when> <xsl:otherwise> <xsl:value-...

Help with combining alternate rows of 2 XML files and displaying it as one HTML table

I have 2 XML files and I would like to display them in one HTML table having alternate rows from each file. I know of an approach using XSLT, can someone guide me on how this can be done? ...

XSL for-each: how to detect last node?

I have this simple code: <xsl:for-each select="GroupsServed"> <xsl:value-of select="."/>,<br/> </xsl:for-each></font> I'm trying to add a comma for each item added. This has 2 flaws: Case of when there's only 1 item: the code would unconditionally add a comma. Case of when there's more than 1 item: the last item would have a com...

Exclude XML directive from XslCompiledTransform.Transform output

I'm using an XsltCompiledTransform to transform some XML into a fragment of HTML (not a complete HTML document, just a DIV that I will include in page generated elsewhere). I'm doing the transformation as follows: StringBuilder output = new StringBuilder(); XmlReader rawData = BusinessObject.GetXml(); XmlWriter transformedData = Xml...

if element not exists create xml element

I am facing a problem that is in my xml file somewhere some particular xml element is exists or not exists. so i want to create the element where not exist with value 0. Below is my xml file and xslt file. <?xml version="1.0" encoding="UTF-8" ?> <Jobs> <Job ID="84590099" PositionID="61838475"> <Title>Graduate Developer / Jun...

How to maintain a count within nested elements using XSLT?

Related to the question here. I have XML input of the form: <book> <chapter> ... </chapter> </book> I am currently outputting something like: <div class="book" id="book-3"> <div class="chapter> ... </div> </div> Using the rule <div class="book" id="book-{position()}"> to create the a book id. So tha...

XSLT: What this exactly do: test="element[@attribute]"

what this exactly do : <xsl:if test="./employee/first-name[@id='14']" > I mean, when will this case be true, if ./employee/first-name[@id] != null or "", or what exactly? EDIT: I have edited the statement above, so it test if element first-name with id=14 have a body or its body contains a data or return true if first-name event don...

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="','" /> ...

Is XSL the right tool to deliver and process custom forms?

I am developing an ASP.NET MVC application on which I provide the end users with a particular form asking for pretty standard stuff, name, phone number, address, etc. However, some of the users will need to ask me for additional pieces of input, for which I have no way to plan. In addition, some of these forms may have slightly differe...

In XSLT, how do you select/copy part of the document as text only?

In XSLT, how do you select/copy part of the document as text only? The change I want to make is to take part of the tree (tags and values both) and output it as text only (preferably with brackets HTML-encoded). I tried to put a CDATA around my copy-of, but it simply put the copy-of command inside my document. Edit: See comment below ...

Maintain all xml elements in xml file

Hi friends, in my xml file elements are not constant like say my file is <alpha> <a>...</a> <b>...</b> <c>...</c> </alpha> <alpha> <a>...</a> <c>...</c> </alpha> <alpha> <a>...</a> <b>...</b> </alpha> <alpha> <a>...</a> <b>...</b> <c>...</c> </alpha> I meant to say i want to maintain all elements in my xml file by ...

How to get server side variable value in xsl template?

I want use localized strings from resources in xsl template as in aspx page, like this: <%=GetLocalizedString("grid_numberof_claim")%>. I am trying use <xsl:text disable-output-escaping="yes"> <![CDATA[<%=GetLocalizedString("grid_numberof_claim")%>]]> </xsl:text> but it is not useful. Actually i can pass localized strings inside...

xsl recursive loop node by index

I have created a recursive template for getting the first n number of items from my XML. It uses an index(counter) just like how I would in a for loop. Now how can I get a node from my XML using the index? I have tried [position()=$index] but it had weird behaviour when trying to get deeper nodes in the XML hierarchy. If I have XML su...

XSLT transform with multiple XML input files

Is it possible to perform a transform on multiple input XML files? It doesn't appear to be possible using XslCompiledTransform, but is there an alternative way of applying an XSLT? ...

Muenchian Grouping - group within a node, not within the entire document

I'm trying to use Muenchian grouping in my XSLT to group matching nodes, but I only want to group within a parent node, not across the entire source XML document. Given XSLT and XML as follows (apologies for the length of my sample code): XSLT <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www...

Quick question, how can I display my XSL code in a browser

Hello! I'm learning XSLT and, for testing purposes, would like be able to simply display my XSL code inside of a browser via a link from another page. With the following anchor tag... <a href="transform.xsl">My Test XSL Transform Code</a> The code isn't displayed when the link is clicked, it's executed. How can I display the code w...

xsl loop to split a fragment tree every n times

This is a sample of my XML, it can possibly have thousands of rows of items in a range of categories. <store> <products type="computer"> <item desc="text" amount="99"></c> <item desc="text" amount="69.95"></c> <item desc="text" amount="4.50"></c> <item desc="text" amount="10"></c> <item desc="text" amount="9.99"><...

role of xsl in dynamically generating HTML pages from relational database.

can anybody explain the role that XSL can play when dynamically generating HTML pages from a relational database? ...