xslt

preserve whitespace between xsl:sort'd nodes

I'm trying to figure out how to preserve the whitespace nodes between the nodes I'm sorting. Here is an example. Input: <a> <b> <c> <d>world</d> </c> <c> <d>hello</d> </c> </b> <e>some other stuff</e> </a> Desired output: <a> <b> <c> <d>hell...

find common parent using Xpath

Hi, I was wondering if there was any way to access common parent node using Xpath. <outer> <main> <a><b> sometext </b></a> <c><d> sometext2 </d></c> </main> </outer> I have the text nodes sometext and sometext2. is there a way i can access main (common parent) of these two nodes? I do not know the layout of the...

XPath search based on dynamic regular expressions

Hi I have an XML like the one below: <?xml version="1.0" encoding="UTF-8"?> <Configuration> <Destinations> <Destination name="DEST1" > <From>AMA*</From> </Destination> <Destination name="DEST2" > <From>AMAZON</From> </Destination> ...

XSLT - How to select XML Attribute by Attribute?

Hello, this is the structure of my source xml: <root> <DataSet Value="A"> <Data Value1="1" Value2="anythingA1" /> <Data Value1="2" Value2="anythingA2" /> <Data Value1="3" Value2="anythingA3" /> <Data Value1="4" Value2="anythingA4" /> <Data Value1="5" Value2="anythingA5" /> </DataSet> </root> from which I like to create some variables ...

XML XSL Transform From Stream

Hi I have a memory stream in which I use XMLTextWriter to write out some XML. What I want to do is transform this XML using the XSL.transform feature. The thing is I don't want to create a temp. XML file, I want to somehow use the stream to Transform it into the XSL. Thank you for any suggestions. ...

How to find out an element node with a empty string value in xsl

Hi, everyone: I am working on transforming a xml file from old version to new version. Here is the basic template which i am using: <xsl:template match="*"> <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}"> <xsl:copy-of select="@*"></xsl:copy-of> <xsl:apply-templates></xsl:apply-templates> </xsl:element>...

How do I explode an attribute with values separated by a , into seperate elements

I have a an attribute who's value may be one or more text strings all delimited by a comma. I wish to transform using XSL the attribute value(s) into their own element; e.g <post title='Hello World" tags="Test,Hello,World /> In which I would like it transformed to; <post> <title>Hello World</title> <tag>Test</tag> <tag>Hello</tag> ...

Converting XML between schemas - XSLT or Objects?

Given: Two similar and complex Schemas, lets call them XmlA and XmlB. We want to convert from XmlA to XmlB Not all the information required to produce XmlB is contained withing XmlA (A database lookup will be required) Can I use XSLT for this given that I'll need to reference additional data in the database? If so what are the argum...

xslt get the file current folder path

Is there a way to get the current folder path from within a xslt file? Need it to locate other xml and xslt files. We have different customer folders and will need to successfully find the correct files. Cheers ...

Java's default JAXB implementation is chosen over my classpath.

I've written a java application that utilizes JAXB for XSL transforms. I've included the saxon9.jar in my classpath so that I can use XSLT 2.0 rather than XSLT 1.0 on the command line. java -classpath ./lib/saxon9.jar:./ -jar myApp.jar I've included code in my XSL to report the XSLT used. <xsl:comment><xsl:text > </xsl:text>XSLT Ver...

Can i make an XSLT transformation directly in html page ?

I know namespace are used to describe, like doctype, but is there a way or a trick to transform inner namespace html with an xsl using xsd ? <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml" x...

Using XSLT to output an empty HTML textarea element

When attempting to output an empty textarea element, the .NET XSLT processor collapses the element to its short form. Instead of this: <textarea id="blah" name="blah"></textarea> I get this: <textarea id="blah" name="blah"/> Which causes many web browsers (including IE and Firefox) to render the rest of the page as if it were the c...

Removing all \n\r characters from a node XSLT?

Hi wondered if you could help me please? I have node in xml that is as followed $LOG: 08880xbpnd $ fhdsafidsfsd df sd fsd f sd fsd I was wondering is there anyway to make all the text go on to one line so that it then can be passsed through to a javascript function? so it would turn out like this $LOG: 08880xbpnd $fhdsafidsfsddfsdf...

Namespaces in XSLT

I'm using XSLT to restructure an XML file. The following code copies all child nodes to a new XML file: <!--Add all child elements of the zzz node--> <xsl:template match="zzz"> <Trade> <xsl:attribute name="ID"> <xsl:value-of select="TradeId" /> </xsl:attribute> <xsl:copy-of select="*"></xsl:copy-of> </Trade>...

Problem sorting RSS feed by date using XSL

I'm creating a website where I need to show the top 5 records from an RSS feed, and these need to be sorted by date and time. The date fields in the RSS feed are in the following format: "Mon, 16 Feb 2009 16:02:44 GMT" I'm having big problems getting the records to sort correctly - I've tried lots of different code examples I've seen, ...

XSLT: sum of tree fragment will always return 0 !

Hello everyone, I am stuck with a problem which seems stupid but I cannot find out the solution... With XLST, I need to sum a list of values calculated by a template. So I stored these values in a tree structure (a list of "Number" elements contained in a root element "Numbers"). But whatever I try to do with this self-made list, it wil...

Is there a point creating a site using XSLT

Is this technology still popular? I want to make a website which automatically transforms XSLT files. It should work like this: When a user accesses the site, a single handler would accept his request and then find a suitable XML for it (according to the URL requested) and transform it using its attached XSL file. I want to do this in ...

Including an attribute of an unrelated element in an XPath

Hi, I have the following XML file: <phonebook> <departments> <department id="1" parent="" title="Rabit Hole" address="" email="" index=""/> <department id="2" parent="" title="Big Pond" address="" email="" index=""/> </departments> <employees> <employee id="1" fname="Daffy" lname="Duck" title="Admin" email="da...

xslt replace \n with <br/> only in one node?

Hey I have a node <msg> which contains a message such as string1 string 2 sting3 but however when it renders, it renders all one line how can i replace all \n with <br />'s. i've tried <xsl:value-of select='replace(msg, "&#xA;", "<br/>")' /> but i get this error Error loading stylesheet: Invalid XSLT/XPath function...

How do I pass an error message generated by xslt to java application caller

I use a java application to call a xslt to do a xml transformation. The xslt file will generate a message and terminate the process if some condition happens. However, my java application couldn't catch the error message generated by xslt, it only catch an exception with general information - "Stylesheet directed termination". Here is m...