xsl

xslt: substring-before

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the folowing xml code: 14 3 12 7 3 78 Now i'd like to only grab the first number of each node to set a background image. So for each node i have the folowing xslt: background-image:url('../icon_ .png'); Problem is that substring before doesn't return anything when there's no space. Any easy way around this? 回答1: You can use xsl:when and contains : background-image:url('../icon_ .png'); background-image:url('../icon_ .png'); 回答2: You can make sure that there is always a space, maybe not the prettiest but at least it's compact :) 回答3:

how to use for-each inside another for-each in xsl

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: the xml is <XYZ> <manager> <mId>m1</mId> <mName>mName1</mName> <manager> <manager> <mId>m2</mId> <mName>mName2</mName> <manager> <department> <dName>d1</dName> <dManager>m1</dManager> <department> <department> <dName>d2</dName> <dManager>m1</dManager> <department> <department> <dName>d3</dName> <dManager>m2</dManager> <department> </XYZ> for each manager, output all the department name he manages, my code is like <xsl:for-each select="XYZ/manager"> <xsl:variable name='mId'> <xsl:value-of select="mId"/> </xsl:variable> <p> manager <xsl:value

Regex to replace single quote with single quote twice if it is inside &lt;xsl: or &lt;XSL:

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Regular Expression to replace ' with '' if it is inside <xsl: else ' should remain as it is. Code Snippet: public static void main ( String [] args ) { String replaceSingleQuoteInsideXsltCondition = "(<\\s*?xsl\\s*?:.*?=.*?)(')(.*?)(')(.*?>)" ; String dummyXSLT = "<p>Thank you for sending us <xsl:for-each select=\"catalog/cd[artist='Bob Dylan']\"> " + "paper's to prove your <span class=\"highlight\"><xsl:if test=\"D01 ='Y'\">Income</xsl:if></span> <span class=\"highlight\"><xsl:if test=\"D02 ='Y'\"> and " + "</xsl:if></span><span

Writing JSON with XSLT

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to write XSLT to transform a specific web page to JSON. The following code demonstrates how Ruby would do this conversion, but the XSLT doesn't generate valid JSON (there's one too many commas inside the array) - anyone know how to write XSLT to generate valid JSON? require 'rubygems' require 'nokogiri' require 'open-uri' doc = Nokogiri::HTML(open('http://bbc.co.uk/radio1/playlist')) xslt = Nokogiri::XSLT(DATA.read) puts out = xslt.transform(doc) # Now follows the XSLT __END__ [ {'artist':' ','track':' '}, ] 回答1: Omit the comma

XSL: Include some ASCII control chars when method=“text”

匿名 (未验证) 提交于 2019-12-03 01:13:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've got an XSL template that outputs text as opposed to XML. In this text, I need to include ASCII character 0x10 in certain position. I understand this character is not allowed in an XML document, but I'm going to output text, so why am I not allowed to use it anyway? I also understand it will not be possible to put this character literally into the template, neither within a CDATA section nor as . But why does on-the-fly generation not work either? I tried, for instance, to define a function that returns this char and used it as but that

Chrome says: Resource interpreted as Stylesheet but transferred with MIME type application/xml

匿名 (未验证) 提交于 2019-12-03 01:12:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an XML file which is styled using an XSL file. When opening the XML file in Firefox, I get no problems, (although strangely, sometimes it will only display after I hit "reload"), but in Chrome/Chromium I get the error message: Resource interpreted as Stylesheet but transferred with MIME type application/xml The files are up here: http://jonreeve.com/test/mike/biblexml.xml I don't think there's anything irregular about the XML/XSL syntax, and the links all seem to be worded correctly, too. Furthermore, this doesn't seem to be similar

How to convert XML to HTML using XSLT in Java

匿名 (未验证) 提交于 2019-12-03 01:12:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to convert XML file into HTML file with help of XSLT. But I am getting an error i.e. javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Invalid byte 1 of 1-byte UTF-8 sequence. XML file 1 John 25 20000 2 Tony 27 23000 3 Eithen 29 25000 XSL file Company Details EmpId EmpName Age Salary Java Code public class TransInfoHtml { public static void main ( String args []) { try { TransformerFactory tFactory = TransformerFactory . newInstance ();

Insert XPath during copy using apply-templates

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've created an XSLT using an identity template and several templates that match to a potential XPath in the source. However, the matching paths do not always exist. Is there a way to "insert" the path before the matching template applies? Since I know XSLT does not execute procedurally, I wasn't sure how to do this. Examples below. Let's say this is the XSLT: <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:if> </xsl:template> <xsl:template match='pathA'> do stuff </xsl:template>

Why does Saxon evaluate the result-document URI to be the same?

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My XSL source document looks like this <Topology> <Environment> <Id>test</Id> <Machines> <Machine> <Id>machine1</Id> <modules> <module>m1</module> <module>m2</module> </modules> </Machine> </Machines> </Environment> <Environment> <Id>production</Id> <Machines> <Machine> <Id>machine1</Id> <modules> <module>m1</module> <module>m2</module> </modules> </Machine> <Machine> <Id>machine2</Id> <modules> <module>m3</module> <module>m4</module> </modules> </Machine> </Machines> </Environment> </Topology> I want to create one result-document per

Getting compile error while using format-date() method in XSLT

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to convert a XML to CSV using XSLT with version 2.0. But I get a compile error while using format-date method in XSLT. Following is the error: Error checking type of the expression 'funcall(format-date, [variable-ref(dt/string), literal-expr([D01]/[M01]/[Y0001])])'. FATAL ERROR: 'Could not compile stylesheet'. XSLT code: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:func="http://exslt.org/functions" xmlns:date