xslt

Can XPath do a foreign key lookup across two subtrees of an XML?

Say I have the following XML... <root> <base> <tent key="1" color="red"/> <tent key="2" color="yellow"/> <tent key="3" color="blue"/> </base> <bucket> <tent key="1"/> <tent key="3"/> </bucket> </root> ...what would the XPath be that returns that the "bucket" contains "red" and "blue"? ...

Xsl relative path for xsl:import or xsl:include

I am trying to use VBSctipt to do an xslt transform on an xml object. The xsl file I'm translating includes the <xsl:import href="script.xsl"/> directive. If I use the absolute href (http://localhost/mysite/script.xsl) it imports the style sheet fine; however, if I use the relative path (script.xsl) it reports "resource not found". I ne...

What's the best way to format 24 hour time in XSLT 1.0?

I've had a hard time finding good ways of taking a time format and easily determining if it's valid then producing a resulting element that has some formatting using XSLT 1.0. Given the following xml: <root> <srcTime>2300</srcTime> </root> It would be great to produce the resulting xml: <root> <dstTime>23:00</dstTime> </root...

Add a namespace to elements using XSLT

I have an XML document with un-namespaced elements, and I want to use XSLT to add namespaces to them. Most elements will be in namespace A; a few will be in namespace B. How do I do this? ...

I have a 100+MB XML file (sans-DTD/Schema). XSLT won't have it. Strategies for transforming/parsing?

This XML file contained archived news stories for all of last year. I was asked to sort these stories by story categor[y|ies] into new XML files. big_story_export.xml turns into lifestyles.xml food.xml nascar.xml ...and so on. I got the job done using a one-off python script, however, I originally attempted this using XSLT. This r...

How to declare a user-defined function returning node-set?

I want something like this: <msxsl:script language="C#"> ??? getNodes() { ... return ... } </msxsl:script> <xsl:for-each select="user:getNodes()"> ... </xsl:for-each> What return type should i use for getNodes() and what should i put in it's body? ...

XSLT: How to count distinct values in a node?

How to count distinct values in a node in XSLT? Example: I want to count the number of existing countries in Country nodes, in this case, it would be 3. <Artists_by_Countries> <Artist_by_Country> <Location_ID>62</Location_ID> <Artist_ID>212</Artist_ID> <Country>Argentina</Country> </Artist_by_Country> <Artist...

What is the best XSLT engine for Perl?

I would like to know what of the many XSLT engines out there works well with Perl. I will use Apache (2.0) and Perl, and I want to obtain PDFs and XHTMLs. I'm new to this kind of projects so any comment or suggestion will be welcome. Thanks. Doing a simple search on Google I found a lot and I suppose that there are to many more. ...

How do I convert an XmlNodeList into a NodeSet to use within XSLT?

I've got a XmlNodeList which I need to have it in a format that I can then re-use it within a XSLT stylesheet by calling it from a C# extension method, can anyone help? I have read that it might have something to do with using a XPathNavigator but I'm still a bit stuck. Thanks in advanced, Chris ...

Checking for a duplicate element in the OUTPUT using XSLT

I've got some XML, for example purposes it looks like this: <root> <field1>test</field1> <f2>t2</f2> <f2>t3</f2> </root> I want to transform it with XSLT, but I want to suppress the second f2 element in the output - how do I check inside my template to see if the f2 element already exists in the output when the second f2 e...

How do I preserve markup tags when using XSLT?

I've got an XML document containing news stories, and the body element of a news story contains p tags amongst the plain text. When I use XSL to retrieve the body, e.g. <xsl:value-of select="body" /> the p tags seem to get stripped out. I'm using Visual Studio 2005's implementation of XSL. Does anyone have any ideas how to avoid this...

XSLT Abstractions

I'm exploring the XML -> XSLT -> HTML meme for producing web content. I have very little XSLT experience. I'm curious what mechanisms are available in XSLT to handle abstractions or "refactoring". For example, with generic HTML and a service side include, many pages can be templated and decomposed to where there are, say, common header...

Calculate weeknumber from a date value using XSLT

Is there some simple way to calculate a Weeknumber value from a date value stored in XML? It needs to be pure XSLT solution. I cannot use any code :( ...

Render App.config/Web.config files via XSLT

Does anyone have an XSLT that will take the app.config and render it into a non-techie palatable format? The purpose being mainly informational, but with the nice side-effect of validating the XML (if it's been made invalid, it won't render) ...

What is more efficient for parsing Xml, XPath with XmlDocuments, XSLT or Linq?

I have parsed Xml using both of the following two methods... Parsing the XmlDocument using the object model and XPath queries. XSL/T But I have never used... The Linq Xml object model that was new to .Net 3.5 Can anyone tell me the comparative effeciantly between the three alternatives? I realise that the particular usage would ...

Converting XML to plain text using XSLT -- how should I ignore/handle whitespace in the XSLT?

I'm trying to convert an XML file into the markup used by dokuwiki, using XSLT. This actually works to some degree, but the indentation in the XSL file is getting inserted into the results. At the moment, I have two choices: abandon this XSLT thing entirely, and find another way to convert from XML to dokuwiki markup, or delete about 9...

Interpreting newlines with XSLT xsl:text?

I have an XSL stylesheet with content in an xsl:text node like this: <xsl:text> foo bar baz </xsl:text> The stylesheet itself is a text file with "unix-style" newline line terminators. I invoke this stylesheet on Windows as well as unix-like platforms. It would be nice to have the output conform to the conventions of the platform on w...

XSLT: testing whether a certain type of non-null element exists... somewhere

I have XML that looks like <answers> <answer> <question-number>1</question-number> <value>3</value> <mean xsi:nil="1" /> </answer> <answer> <question-number>2</question-number> <value>2</value> <mean>2.3</mean> </answer> <answer> <question-number>3</question-number> <value...

Cocoon 2.2? Is it worthwhile or bad news?

Hi, I am looking to use Cocoon for a couple of sites I am creating. I will make heavy use of xml, xsl and conversion to html, pdf and excel on the sites. I am attracted to coccon as it implements these functions quite well. I guess I am just wondering if anyone has used it and like it, or if they found it was more trouble than it's wo...

Unable to translate Unicode character

I have an ASPX page that creates an XMLDocument object from SQL data and then transforms it into another XML document (RSS feed) using an XSLT file with XPathNavigator and XslCompiledTransform. Occasionally the data will contain smart quotes (\u2019) which results in an error (Unable to translate Unicode character \u2019 at index 947 to...