xslt-1.0

Remove characters using xsl

て烟熏妆下的殇ゞ 提交于 2019-12-05 10:45:10
问题 I need to remove the following characters from a string value using xsl 1.0 *, /, \, #, %, !, @, $, (, ), & I have come up with the following: translate(translate(translate(string(//xpath/@value),'.',''),'/',''),',','') In the above approach, I would have to duplicate the same code many times (one time per character). How can I achieve the same goal without duplicating the code? Thanks :-) 回答1: You simply need translate(//foo/@value, '*\%!@$&', '') in pure XPath respectively inside of an XML

Single quote escaping a dynamic value-of string in XSLT 1.0

北战南征 提交于 2019-12-05 10:03:53
I am defining a JavaScript variable from XSLT and am getting an error due to an unescaped string. I understand that I need to replace this to &apos; , but I'm unsure how to do that in XSLT 1.0. XSLT example: var currentComment = '<xsl:value-of select="root/Reviews/Review/Comment" />'; Rendered javascript with unescaped single quote: var currentComment = 'Let's test a string.', // Causing an error ------^ As Ian Roberts pointed out in his comment, you need to account for backslashes and not just apostrophes. Dimitre's answer can be modified as follows to account for this: <xsl:stylesheet

CSS style for leading dots

六月ゝ 毕业季﹏ 提交于 2019-12-05 08:17:51
I'm working on a CSS style which produces dots for a table of contents page. The code is based on https://code.google.com/p/wkhtmltopdf/issues/detail?id=1073 . The idea is to create a div with lots of dots in it and overlay it with a span-elements (text and page-number), which have a white background. This works quite good, except for following two issues: dots are "cut" (screenshot: http://i.imgur.com/VRJQCP5.png ) if a text-element requires more than one line, it doesn't get displayed Code: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999

How to convert .csv file to xml using XSLT 1.0?

為{幸葍}努か 提交于 2019-12-05 08:06:53
问题 I have a .csv file generated and I want to transform it to xml using xslt. How to do that? I'm not good in xslt. Please, help me. Thank you. Here's my .csv file CONTRACT_NUMBER,CLIENT_NAME_FULL,STREET_ADDRESS,REGISTRY_NO,DATE_RECEIVED,STATUS,REMARKS 3300016335,name,"address",1_A,3/26/2014,Received,with signature Desired xml: <root> <row> <CONTRACT_NUMBER>CONTRACT_NUMBER</CONTRACT_NUMBER> <CLIENT_NAME_FULL>CLIENT_NAME_FULL</CLIENT_NAME_FULL> <STREET_ADDRESS>STREET_ADDRESS</STREET_ADDRESS>

Get first child node in XSLT using local-name()

天涯浪子 提交于 2019-12-05 06:04:02
Assume we have this simple xml ... <books> <book> <author/> <title/> </book> <book> <author/> <title/> </book> </books> I'm using this xpath to get the elements of the first book instance. //books[1]/* Returns <author/> <title/> And that works fine, but I have to get it working using local-name(). I've tried the following but none of these work... //*[local-name()='books']/* this returns repeating author and title elements, not good, I only need them from the first child //*[local-name()='books'][0]/* this does not return anything Basically, I want to create a CSV file, so the first line in

find next-to-last node with xpath

点点圈 提交于 2019-12-05 04:32:21
I have a XML document with chapters and nested sections . I am trying to find, for any section, the first second-level section ancestor. That is the next-to-last section in the ancestor-or-self axis. pseudo-code: <chapter><title>mychapter</title> <section><title>first</title> <section><title>second</title> <more/><stuff/> </section> </section> </chapter> my selector: <xsl:apply-templates select="ancestor-or-self::section[last()-1]" mode="title.markup" /> Of course that works until last()-1 isn't defined (the current node is the first section). If the current node is below the second section, i

Dynamically include other XSL files in XSLT

非 Y 不嫁゛ 提交于 2019-12-05 03:38:06
I have a small problem, is there a way to dynamically include another xsl? For example: <xsl:variable name="PathToWeb" select="'wewe'"/> <xsl:include href="http://{$PathToWeb}/html/xsl/head.xsl" /> <xsl:include href="http://{$PathToWeb}/html/xsl/navigation.xsl" /> <xsl:include href="http://{$PathToWeb}/html/xsl/promo.xsl" /> <xsl:include href="http://{$PathToWeb}/html/xsl/3columns.xsl" /> <xsl:include href="http://{$PathToWeb}/html/xsl/footer.xsl" /> I have a small problem, is there a way to dynamically include another xsl? For example: <xsl:variable name="PathToWeb" select="'wewe'"/> <xsl

“Regular expression”-style replace in XSLT 1.0

浪子不回头ぞ 提交于 2019-12-05 03:14:29
问题 I need to perform a find and replace using XSLT 1.0 which is really suited to regular expressions. Unfortunately these aren't available in 1.0 and I'm also unable to use any extension libraries such as EXSLT due to security settings I can't change. The string I'm working with looks like: 19;#John Smith;#17;#Ben Reynolds;#1;#Terry Jackson I need to replace the numbers and ; # characters with a , . For example the above would change to: John Smith, Ben Reynolds, Terry Jackson I know a recursive

List of XSLT instructions/functions that change the context node?

℡╲_俬逩灬. 提交于 2019-12-04 23:52:12
Does anyone know of a list of XSLT instructions/functions that change the context node? For example, instruction like for-each is one of them. Michael Kay The obvious XSLT 2.0 instructions that change the context are for-each , apply-templates , for-each-group , and analyze-string . But there's also, for example, xsl:sort and xsl:key . In XPath, the operators / and [] change the context. There are no functions that change the context. There are only two things in XSLT 1.0 that change the context and neither of them are functions. These are: <xsl:apply-templates select='some-test'/> (which will

xsl trying to ouput '<' as opposed to '<'

家住魔仙堡 提交于 2019-12-04 23:34:09
问题 Update: The issue still persists although it is not quite the same as before. Below is an example of what is being input, what is being output and what I want to have output An example of the input: &lt;p&gt;&lt;span style=&quot;font-size: medium&quot;&gt;Product description text&lt;/span&gt;&lt;/p&gt; Current output: <p><span style="font-size: medium">Product description text</span></p> Intended output: <p><span style="font-size: medium">Product description text</span></p> . Using CDATA has