xslt-1.0

XSLT: Passing URL querystring as a parameter

家住魔仙堡 提交于 2019-12-11 03:24:09
问题 I know this is an old question that has been passed around SO several times but I was wondering whether anyone can expand on whether a URL that has a querystring attached to it can be stripped out via XSLT 1.0 and can be used as a parameter for later use of the XSLT transformation. For example, I have a URL of http://www.mydomain.com/mypage.htm?param1=a&param2=b via XSLT, I am looking for a result of something along the lines of: <xsl:param name="param1">a</xsl:param> and <xsl:param name=

XSL-T Adding Missing schema elements from input xml as empty tags

社会主义新天地 提交于 2019-12-11 03:06:09
问题 I am relatively new to XSL-T. My requirement is rather simple. I want to add missing elements of Schema which are not present in the xml as empty tags. For example, <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified"> <xs:element name="RootElement"> <xs:complexType> <xs:sequence> <xs:element name="XMLTagOne"> <xs:complexType> <xs:sequence> <xs:element type="xs:string" name="value1"/> </xs:sequence> </xs:complexType> </xs

How do I time my XSLT execution times to millisecond accuracy?

久未见 提交于 2019-12-11 02:54:37
问题 I have an XSLT (running under Sitecore) that I'd like to benchmark. For example: <xsl:variable name="start_ms" select="TIME IN MILLIS" /> Do something <xsl:variable name="end_ms" select="TIME IN MILLIS" /> <xsl:variable name="total_ms" select="$end_ms - $start_ms" /> Do something else Unfortunately I can't manage to get the time to milliseconds accuracy. If I include xmlns:date="http://exslt.org/dates-and-times" I get date:dateTime() , but that only goes to seconds accuracy. Similarly, sc

How do I use SUM and AVERAGE in XSL?

一曲冷凌霜 提交于 2019-12-11 02:47:24
问题 I want to the total kilometers per car and the average kilometers per day This is the input XML : <?xml version="1.0" encoding="ISO-8859-1" ?> <output> <cars> <car> <id>1</id> <brand>BMW</brand> <type>M3</type> <license>AD-9999-ATSR</license> </car> <car> <id>2</id> <brand>Volkwagen</brand> <type>GTI</type> <license>ASD-7458-WERT</license> </car> </cars> <distances> <distance> <id_car>1</id_car> <date>20120118</date> <distance>90</distance> </distance> <distance> <id_car>1</id_car> <date

Grouping and counting in XSLT 1.0

故事扮演 提交于 2019-12-11 02:46:38
问题 I have input XML: <?xml version="1.0" encoding="UTF-8"?> <root> <FT>Paket</FT> <FT>Parti</FT> <FT>Paket</FT> <FT>Styche</FT> <FT>Styche</FT> </root> And I want my output to display such as - Paket 2 Parti 1 Styche 2 Its is grouping the value of elements and the no. is showing the total count of the value being repeated. Like Paket is indicating the value and it is being repeated 2 times in the XML. How the logic will work? 回答1: In XSLT 1.0, using Muenchian grouping: <xsl:stylesheet version="1

Populate Attribute and values to all parent nodes of the XML file from 4th parent node

拈花ヽ惹草 提交于 2019-12-11 02:35:30
问题 I am new to XSLT and would like to add Attribute and Value of the same to all parent nodes starting from 2nd parent node. here the logic should be the if there is Main node, the attribute(Mainattribute) should be one time and for rest of all parent nodes under the Main node should have different attribute(childattribute) which should be same across all other than Main node. we have a input xml like below : It is just have some fields only, ideally there will be more tags and may differ. <?xml

Maintaining XML comments during XSL Transformations

末鹿安然 提交于 2019-12-11 02:27:17
问题 XML <?xml-stylesheet type="text/xsl" href="script.xsl"?> <elements> <stack> <name>Ray</name> <status>0</status> </stack> <!-- Comment 1 --> <things> <!-- Comment 2 --> <thing> <color>red</color> <!-- State Comment --> <state>solid</state> <!-- Weight Comment --> <weight>45</weight> <unit>34</unit> <!-- Comment 3 --> </thing> </things> <favs> <stick>ready</stick> <!-- Comment 4--> </favs> </elements> EXPECTED OUTPUT <elements> <stack> <name>Ray</name> <status>0</status> </stack> <!-- Comment 1

XSLT How to do a classic for x to y loop?

时间秒杀一切 提交于 2019-12-11 01:53:27
问题 I need to do a classic for i=0 to N loop, how can it be done in xstl 1.0? thanks. <xsl:for-each select="¿¿¿$i=0..5???"> <fo:block> <xsl:value-of select="$i"/> </fo:block> </xsl:for-each> To give an example, I have <foo> <bar>Hey!</bar> </foo> And want an output of Hey! Hey! 回答1: XSLT is a functional programming language and as such it is very different to any procedural languages you already know. Although for loops are possible in XSLT, they do not make use of the inherent strengths of XSLT

declare global variable in project and use it in xslt

北城以北 提交于 2019-12-10 23:00:45
问题 I would seek this your guidance for doubt in XSLT. In my current project there is a requirement to create many XSLT files. In these transformations, there are few common steps performed; for.eg. changing uppercase of an element value from input xml. I'm currently using the below code in an XSLT, so if there are 50 XSLT being created then this code will be duplicated. <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" /> <xsl:variable name="uppercase" select="

XSLT find and replace carriage returns

半城伤御伤魂 提交于 2019-12-10 22:27:44
问题 I need to replace carriage returns from input XML. Input as follows: <Answer> <Label>Notes/Comments</Label> <Value>Q WERTYU IOPASDFGHJKLZXCVBNM QWERTYUIOPASDF GHJKLZXCVBNM QWERTYU IOPASDFGHJKLZXCVBNM QWERTYUIOPASDFGHJ KLZXCVBNM QWERTYU IOPASDFGHJKLZXCVBNM QWERTYUIOPASDFGH JKLZXCVBNM QWERTYUIOPASDF GHJKLZXCVBNM QWERTYUIOP ASDFGHJKLZXCVBNM QWERTYU IOPASDFGHJ KLZXCVBNM QWERTY UIOPAS DFGHJKLZX CVBNM QWERTYUIO PASDFGHJ KLZXC VBNM </Value> <Iteration>0</Iteration> <DataType>TEXT</DataType> </Answer