xslt-2.0

Populate XML template-file from XPath Expressions?

依然范特西╮ 提交于 2019-12-18 18:31:12
问题 What would be the best way to populate (or generate) an XML template-file from a mapping of XPath expressions? The requirements are that we will need to start with a template (since this might contain information not otherwise captured in the XPath expressions). For example, a starting template might be: <s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'> <ns1:create xmlns:ns1='http://predic8.com/wsdl/material/ArticleService/1/'> <article xmlns:ns1='http://predic8.com

xslt 2.0 tokenize and group

时光怂恿深爱的人放手 提交于 2019-12-18 09:55:38
问题 I have an text file with following data: <t>Heros Firstname Sean Lastname Connery DOB 25-08-1930 Films Dr.No 1962 Goldfinger 1964 Thunerball 1965 Award name Academy time 1 Award name BAFTA time 2 Award name Gloden Globes time 3</t> Expected output should look like: <Jamesfilms> <heros> <firstName>Sean</firstName> <lastName>Connery</lastName> <DOB>25-08-1930</DOB> </heros> <films> <Dr.No>1962</Dr.No> <Goldfinger>1964</Goldfinger> <Thunerball>1965</Thunerball> </films> <award> <name>Academy<

Convert 31-DEC-2016 to 2016-12-31

随声附和 提交于 2019-12-18 09:44:40
问题 I want to convert the 31-DEC-2016 i.e., dd-mmm-yyyy to yyyy-mm-dd in the XSLT using format-dateTime function but the output is not as expected.Can anyone help on this? <ns1:QuoteDate> <xsl:value-of select='concat(xp20:format-dateTime(/Quote/QuoteHeader/QuoteDate,"[Y0001]-[M01]-[D01]"),"T00:00:00")'/> </ns1:QuoteDate> I want to get the value for this particular thing.31-DEC-2016 : This is the input and i have to transform over here in the code Once that is converted, How to concat the the

xsl:for-each-group help needed

二次信任 提交于 2019-12-18 07:02:55
问题 I went through XSLT Grouping Examples and Using for-each-group for high performance XSLT . I have a problem with for-each-group. My XML <?xml version="1.0" encoding="UTF-8"?> <body> <p name="h-title" other="main">Introduction</p> <p name="h1-title " other="other-h1">XSLT and XQuery</p> <p name="h2-title" other=" other-h2">XSLT</p> <p name=""> <p1 name="bold"> XSLT is used to write stylesheets.</p1> </p> <p name="h2-title " name="other-h2">XQuery</p> <p name=""> <p1 name="bold"> XQuery is used

How to convert ticks into a readable datetime with XSLT?

别等时光非礼了梦想. 提交于 2019-12-18 03:58:50
问题 I have an XML with timestamps like this: <node stamp="1236888746689" /> And I would like to display them in the result HTML as date with time. Is there a way to do it with XSLT (any Version)? EDIT: I am using XSLT2.0 with Saxon9. The base date is 1970-01-01 0:00. 回答1: You take the date 1970-01-01T00:00:00 and add as many milliseconds as the value of the stamp tells you: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"

How to group and sum values in XSLT

扶醉桌前 提交于 2019-12-18 03:56:46
问题 For each "agency" node I need to find the "stmt" elements that have the same key1, key2, key3 values and output just one "stmt" node with the "comm" and "prem" values summed together. For any "stmt" elements within that "agency" that don't match any other "stmt" elements based on key1, key2 and key3 I need to output them as is. So after transformation the first "agency" node would only have two "stmt" nodes (one summed) and the second "agency" node would be passed as is because the keys don't

XSLT split result in groups of 3

吃可爱长大的小学妹 提交于 2019-12-18 03:40:06
问题 An web-application is providing me an XML-feed, which I can't change. What I want to do is split this XML-feed into several unordered lists. I'm trying to do this with the XSLT below. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" encoding="utf-8" /> <xsl:param name="html-content-type" /> <xsl:template match="/NavigationTree"> <xsl:if test="count(//Page) >

Testing xslt code using your browser

故事扮演 提交于 2019-12-17 20:43:05
问题 Using my browser, I want to test if my xslt code is working. Currently I am copy pasting my xml and xslt code into w3school's example page and test it there. However, this is a real pain, since inserting tabs don't work there, syntax highlighting isn't active and the output window is too small. It is inconvenient to test your code there in general. So: What do I have to setup to test my xslt code? Do I have to change the name of the xslt file to xhtml or html? How do you test xslt code in

How to parse string to date in xslt 2.0

痴心易碎 提交于 2019-12-17 16:45:09
问题 Is it possible to convert strings like 30042013 (30 April 2013) to a date format? So I can use it later in functions like format-date 回答1: fn:dateTime($arg1 as xs:date?, $arg2 as xs:time?) will convert its arguments to xs:dateTime . Just use fn:substring() and fn:concat() to cut out the relevant parts and join them as yyyy-mm-dd before passing that to fn:dateTime . 回答2: Like Tomalak said, you can use substring() and concat() to build a string you can cast as an xs:date() (It doesn't sound

adding attribute to the node

自闭症网瘾萝莉.ら 提交于 2019-12-17 10:44:34
问题 I am trying to add an attribute to the node if the child node value is equal to some string. I have a main.xml file <Employees> <Employee> <countryid>32</countryid> <id name="id">1</id> <firstname >ABC</firstname> <lastname >XYZ</lastname> </Employee> <Employee> <countryid>100</countryid> <id name="id">2</id> <firstname >ddd</firstname> <lastname >ggg</lastname> </Employee> </Employees> So let's say if the country id is equal to 32 then it should add attribute country=32 to Employee node. The