xslt

XSL - why does this recurse forever?

I'm trying to create something similar to a for-loop with the recursive idiom I've seen across the web. My implementation is with a parameter that tells what to print. I use the Eclipse built-in XSL transformator and I can't for the life of me see why it gives a StackOverflowException: <!-- Loops recursively to print something the ...

XST - using output from call-template as return value

Suppose i have a template foo which can output something given a parameter. Now I want to use that output as a parameter to my other template, loop so I can loop the output a certain number of times. I have tried something along the way of <xsl:call-template name="loop"> <xsl:with-param name="times" select="someParam"/> ...

xslt - adding </tr><tr> every n node?

I found an elegant solution for that problem here: http://stackoverflow.com/questions/3806578 I'd like to understand the xslt code and I was wondering if you could help me to understand it by taking a look at the link provided above. Basically there are 3 <xsl:template>. To me the first 2 ones are enough to achieve the purpose. Howeve...

Order of XML Elements Using XSLT

Suppose i have an xml document like this XML File: <document> <educationalsection> educational details </educationalsection> <professionalsection> professional section details </professionalsection> </document> I have created XSL to converge it into my required format but the problem is if i want to change the order of t...

XSL checking integer

How to check the integer value in XSL ??? I'm used the version 1.0 My Code: <xsl:variable name="ShowEmailEventId" select="com.zoniac.emailevent.NewEmailEventBean/emailEventIdString"/> <xsl:if test="$ShowEmailEventId !=48"> <table align="center" width="96%" border="1" style="border-color:#2E73AD...

XSLT help running in java.

Im new to the XSLT world, I am basically trying to run the JSON convertion from HERE However if I use this method: TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(new StreamSource("src\\json\\xml-to-json.xsl")); transformer.transform(new StreamSource("src...

Only emit some HTML when a variable is different from the last iteration in XSLT

Using XSLT I'm trying to work out a way to only emit a HTML table row when a value is different from the last iteration of the for-each loop. Essentially I want to make the table appear to have grouped headers, by only writing out the header once it changes. I'm having a bit of trouble conceptually working out how I could do that consid...

XSL Transform cannot invoke user defined Java Method

Hi, I have the following XSL which defines a namespace for my Java Class. In a nutshell I'm trying to point to a different resource bundle depending upon a value in my XML file (I know Resource Bundles are really for internationalization but why re-create the wheel?): <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/...

How can I store UTF8 in MySQL with PHP, sanitize it, echo it with XML and transform it with XSLT?

I am developing a MVC application with PHP that uses XML and XSLT to print the views. It need to be fully UTF-8 supported. I also use MySQL right configured with UTF8. My problem is the next. I have a <input type="text"/> with a value like àáèéìíòóùú"><'@#~!¡¿?. This is processed to add it to the database. I use mysql_real_escape_string...

How to create PHP/JSP/ERB tags using XSLT?

I have a bunch of XML files which I use to generate HTML pages. Those pages ultimately get marked up (by hand) with some <%= %> tags and made into Ruby .erb templates. Is there a way to generate the special tags <?php ?> or <%= %> directly during the XSL transform? I've tried using a <![CDATA[ ... ]]> block, but then the output generat...

XSLT: for each problem

It supposed to be very simple, I want to limit my results in this for-each but also want to check a node. For some reason it doesn't work combining them both in one statement? I have a checkbox (recommended) which can be ticked to 'Yes'. When I remove the limit 5 in the for-each, it shows all the items that have recommended on 'Yes'. ...

How to use xsl variable in xsl if

I am trying to assign a value from an xsl variable to a new node in my xml file. This code works, but adds an empty PROP/PVAL node when the value of "lbi:GetCoordinates(PVAL)" is empty: <xsl:template match="PROP" mode="Geocode"> <PROP NAME="Geocode"> <PVAL> <xsl:value-of select="lbi:GetCoordinates(PVAL)"/> </PVAL> </PROP>...

XSLT to copy XML doc and add attribute plus generated value under certain conditions

Hi, I'm pretty new to XSLT and have an urgent work requirement that I'm finding quite complex to sort out. I have an XML doc which needs an attribute adding under certain conditions. The XML doc is pretty straightforward: <A x="foo" y="bar" z=""> <B/> <C/></A> Basically if attribute "z" is present. Then a new attribute needs to be...

XML with inline XSLT

I need an XML file to change after installation, based on some parameters. For example: <?xml ...?> <root xmlns="..."> <!-- remove this element when PARAM_MODE=1 --> <sometag /> <!-- remove this element when PARAM_MODE=2 --> <sometag2 /> <someothertag /> </root> The easiest way it to use XSLT to remove the element, but ...

Get element position() regardless of parent

Lets say you have an xml document like <parents> <parent> <element /> <element /> </parent> <parent> <element /> <element /> </parent> </parents> While processing I need to know that the elements are 1, 2, 3, 4 in the document, not that but calling position() will return 1, 2, 1, 2. Nor...

XSL to find all nodes between nodes

I have a large poorly formed XML file where information related to a single line item is broken into multiple lines of information that I'm trying to group with the parent line item (ITEM_ID). The information is sequential so the key is the ITEM_ID node, but I can't seem to create the proper XSL needed to group the information related to...

xsl to group nodes between other nodes?

I can't figure out how create xsl to group some nodes between other nodes. Basically, everytime I see a 'SPLIT' I have to end the div and create a new one. The xml looks like this: <data name="a" /> <data name="b" /> <data name="c" /> <data name="SPLIT" /> <data name="d" /> <data name="e" /> <data name="SPLIT" /> <data name="f" /> <da...

Splitting XML into multiple files with XSLT

I'm having a hard time wrapping my head around XSLT but I heard it's possible to split an XML file into multiple files. Basically I'd like to copy all the elements up to the first file and after the last file and then add the individual file content for each output file. Could someone give me some pointers on this if it's even possible...

How to remove an element from InfoPath XML using XSL

I have the standard XML form and am having problems removing an element. XML <my:myFields> <my:Attachment>some values</my:Attachment> </my:myFields> I have tried using this: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="@*|node()"> <xsl:copy> <xsl:app...

Alphanumeric sort on mixed string values: alpha numeric alpha

Given XML where FORMNUMBER can be numeric only; begin with numeric and then include alpha; or follow a numeric alpha numeric pattern: <FORMSLIST> <FORMS> <FORMNUMBER>3 ABC</FORMNUMBER> <FORMSEQ>99900</FORMSEQ> </FORMS> <FORMS> <FORMNUMBER>12 ABC 45</FORMNUMBER> <FORMSEQ>99900</FORMSEQ> </F...