xslt

XPath/XSLT Optimization ?

Hey, I'm basically taking fileA.xml, grabbing nodes from totally distinct parts of the file, and building a new tree in fileB.xml. Relative paths are a bit confusing now because once I get to a node nested 3 down, and I need to add another node which is nested 4 down from a totally different branch, I start needing global xpaths. Ques...

Basic XML/XSLT transform: search & replace

I'm new to XML and XSLT and have spent a bit of time on what should be a pretty simple search-and-replace case. I just can't seem to get the syntax correct. The overall goal of this exercise is to replace the values of 'Y' and 'N' in element 'NewCustomer' with 'true' or 'false' respectively. Here's my sample data. <?xml version="1.0"...

Transform XML with XSLT and preserve CDATA (in Ruby)

I am trying to convert a document with content like the following into another document, leaving the CDATA exactly as it was in the first document, but I haven't figured out how to preserve the CDATA with XSLT. Initial XML: <node> <subNode> <![CDATA[ HI THERE ]]> </subNode> <subNode> <![CDATA[ SOME TEXT ]]> ...

XSLT: change namespace in transformer, not in in stylesheet / remove namespace prefix

I am transforming some XML using XSLT and Saxon like this: Source sourceXML = new StreamSource(...); Source sourceXSLT = new StreamSource(...); System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl"); TransformerFactory transFact = TransformerFactory.newInstance(); Templa...

XSL - Invalid Xpath Extension on Replace

Im getting on error when I try and use the following: <xsl:variable name="url" select="guid"/> <xsl:variable name="vid" select="substring-after($url,'podcast/')"/> <xsl:variable name="pre" select="substring-before($vid,'.mp4')"/> <<xsl:variable name="p" select="replace($pre,'_','-')"/> <xsl:variable name="p1" select="concat($p,'.e...

JQuery and XSLT

Good day, I have stumbled upon a bug or some strange behaviour and I can't find the solution anywhere. I use XSLT to display HTML from a XML document. Inside that stylehsheet, I use javascript/jQuery to add some contents. But apparently you can not append anything but texts to any container. <script type="text/javascript"> <![CDATA[ ...

XSLT - how to deal with <![CDATA[

Im trying to output some XML using XSLT, however I've just come across this: <description><![CDATA[<p>Using Money &ndash; recognise coins, getting change, paper money etc. A PowerPoint resource containing colour coded levels to suit different abilities &ndash; special needs. Self checking and interactive.</p>]]></description> How do I...

Most efficient way to do an XSL transformation on a DataSet?

What is most efficient way (code example) to do an XSL transformation on a DataSet in .NET 2.0? ...

XSLT - Converting time to minutes

Id like to be able to convert the following XML <itunes:duration>00:09:54</itunes:duration> To a total of minutes, I currently just output the complete value but I would like to just display: 0hr 9min 54sec Or possibly round up to the nearest minute? ...

Regular Expression in XSLT

I have an XSLT function that takes a regular expression as a parameter but the XSLT parser does not like it. Here is the code: <xsl:value-of select='ns:RegexReplace($variable, "", "style=\"\w+\:\s\w+;\"")' disable-output-escaping='yes' /> I found this: http://www.xml.com/pub/a/2003/06/04/tr.html <-- but it is using what I am and seem...

XSLT menu generation problem

Here is a template I call to generate a menu, and it kinda breaks. Using Xalan, I get heap size error, so my guess would be that something in it is horribly broken and unholy. I preset the template for the current portion of the website tree, feeding it the path from the root of the site, the language, the current depht (p-i), and a fil...

XSL test for text present in node when another one is in the way

Given the following XML is it possible to test to see if there is any text present after the list but still within the quote-para node. This is probably really basic but I can't get my head around where to start with this one: <quote-block open="&quot;" close="&quot;"> <quote-para>In the result I would restate the <emphasis strength="no...

XSLT: A simple way to merge xml files

I have two xml files. I need to merge them together where the element "myid" matches between the two. Please have a look at these example files... File1.xml: <?xml version="1.0" encoding="ISO-8859-1"?> <catalog> <data> <title>Title1</title> <description>Description1</description> <myid>1</myid> </data> <data> <...

Will Firefox do XSLT on external entities?

What I'm trying to do is take an XML document, let's say http://example.org/data.xml and show it with an XSL stylesheet applied. (I cannot modify the document itself and add a directive) So there are a couple of utility XML files like this: wrapper.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE wrapper [ <!ENTITY content SY...

XSLT - Sorting multiple values

I've already created my XSLT but id like to be able to sort the data, also add some kind of index so i can group the items together, the difficulty Im having is the the node i want to sort by contains multiple values - values id like to sort by. For example here is my XML: <item> <title>Item 1</title> <subjects>English,Maths,Science,...

How do you transform an xml that is too big to work with any of the .net transform classes?

I am using .NET XmlReader because the xml file is way too big to use a DOM or other in-memory class, but I need to be able to somehow walk back up the xml hierarchy from the current position in XmlReader. Is there a way to do that? I sometimes need to walk back up to the level one parent to retrieve content. I could cache some xml as I p...

SVG via dynamic XML+XSL

This is a bit of a vague notion which I have been running over in my head, and which I am very curious if there is an elegant method of solving. Perhaps it should be taken as a thought experiment. Imagine you have an XML schema with a corresponding XSL transform, which renders the XML as SVG in the browser. The XSL generates SVG with ...

Url link encoding within XSLT

I'm trying to link to a SharePoint page from an HTML document produced using an XSL transformation, but it keeps complaining that the link is invalid: <a href="site.aspx?List={5r45d0e2-f7eb-4658-a585-3277gr4327ee}&amp;RootFolderUrl=url&amp;Name=name">My Link</a> Obviously, the link is full of unusual characters, and I'm not too sure h...

xslt - infer result from children

Given the following xml input: <Sections> <Section number="1"> <Step number="1"> <SubStep number="1" Pass="True"> <SubSubStep number="1" Pass="True"/> <SubSubStep number="2" Pass="True"/> </SubStep> </Step> <Step number="2"> <SubStep number="1" Pass="False"> <SubSubStep number="...

Passing parameters to XSLT Stylesheet via .NET

Hello, I'm trying to pass a parameter to an XSLT stylesheet, but all i'm getting is an empty xml document when the document is transformed using XSlCompiledTransform. This is the C# method used to add the parameters(after adding in people's suggestions) private static void CreateHierarchy(string manID) { string man_ID = m...