xslt-2.0

Word Frequency Counter in XSLT

耗尽温柔 提交于 2019-12-02 04:17:20
问题 I am trying to make a word frequency counter in XSLT. I want it to use stop words. I got started with Michael Kay's book. But I have trouble getting the stop words to work. This code will work on any source XML file. <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:variable name="stopwords" select="'a about an are as at be by for from how I in is it

xslt remove duplicate elements

本秂侑毒 提交于 2019-12-02 03:34:01
I am trying to remove elements with the same href attribute form this file: <?xml version="1.0" encoding="UTF-8"?> <images> <item id="d1e152_1" href="Pic/104764.jpg" media-type="image/jpeg"/> <item id="d1e163_2" href="Pic/104764.jpg" media-type="image/jpeg"/> <item id="d1e174_3" href="Pic/104764.jpg" media-type="image/jpeg"/> <item id="d1e218_4" href="Pic/104763.jpg" media-type="image/jpeg"/> <item id="d1e349_5" href="Pic/110001.tif" media-type="image/tif"/> <item id="d1e681_6" href="Pic/199201.tif" media-type="image/tif"/> <item id="d1e688_7" href="Pic/124566.tif" media-type="image/tif"/> <

Annotating an xml instance from a list of xpath statements with xslt

不羁岁月 提交于 2019-12-02 01:24:15
Given a list of xpath statements, I want to write a stylesheet that will run through an xml document and output the same document but with a comment inserted before the node identified in each xpath statement. Let's make up an example. Start with an xml instance holding the xpath statements: <paths> <xpath location="/root/a" annotate="1"/> <xpath location="/root/a/b" annotate="2"/> </paths> Given the input: <root> <a> <b>B</b> </a> <c>C</c> </root> It should produce: <root> <!-- 1 --> <a> <!-- 2 --> <b>B</b> </a> <c>C</c> </root> My initial thought is to have an identity stylesheet which takes

Word Frequency Counter in XSLT

纵然是瞬间 提交于 2019-12-02 00:47:30
I am trying to make a word frequency counter in XSLT. I want it to use stop words. I got started with Michael Kay's book . But I have trouble getting the stop words to work. This code will work on any source XML file. <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:variable name="stopwords" select="'a about an are as at be by for from how I in is it of on or that the this to was what when where who will with'"/> <wordcount> <xsl:for-each-group group

How to get the Particular XML elements indexes with respect to this scenario in xslt 2.0?

我是研究僧i 提交于 2019-12-02 00:05:00
I want to convert one xml to another xml by using XSLT2.0.While doing so, i want to find out some XML elements indexes with respect to my scenaio i explained here... This is XML Document : <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"> <w:body> <w:sdt> <w:sdtContent> <w:p> <w:pPr> <w:pStyle w:val="TOC"></w:pStyle> </w:pPr> </w:p> </w:sdtContent> </w:sdt> <w:p> <!-- index value 0 --> </w:p> <w:p> <!-- index value 1 --> </w:p> <w:Bookmark></w:Bookmark> <!-- index value 2 --> <w:Bookmark></w:Bookmark> <!-

XSLT- normalize non-breaking whitespace characters

南笙酒味 提交于 2019-12-01 23:55:25
问题 I have a sample xml file like this, <doc> <p>text1 text2 </p> <p>text1 text2 </p> <p>text1 text2 </p> </doc> this sample xml, first <p> has space whitespace character ( ), second <p> has tab whitespace whitespace character ( ) and third <p> has space non-breaking whitespace character (   ). I need to remove the any white spaces appearing just before closing tag. So, expected output should be, <doc> <p>text1 text2</p> <p>text1 text2</p> <p>text1 text2</p> </doc> By using xslt normalize

XSLT: Sorting based on sum of values from other nodes

巧了我就是萌 提交于 2019-12-01 23:21:46
问题 I'm rather new to coding xslt and have got rather stuck trying to do the following. I have an xml file that has breeding info for horses broken into two main sections. 1. Horses node has the performance details of individual horses as well as an id to who their sire was. 2. Sires node is list of the Sires also holding breeding specific statistics. I need to sort the list of sires based on the sum of the 'stake' money won by their foals (i.e. in the horses node). So a cut down xml file looks

XSLT- normalize non-breaking whitespace characters

只愿长相守 提交于 2019-12-01 21:42:41
I have a sample xml file like this, <doc> <p>text1 text2 </p> <p>text1 text2 </p> <p>text1 text2 </p> </doc> this sample xml, first <p> has space whitespace character ( ), second <p> has tab whitespace whitespace character ( ) and third <p> has space non-breaking whitespace character (   ). I need to remove the any white spaces appearing just before closing tag. So, expected output should be, <doc> <p>text1 text2</p> <p>text1 text2</p> <p>text1 text2</p> </doc> By using xslt normalize-space() I can remove unnecessary spaces and tab characters but not non-breaking whitespace characters.

XSL transform on text to XML with unparsed-text: need more depth

旧街凉风 提交于 2019-12-01 21:36:21
My rather well-formed input (I don't want to copy all data): StartThing Size Big Colour Blue coords 42, 42 foo bar EndThing StartThing Size Small Colour Red coords 29, 51 machin bidule EndThing <!-- repeat a few thousand times--> I have the below XSL which I modified from Parse text file with XSLT <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:param name="text-encoding" as="xs:string" select="'iso-8859-1'"/> <xsl:param name=

Use XSLT to mark up text matching regex?

大兔子大兔子 提交于 2019-12-01 19:56:32
I am trying to use XSLT 2.0 (Saxon-PE 9.6) on an HTML document to create tags that surround all contiguous runs of characters from a specified non-Latin Unicode block (spaces allowed). I need to apply this process to every text() node in the document. I have made some progress with two approaches that use <xsl:analyze-string> and using fn:replace() but I've not been able to arrive at a satisfactory and complete solution. For example, here is some text containing Hindi: Input: <p>चाय का कप means ‘cup of tea’ in हिन्दि.</p> Desired Output: <p><span xml:lang="hi-Deva">चाय का कप</span> means ‘cup