xslt

XML to CSV using XSLT help.

I'd like to convert XML into CSV using an XSLT, but when applying the XSL from the SO thread titled XML To CSV XSLT against my input: <WhoisRecord> <DomainName>127.0.0.1</DomainName> <RegistryData> <AbuseContact> <Email>[email protected]</Email> <Name>Internet Corporation for Assigned Names and Number</Name> <Ph...

How to improve variable overriding/overwriting in XSL?

I want to do the following: Declare a variable Go into a if-statement Overwrite the variable XSL says I can't declare a variable twice, so what can I do to improve this step? Another approach was to check if a variable is set at all. I did this, because i skipped the first step and declared the variable in the if-statement. In anot...

XSLT string with HTML entities - How can I get it to render as HTML?

I'm completely new to using XSL, so if there's any information that I'm neglecting to include, just let me know. I have a string in my XSLT file that I can display like this: <xsl:value-of select="@Description/> and it shows up, rendered in a browser like: <div>I can't do anything about the html entities existing in the text.</div> ...

XSLT good choice for web framework?

I've always thought of XML (and SGML before that) data as the devil's format. I'm of the old database and flat files school. Nonetheless, we are developing a commercially-available web product who's framework is based off of translating/transforming XML data in chains. As we're interviewing for positions as well talking to potential c...

Apply XSLT on in-memory XML and returning in-memory XML

I am looking for a static function in the .NET framework which takes an XML snippet and an XSLT file, applies the transformation in memory, and returns the transformed XML. I would like to do this: string rawXml = invoiceTemplateDoc.MainDocumentPart.Document.InnerXml; rawXml = DoXsltTransformation(rawXml, @"c:\prepare-invoice.xslt"))...

Wrapping element in choose construction. How to improve?

Is there any way to optimize this code. <xsl:choose> <xsl:when test="val1 = val2"> <xsl:apply-templates select="node"/> </xsl:when> <xsl:otherwise> <div> <xsl:apply-templates select="node"/> </div> </xsl:otherwise> </xsl:choose> I do not like having to write twice the same <xsl:appl...

Looping and recursion based on parameter passed

I have an XML organized like below- <section name="Parent 1 Text here" ID="1" > <section name="Child 1 Text here" ID="11"> </section> <section name="Child 2 Text here" ID="12"> <section name="GrandChild Text here" ID="121" > </section> </section> </section> <section name="Parent 2 Text here" ID="2" > <section n...

How to write <a href="mailto: tag in xslt ?

I am creating HTML o/p using xsl. one of the requirement is to display user's mail id and when clicked... it will open a new page of Outlook. I know tag but How to write HTML tag in xslt ? <a href="mailto:<xsl:value-of select="//Email/>"> <xsl:value-of select ="//Email"/> </a> where Email is retrived from an XML. I need to provide x...

Flatten and convert a large amount of XML files to a Table

Hi, I have a huge number (2k+) of xml files that I need to extract data from and dump that data into a table of some sort (Excel or simply one or multiple XML files would be fine). The fun part is that the xml files have wildly differing amount of nodes (with occasionally the same names in the subnodes) and also the depth of the hierarc...

Messing with Encoding and XslCompiledTransform

Hello, im messing with the encodings. For one hand i have a url that is responding me in UTF-8 (im pretty sure thanks to firebug plugin). Im opening the url reading the content in UTF-8 using the following code: StreamReader reader = new StreamReader(response.GetResponseStream(),System.Text.Encoding.UTF8); For other hand i have a ...

Xslt external parameter

In my server side TransformerFactory tfactory = TransformerFactory.newInstance(); Transformer transformer = tfactory.newTransformer( new StreamSource("mytext.xsl")); transformer.setParameter("parametro","hope"); transformer.transform( new DOMSource(document), outputStream ); --mytext.xslt-- . . . ...

How to detect the error raised on a particular codeline?

[Please edit the title if you find its not good enough] I have code which triggers XSL-transformation: objMemoryStream = new MemoryStream(); xslTransform = new XslCompiledTransform(); xpathXmlOrig = new XPathDocument("E:\\xslt error\\Simulation_of_error\\input.xml"); xslSettings = new XsltSettings(); xslSettings.EnableScript = true; ...

Generate dynamic xmlns

Hello, I would like to dynamically generate xmlns attributes. I want to generate this in XSL : <Common:MainPageBase xmlns:Common="clr-namespace:ThisPartIsDynamic;assembly=ThisPartIsDynamic"> </Common:MainPageBase> How can I do that in XSL? Thanks, Alex Update: To be more precise, here is what I need to generate. The parts th...

Forward slash problem in xsl and xsql

Hi I have simple xsql <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="zad1.xsl" ?> <page xmlns:xsql="urn:oracle-xsql" connection="java:comp/env/jdbc/mondialDS"> <xsql:query max-rows="-1" null-indicator="no" tag-case="lower" rowset-element="continents"> select name as continent from ...

WPF Resource Dictionary XSLT

To use images in wpf you can define: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <BitmapImage x:Key="ImageFunTime" UriSource="../Resources/Images/ImageFunTime.png" /> ... Then in app somewhere you can: var img = (Im...

XSLT 1.0 grouping to reformat element defined by date into element defined by task

Hi folks, I have a tricky XSLT transformation and I'd like your advise My xml is formatted as below: <Person> <name>John</name> <date>June12</date> <workTime taskID=1>34</workTime> <workTime taskID=2>12</workTime> </Person> <Person> <name>John</name> <date>June12</date> <workTime taskID=1>21</workTime> <workTime taskID=2>11</workTime> ...

How to format the date in xslt ?

Hello All, How can we format the date in xslt ? Example: <xsl:value-of select ="name of function(I/P, 'MMM dd, yyyy')"/> Thanks in advance... ...

Specific template for the first element.

I have a template: <xsl:template match="paragraph"> ... </xsl:template> I call it: <xsl:apply-templates select="paragraph"/> For the first element I need to do: <xsl:template match="paragraph[1]"> ... <xsl:apply-templates select="."/><!-- I understand that this does not work --> ... </xsl:template> How to call <x...

Filter a CSV list in XSLT

Hello SO; I'm trying to convert xml elements whose content is a csv list of identifiers, the exact form doesn't matter. I want to exclude every item that contains the character "/". The best I've come up with is translate(./someElement, ",*/*", "") but this has at least two problems; I'm pretty sure that xsl doesn't accept wildcards,...

How to write a XSLT for this XML?

<?xml version="1.0" encoding="utf-8"?> <!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) --> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"&gt; <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x=...