xslt

Passing variables to XSLT

I am new to XML/XSL. I want to be able to pass a var in a rule string and have that return the correct data. Right now I have have this PHP: <?php $params = array('id' => $_GET['id']); $xslDoc = new DOMDocument(); $xslDoc->load("test.xsl"); $xmlDoc = new DOMDocument(); $xmlDoc->load("test.xml"); $xsltProcessor = new XSLTProcessor...

Use XslCompiledTransform with cdata-section-elements

I want there to be CDATA sections in my output XML. I have tried to use the "cdata-sections-element" attribute of xsl:output. However, I don't get CDATA in my output. using System; using System.Xml; using System.Xml.Xsl; using System.IO; using System.Text; namespace ConsoleApplication1 { class Program { static void Mai...

Creating a nested tree structure from a path in XSLT

I have a dynamic XML document which represents a tree structure of categories, but does so using path separated attributes in arbitrary order - like this: <data> <record ID="24" Name="category 1\sub category 1"/> <record ID="26" Name="category 1"/> <record ID="25" Name="category 1\sub category 1\sub cate...

xslt and xpath: match two node attributes

given the following xml: <student studentID="001"> <dateOfBirth> 1-1-1990 </dateOfBirth> <name> Ayse Ozer </name> <sex> F </sex> <takes> CMPE351 </takes> <takes> CMPE111 </takes> <takes> CMPE418 </takes> </student> <student studentID="002"> <dateOfBirth> 2-2-1992 </dateOfBirth> <name> Bircan Korkmaz </...

xsl filter on select

I would like to select all descendant but "blog" nodes. For the example, only subtree should appear on output. I'm trying this xsl code: <xsl:template match="rdf:RDF"> <xsl:copy> <xsl:copy-of select="descendant::*[not(descendant::blog)]"/> </xsl:copy> </xsl:template> for this xml: <rdf:RDF> <profesor rdf:ID="...

Move sub nodes into parent attributes with XSLT

I have some XML which contains records and sub records, like this: <data> <record jsxid="id0x0b60fec0" ID="12429070" Created="2008-10-21T03:00:00.0000000-07:00"> <record jsxid="id0x0b60ff10" string="101"/> <record jsxid="id0x0e64d8e8" string="63"/> <record jsxid="id0x2fd83f08" string="Y"/> </record> <record jsxid="id0x0b60fec0"...

XSLT template overriding

Hi Everyone, I have a small question regarding XSLT template overriding. For this segment of my XML: <record> <medication> <medicine> <name>penicillin G</name> <strength>500 mg</strength> </medicine> </medication> </record> In my XSLT sheet, I have two templates in the following order: <xsl:template match=...

Calling ColdFusion function inside XML Transform with value of attribute

How can one call a ColdFusion function, passing in attribute values as arguments, inside an XML transform template statement. For example, something like: <xsl:template match="date"> <cfoutput>#DateFormat(now(), <xsl:value-of select="@format"/>)#</cfoutput> </xsl:template> Such that the following XML: <date format="mm/dd/yy" /> ...

XSLT and XQuery on invalid html input, pieces of URI look like entities

I'm using Saxon 9 to analyze invalid html sources. Specifically the html has href values like the following: <a href="blah.asp?fn=view&g_varID=1234">some text</a> I'm getting errors: "Error reported by XML parser: The reference to entity "g_varID" must end with the ';' delimiter." The xml parser is reading the "&g_varID" string and...

xsl strange behaviour using variables

I've stored a file's tree into $onto <xsl:variable name="onto" select="document('file.xml')"/> In some places I can use this variable as espected: <xsl:copy-of select="$onto/rdf:RDF"/> But I'm having trouble in other places, strange chars are written on output: <xsl:element name="autor"> <xsl:attribute name="rdf:resource"> ...

How to make external XML file display nicely in a browser?

I have this PHP web application. It has a link to an XML file to which I have no control. How can I make the XML display nicely? I just want it to line up in a table or it can even look like a data file. Can I attach an XSLT file or style sheet to the XML file from the outside i.e. I wish I could, but I can't put this in the XML: <...

Selecting a specific table with XPath

I've got an XHTML document, and I want to select the only table in it with class="index". If I understand correctly, the descendant axis will select all nodes directly and indirectly descending from the current node, so here's what I've got. //descendant::table[@class="index"] It doesn't appear to be working when tested with xmlstar...

Prevent whitespaces between two XSLT-elements from being removed by the xslt-processor

Hi, my question is a bit different from the other ones.. i got an xsl-code like this: <xsl:value-of select="..."/> <xsl:value-of select="..."> what i want in my result is: result_of_select_1 result_of_select_2 what i get is: result_of_select_1result_of_select_2 how can i prevent this? ( any xsl:output option for example?...

XSLT root tag namespace instead of element attribute namespace

I have a XSL file to transfer another XSL file. I want the namespace declaration to be on the root tag, instead of it being repeated on every single element!! Here is my stylesheet: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mynamespace="somenamespace" version="2.0"> <xsl:output method="xml...

Transforming XML to XML with XSLT - ugly ColdFusion export.

I have a following XML structure that I need to transform: <recordset rowCount="68" fieldNames="ITEM,ECL,LEAD_TIME" type="**coldfusion.sql.QueryTable**"> <field name="ITEM"> <string>ITEM_A</string> <string>ITEM_B</string> <string>ITEM_C</string> </field> <field name="REV"> <string>A</string> <string>B</string> <string>C</string> <...

XSLT: Breaking CSV from one source XML node into multiple target XML nodes.

Hi, Thanks to help of fellow SO users that helped me out in this question I am half way through my XML transformation. The problem that I hit a wall with transforming comma seperated values (DATE and QTY): <?xml version="1.0" encoding="utf-8"?> <results> <recordset rowCount="68" fieldNames="ITEM,ECL,LEAD_TIME,QTY,DATE" type="**coldfus...

XSLT self-closing tags issue

Hi, I am using xslt to transform an xml file to html. The .net xslt engine keeps serving me self-closing tags for empty tags. Example: <div class="test"></div> becomes <div class="test" /> The former is valid html, while the latter is illegal html and renders badly. My question is : How do I tell the xslt engine (XslCompiledTrans...

How to display xml response already formatted in html (IE won't show anything after the xml table)

How to display xml response already formatted in html (IE won't show anything after the xml table) If you visit this page in IE you'll see that nothing displays after the chart: http://www.ratecatcher.com/prototype.htm Here is the main php code: $xml = file_get_contents($request); echo html_entity_decode($xml); Then the html that is...

FOP: fo:block width attribute ignored?

Hi all, I'm managing to generate a PDF with one line-chart from google-chart, but the quality of the generated columns titles doesn't fit our needs, so I want to generate by myself. This task should be done using [fo:table] but I'm not able to positionate succesfully the titles (widths and margins/paddings). In sum up, I want to put t...

Can XSLT render MVC ASP.NET Controls/Code?

Is there any way to render ASP.net MVC controls or code directly within a XSLT/XSL transform file under the .NET Framework? If so can you provide me with a sample or link? ...