xslt

xsl:character-map to replace special characters

大憨熊 提交于 2020-01-23 09:29:06
问题 Given an element with a value of: <xml_element>Distrib = SU & Prem &lt;&gt; 0</xml_element> I need to turn &lt; or &gt; into < or > because a downstream app requires it in this format throughout the entire XML document. I would need this for quotes and apostrophes too. I am tryinging a character-map in XSLT 2.0. <xsl:character-map name="specialchar"> <xsl:output-character character="&apos;" string="&apos;" /> <xsl:output-character character=""" string="&quot;" /> <xsl:output-character

xsl:character-map to replace special characters

偶尔善良 提交于 2020-01-23 09:27:05
问题 Given an element with a value of: <xml_element>Distrib = SU & Prem &lt;&gt; 0</xml_element> I need to turn &lt; or &gt; into < or > because a downstream app requires it in this format throughout the entire XML document. I would need this for quotes and apostrophes too. I am tryinging a character-map in XSLT 2.0. <xsl:character-map name="specialchar"> <xsl:output-character character="&apos;" string="&apos;" /> <xsl:output-character character=""" string="&quot;" /> <xsl:output-character

Copy node and add value to attribute with Xslt

我的梦境 提交于 2020-01-23 08:00:08
问题 Basiccly i have problem with xml and xslt which i do not know how to solve, and would appreciate any help regarding this matter where to start. I have XML: <root> <test value="1" setting="3"> <tag1>data....</tag1> <tag2>data....</tag2> <tag n+1>data....</tag n+1> </test> <test value ... . . . </test> </root> Now i would now need to copy, all nodes in "test" node in this way and add always value 3 to settings value (settings value is changing in test node) in 4 new nodes like shown below so i

Copy node and add value to attribute with Xslt

╄→尐↘猪︶ㄣ 提交于 2020-01-23 07:59:29
问题 Basiccly i have problem with xml and xslt which i do not know how to solve, and would appreciate any help regarding this matter where to start. I have XML: <root> <test value="1" setting="3"> <tag1>data....</tag1> <tag2>data....</tag2> <tag n+1>data....</tag n+1> </test> <test value ... . . . </test> </root> Now i would now need to copy, all nodes in "test" node in this way and add always value 3 to settings value (settings value is changing in test node) in 4 new nodes like shown below so i

What is the difference between <copy-of> and <apply-templates>?

江枫思渺然 提交于 2020-01-23 05:39:11
问题 When should I use <copy-of> instead of <apply-templates> ? What is their unique role? Most of the time replacing <apply-templates> with <copy-of> gives out weird output. Why is that? 回答1: xsl:copy-of is an exact copy of the matched input xml element. No xslt processing takes place and the output from that element will be exactly the same as the input. xsl:apply-templates tells the xslt engine to process templates that match the selected elements. xsl:apply-templates is what gives xslt its

Xslt Looping using xsl:variable

≯℡__Kan透↙ 提交于 2020-01-23 01:36:08
问题 I wanted to use xsl:variable and loop based on it's count, but I am not sure if its possible in Xslt. for example if I have a variable name count <xsl:variable name="count" as="xs:integer" select="4"/> Can I make use of variable, in below form!!! <xsl:if test="some condition"/> loop from 0 to $count ...do something here end loop </xsl:if> Is it possible? My Input XML: <Root> <Element> <Value>1</Value> <Value>2</Value> </Element> <Element> <Value>1</Value> <Value>2</Value> <Value>3</Value>

Extremely slow XSLT transformation in Java

不羁岁月 提交于 2020-01-23 01:08:44
问题 I try to transform XML document using XSLT. As an input I have www.wordpress.org XHTML source code, and XSLT is dummy example retrieving site's title (actually it could do nothing - it doesn't change anything). Every single API or library I use, transformation takes about 2 minutes! If you take a look at wordpress.org source, you will notice that it is only 183 lines of code. As I googled it is probably due to DOM tree building. No matter how simple XSLT is, it is always 2 minutes - so it

Truncate XML with XSLT

一曲冷凌霜 提交于 2020-01-22 20:00:06
问题 I have a question for the clever people of the SO community. Below is a snippet of XML generated by the Symphony CMS. <news> <entry> <title>Lorem Ipsum</title> <body> <p><strong>Lorem Ipsum</strong></p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed malesuada auctor magna. Vivamus urna justo, pulvinar nec, sagittis malesuada, accumsan in, massa. Quisque mi purus, gravida eget, ultricies a, porta in, sem. Maecenas justo elit, elementum vel, feugiat vulputate, pulvinar nec,

How to import Javascript object in xslt script

拟墨画扇 提交于 2020-01-22 03:42:07
问题 I am using XSLT stylesheet to generate jUnit HTML report which will be sent as an email. Here I want to create Hyperlink in xslt stylesheet and the value of a link is available in the output of javascript "cur['adm-lib']" as mentioned below. <script type="text/javascript" language="JavaScript"> var TestCases = new Array(); var cur; <xsl:for-each select="./testsuite"> <xsl:apply-templates select="properties"/> </xsl:for-each> <xsl:template match="properties"> cur = TestCases['<xsl:value-of

Saxon XSLT Transformation: How to close outputstream when failing during transformation

☆樱花仙子☆ 提交于 2020-01-22 02:33:08
问题 I want to do a XSLT transformation with multiple output files. There for I used "xsl:result-document". When the transformation fails, all output files should be deleted. But if the generation of a document created by "xsl:result-document" fails, my program not able to delete this document anymore. I think the reason is, that "xsl:result-document" create a different OutputStream. Does anyone know how to close all output streams? Edit: I use Saxon 9.5 to do the transformation. Please see below