xslt

XSLT: Consolidating Stylesheets

I currently am using two stylesheets to get my intended output. The first stylesheet (pass1.xsl) does the real work, and the second stylesheet (pass2.xsl) removes duplicates while providing minor formatting updates. My question is whether I can perform both actions within a single stylesheet. When I'm looking at the content, I don't ge...

Read xml inside xml with xslt

I got this XML document with an XML-string defined inside an element: <HIT> <FIELD NAME="xmlstring"> &lt;?xml version="1.0"?&gt; &lt;kontaktpersoner&gt;&lt;person&gt;&lt;funksjon&gt;&lt;![CDATA[Økonomi]]&gt;&lt;/funksjon&gt;&lt;tittel&gt; &lt;![CDATA[regnskapsansv.]]&gt;&lt;/tittel&gt;&lt;email&gt;&lt;![CDATA[[email protected]]]&gt;&lt;...

Calling Named Template

I would like to process a frame element in my source xml file using XSLT 2.0 (Saxon 9.1.0.7). If the frame element contains a renderer attribute I need to send this from the frame template to another named template, otherwise I would like to send a default renderer value to the named template. So in the source xml file I could have the...

What XSLT do you use to format MsBuild XML output in CruiseControl.Net?

Hi We currently don't format our msbuild output in CC.NET (CruiseControl.Net) and as a result, finding the cause of a broken build involves reading the XML to find the last 'success="false"' instance in the output. What XSLT do you use to format your msbuild output, and are you happy with the resulting HTML? I.e. do you find it easy to...

XSLT: Loop selecting two elements at a time

I have a bunch of xml documents where the author chose to represent a set of cartesian points like this: <row index="0"> <col index="0">0</col> <col index="1">0</col> <col index="2">1</col> <col index="3">1</col> </row> This would be equal to the points (0,0) and (1,1). I want to rewrite this as <set> <point x="0" y="0"/...

XSL(T) current/previous/next

Hey, I know there is the current() function to retrieve the current node in XSL, but is there a way to be able to reference the "previous" and "next" nodes in reference to the current position? ...

Compare Author to UserID in SharePoint XSLT

Hey Gang, I've got a simple DataFormWebPart where I'm using XSLT to render out the contents of list. I want to compare the @Author field each list item to the current user, however the following won't evaluate to true: in the header of the XSL: <xsl:param name="UserID" /> and within the template that evaluates the rows: <xsl:value...

XSLT: <xsl:strip-space> does not work ...

Hi there, I have a servlet filter in my application that intercepts all the incoming requests and tries to strip the whitespaces from the incoming XML and write the resulting 'clean' XML to the response. I am using XSLT to achieve this. Please see the XSLT below: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version=...

How to assert that all child nodes have a certain attribute value in XPath?

Given the following partial XML document: <section> <entry typeCode="DRIV"> <act classCode="AT" moodCode="DEF"> <statusCode code="completed"/> </act> </entry> <entry typeCode="DRIV"> <act classCode="ACT" moodCode="DEF"> <statusCode code="completed"/> </act> </entry> <entry typeCode="DR...

XSLT do not match certain attributes

Is it possible to match attributes that do not belong to a subset of attributes? For example, I would like to match everything but @attr1 and @attr2. Is there a way to write a template match statement similar to the following, or am I going about this the wrong way? <xsl:template match="NOT(@attr1) and NOT(@attr2)"> Thanks ...

Why is the XSLT disable-output-escaping not implemented in Firefox?

This is an issue that recently came up for me while writing a new XSLT for some XML generated by an application with XTHML embedded using CDATA. Normally I've been able to use disable-escape-output to render the results correctly. However, in Firefox, everything was being displayed as escaped (i.e. &amp;) as opposed to rendering as expe...

can xsltproc be used to parse non UTF 8 xml files

I have written a bash shell script that reads a directory and parses all the XML files in it in a for loop. I am taking each XML file and feeding it to xsltproc along with a xsl style sheet. The problem is some xml files are having non UTF 8 characters and the parser is unable to open those files. Parser error is thrown saying that UTF 8...

XSLT - Use Variable to Store Attributes to Match on in Templates

I have two templates matching the same attributes, both with different modes (shown below). Is there a way that I can avoid writing the attributes twice, one for each template, and instead store those attributes in say a variable? So instead of the match statements below I would have a match like match=$styleAttributes, and styleAttrib...

XSL: how to copy a tree, but removing some nodes ?

I want to use XSL to remove some elements from a tree. Suppose I have the following XML tree: <?xml version="1.0" ?> <mydoc> <file> <colors> <blue /> <red /> <green /> </colors> <secret> <username /> <password /> </secret> </file> </mydo...

Access attributes from XML in shell

I'm trying to parse out values from a Widget config.xml using shell. I do want to use sed for this task. If there is something that sucks less than xsltproc, I'd love to know. In this example I am after the id attribute value from the config.xml below: <?xml version="1.0" encoding="UTF-8"?> <widget xmlns="http://www.w3.org/ns/widgets"...

XSLT 1.0: for each terminal node dump its ancestor chain in csv form

Hi all, I am trying to get the best from the excellent open source Mind Map software FreeMind. As the result of designing a map I get a file which is in fact an XML file that has a simple structure: <node TEXT="0th text i am interested in"> <node TEXT="1st text i am interested in"> <node TEXT="2nd text i am interested in"> <...

Reading a file from Java Servlet

I wrote some code to read a file in my Java Servlet class. (I'm using Netbeans on Windows along with Tomcat server). However, my servlet cannot find the file! After much digging, I found that I had to place the file I wanted to read in Tomcat/bin folder. That's very surprising. How can I get the path to my Webapps/ folder? Let's assume ...

xsl: Copy the entire xml except a parent node but keep its child node

HI, I'm new with stylesheets and looking for a solution to copy the entire XML document but remove a parent node from an xml document. However this parent node also has a child that i'd like to keep. The node to remove is <LoginID> and the child node to keep is <PAN> <InqRs> <LoginID> <PAN>4506445</PAN> </LoginID> <RqUI...

Is there a way to call externals from an xsl stylesheet ?

I very often use the document() xslt function to access an external XML file and use that in the transformation. If I provide a URL within the function I can also access RESTfull web service from the xslt and use the XML this service returns in my xslt. But now i have a local program that returns XML and I would like to address it the sa...

Drag-and-drop generation of XSLT for displaying XML as HTML?

(I've searched and browsed XSLT questions, as well as looked at Altova's product, though not yet Stylus's product.) I do not want to hear again that XSLT is complicated and difficult to hand-code. That's how HTML was when it was first popularized. (I know, apples and oranges comparison because XSLT is a processing language and HTML is j...