xslt

XSLT processing when order is important

I'll admit I'm new to xslt and I'm going through various tutorials and documentation as I go, but I have a situation that I'm not sure how to look up the answer for. Basically it is this. I have an xml document that looks like so... <tag1> <tag2> foo </tag2> <tag3> bar </tag3> <tag2> goo </tag2> <tag3> mar </ta...

Detecting Characters in an XSLT

I have encountered some odd characters that do not display properly in Internet Explorer, such as these: “, –, and ’. I think they're carried over from copy-and-paste Word content. I am using XSLT to build the page content and it would be great to detect these characters in the XSLT and replace them with valid HTML codes. I alread...

How do I transform xml from axis2 services using jQuery and AJAX?

I'm running into a problem with axis2 and ajax. I'm getting xml from one of my web services with jQuery's ajax functions, and using this jquery plugin to transform the result xml to html. Here's an example of the relevant xml that the service returns. <ns:getPatientsByDoctorResponse> <ns:return type="com.emolst.jdbc.PatientBean"> ...

How to loop with XSLT through hierarchical nodes?

I am trying to traverse Docbook section nodes. Their structure are as follows: <sect1> <sect2> <sect3> <sect4> <sect5> </sect5> </sect4> </sect3> </sect2> </sect1> So sect1 only have sect2 inside, sect2 will only have sect3 inside, and so on. We can also have multiple sub nod...

Converting XML document for use with .NET 2.0 TreeView control

I have an XML file which is in the following format: <root> <category> <doctype> <name>Doc1</name> <site> <name>Site1</name> <target>iframe</target> <url>http://www.gmail.com&lt;/url&gt; </site> </doctype> <doctype> <name>Doc2</name> <site> <name>Site2</name> ...

XSLT foreach

Hi i have a strange issue with matching specific attribute of xml node. Example code that doesnt work: <xsl:for-each select="../../unit/service/price/season[@name=$period_name]"> <xsl:attribute name="std_bed_price"> <xsl:value-of select="../@amount"/> </xsl:attribute> </xsl:for-each> Example code that DOES work but...

Populating a standard .net 2.0 GridView / TreeView control using XML from a database as opposed to an XML file

At present I am populating a standard .net 2.0 GridView & TreeView control using a physical XML document which uses an XSLT stylesheet. But i need to make the population of the grid more dynamic, while still using the XSLT style sheet Does anyone know if it is possible to populate a standard .net 2.0 Gridview & TreeView control another ...

XMLStarlet: XML parsing error

xsltCopyText: text allocation failed runtime error: element value-of xsltValueOf: text copy failed Got this error when parsing XML (wikipedia dump, actually) w/ XMLStarlet. I can get page titles and ids, but when it comes to page texts, it fails. Expression used: xml sel -N xmlns=http://www.mediawiki.org/xml/export-0.3/ -T -t -m "//x...

Group List of nodes into Tree of nodes with XSL

Hi, I'm parsing a huge word file with Test descriptions, and have a problem of scope of nodes. Word basically creates a list of paragraphs and I want to group them into a parent node. So for each node 'A' I want to group all the following nodes up to the next node 'A' into 'A'. How can this be done with XSL? Example: I've gotten to : ...

How do I generate a comma-separated list with XSLT/XPath?

Given this XML data: <root> <item>apple</item> <item>orange</item> <item>banana</item> </root> I can use this XSLT markup: ... <xsl:for-each select="root/item"> <xsl:value-of select="."/>, </xsl:for-each> ... to get this result: apple, orange, banana, but how do I produce a list where the last comma is not present? ...

XSLT Decimal formatting based on input XML.

I have a situation where my XSLT files should display prices alongwith decimals conditionally, depending on whether the input XML contains decimals or not. So, I can receive XML files with two types of values - XML will contain all prices formatted with decimals upto two places (I call this one "Decimal-XML") or the prices will be rounde...

What is the best java web application framework that goes well with xml+xslt?

I recently learned a bit about xml/xslt and would like to try it in my web project. What framework would you recommend for that? Basically, I want to generate a dynamic xml that will be applied to xslt stylesheet on the client side. Wicket was my first candidate, but it is primarily html-centric. Didn't manage to get my idea work yet. ...

How not to copy some attributes?

I need to copy from input document to output document all attributes but one. My input is like this: <mylink id="nextButton" type="next" href="javascript:;" /> And I need output like this: <a id="nextButton" href="javascript:;" /> If I use the following XSL: <xsl:template match="mylink"> <a><xsl:copy-of select="attribute::*"/...

XSLT filter with an index counter

I've written some XSLT that uses one XML document to filter another. Now I'd like to number my output elements using position(), but my filtering condition is not built in to my <xsl:for-each>, so position() gives me results with numbering gaps. How do I get rid of the gaps? <xsl:variable name="Astring"> <a><b>10</b><b>20</b><b>30</b>...

XSLT: help me fix multiple BODY tags

I need to postprocess some HTML that has bad structure -- e.g. <html> <body>...</body> <body>...</body> </html> What's the best way to transform this HTML so that the contents of the second body appear inside the first, except of course the extra body tag? I don't want to manipulate anything else with this rule. I've thought of match...

XSLT transformation problem with dynamic attribute

This is something that work: $curRow[1]/@gridClose but let say that I do not know the attribute name "gridclose". I will loop and get this attribute with the code. With the debugger I can get the value "gridClose" with : $curCol/@id. So I am trying to get something like : $curRow[1]/@{$curCol/@id} But it doesn't work. Any idea ho...

How to Iterate Over Unknown Columns in XSLT

Hi .... The Title pretty much says it all. I have an XML document that I am processing with XSLT .... but I don't know how many columns (fields) that are in the XML document (therefore, obviously, I don't know their names). How can I determine the number of "unknown" fields there are? Also, how can I read the attributes, if any, for ...

Use XSLT Variable as Field Name

Hi .... I have an XSLT variable that I'm creating and populating with the value of an attribute at the top of the style sheet like so ... <xsl:variable name="MyAttributeValue" select="/Source/Fields/Field[@SpecialAttribute]/@MyAttributeValue" /> Later on in the processing, I want to use $MyAttributeValue as a field name just lik...

Load old XML data into new version of InfoPath form

We have an ASP.NET application with an InfoPath forms component, delivering InfoPath forms to the browser using InfoPath Forms Server. Rather than save the forms in SharePoint, we submit the XML form data to a ASP.NET web service, which saves the data as an XML data type in SQL Server 2005. This is working fine, and we have no issues l...

XSL 101 - How to generate a basic XSL style sheet for a given XML document?

Below is a snippet of what you get when you save the configuration of IIS 6/Windows Server 2003 web sites to a file: <?xml version ="1.0"?> <configuration xmlns="urn:microsoft-catalog:XML_Metabase_V64_0"> <MBProperty> <IIsWebServer Location ="/LM/W3SVC/1" AppPoolId="DefaultAppPool" DefaultDoc="Default.htm,Default.asp,index.h...