xslt

Right padding a String with Zeros in XSLT

余生长醉 提交于 2021-01-29 06:50:48
问题 I need to right pad this with leading zeros to a length of 3 in the output (which is fixed length text) Examples: A becomes A00 AB becomes AB0 ABC becomes ABC Please help. 回答1: You could do simply: substring(concat($your-string, '000'), 1, 3) Note that this means that "ABCD" becomes "ABC" . 来源: https://stackoverflow.com/questions/65317883/right-padding-a-string-with-zeros-in-xslt

How can I create a footer on the last page

别说谁变了你拦得住时间么 提交于 2021-01-29 06:42:53
问题 Here the clean code: <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master master-name="pages-normale" page-width="297mm" page-height="210mm" margin-top="0.5cm" margin-bottom="0.5cm" margin-left="0.5cm" margin-right="0.5cm"> <fo:region-body margin-top="1cm" margin-bottom="1cm"/> <fo:region-before margin-top="1cm" margin-bottom="1cm" extent="7cm"/> <fo:region-after margin-top="1cm" margin-bottom="1cm" extent="1cm"/> </fo:simple-page-master> </fo

Using a variable as part of a XPath selection

房东的猫 提交于 2021-01-29 04:19:53
问题 I'm looking to use a variable as part of an XPath expression. My problem might be the msxsl node-set function... not sure. But don't let that cloud your judgement... read on... I'm using a .NET function to load up the content file, which is passed in via bespoke XML content. The @file results in an XML file. The bespoke XML the sits on the page looks like : <control name="import" file="information.xml" node="r:container/r:group[@id='set01']/r:item[1]" /> The XSL looks like : <xsl:variable

add namespace and prefix to xml

一笑奈何 提交于 2021-01-29 03:29:46
问题 I am using camel to route messages to a Webservice. The Messages are like XML but without namespaces/prefixes. The problem now is that the Webservice expects the XML but with the appropriate namespaces for each element. So as an example: <a> <b>value_b</b> <c>value_c</c> </a> is what im getting in, but what needs to be sent out should look like this <a xmlns:n1="http://yadda-ns1.com" xmlns:n2="http://yadda-ns2.com"> <ns1:b>value_b</ns1:b> <ns2:c>value_c</ns2:c> </a> if it was the same

add namespace and prefix to xml

ε祈祈猫儿з 提交于 2021-01-29 03:18:47
问题 I am using camel to route messages to a Webservice. The Messages are like XML but without namespaces/prefixes. The problem now is that the Webservice expects the XML but with the appropriate namespaces for each element. So as an example: <a> <b>value_b</b> <c>value_c</c> </a> is what im getting in, but what needs to be sent out should look like this <a xmlns:n1="http://yadda-ns1.com" xmlns:n2="http://yadda-ns2.com"> <ns1:b>value_b</ns1:b> <ns2:c>value_c</ns2:c> </a> if it was the same

I saw this recursion template in XSLT and cannot understand what is happening

只谈情不闲聊 提交于 2021-01-29 03:07:05
问题 What happens when the control gets into xsl:variable? It should never reach <xsl:value-of select="$number * $recursive_result"/> as it is calling the template again and again but it does. This made me question the overall control flow of XSLT. Please explain! <xsl:template name="factorial"> <xsl:param name="number" select="1"/> <xsl:choose> <xsl:when test="$number < 1"> <xsl:value-of select="1"/> </xsl:when> <xsl:otherwise> <xsl:variable name="recursive_result"> <xsl:call-template name=

How to aggregate nodes in XSLT 1.0?

随声附和 提交于 2021-01-28 21:29:58
问题 I often need to aggregate a sequence of nodes using XSLT 1.0 but I always struggle to find a clean solution. This is a typical example; Input <x>Foo/Red</x> <x>Foo/Green</x> <x>Foo/Blue</x> <x>Bar/Hello</x> <x>Bar/World</x> Desired output <y s="Foo">Red, Green, Blue</y> <y s="Bar">Hello, World</y> I always end up in a mess with this type of problem. Is there an elegant XSLT 1.0 solution to the above? I'm using PHP 's libxslt so I do have the exslt:node-set() function available to use if

Logic for passing variable number of parameters to XSLT

那年仲夏 提交于 2021-01-28 19:53:09
问题 I need to develop an application that will periodically check data from a XML feed , process it and take appropriate actions like notifying the users etc but mostly used to generate and view a report. This xml feed basically checks the uptime, downtime of applications. Here are the steps that i am following: I am downloading a xml file from a remote location to my own server. Check which applications to monitor from a properties file . Transform it to html using a XSLT and mail the html page.

xml transform to html using xslt

拈花ヽ惹草 提交于 2021-01-28 18:23:34
问题 I'm trying to use key function to transform xml to html look like: but I don't know how to make two table, because my if function write books one under other. A XML looks like: <library> <books> <book aut="JKR"> <title>Harry Potter and the Sorcerer's Stone</title> <quantity>5</quantity> </book> </books> <books> <book aut="JKR"> <title>example</title> <quantity>3</quantity> </book> <book aut="AC"> <title>example</title> <quantity>2</quantity> </books> <authors> <author id="JKR">J.K.Rowling<

setting default values for empty nodes

泄露秘密 提交于 2021-01-28 10:22:42
问题 I need to transform a piece of XML, so that the value of every node in a list I specify is set to "0" for example: <contract> <customerName>foo</customerName> <contractID /> <customerID>912</customerID> <countryCode/> <cityCode>7823</cityCode> </contract> would be transformed into <contract> <customerName>foo</customerName> <contractID>0</contractID> <customerID>912</customerID> <countryCode>0</contractID> <cityCode>7823</cityCode> </contract> How can this be accomplished using XSLT? I have