xslt-2.0

How to convert flat xml data to hierarchical data xml

早过忘川 提交于 2021-02-05 08:31:22
问题 I have to convert a flat xml to hierarchical xml. I have no idea for this task. Below is input for conversion. Input:- <body> <p class="title">Article Title</p> <p class="Authors">abc, pqr and xyz</p> <p class="intro">here is introdution text......</p> <p class="head1">1: Heading level 1</p> <p>some text here</p> <p>some text here</p> <p class="head2">1.1: Heading level 2</p> <p>some text here</p> <p>some text here</p> <p class="head3">1.1.1: Heading level 3</p> <p>some text here</p> <p>some

Is there a way to use mode in an xsl:if test?

不羁岁月 提交于 2021-02-05 05:24:26
问题 I've been learning to use the mode attribute with XSLT and was wondering if there's a way to test for it within a template, such as in an xsl:if statement? I've only seen it used at the xsl:template level and maybe that's the only way. Say I want to add a "../" in front of a path attribute (@href), but only if mode="print": <xsl:template name="object" mode="#all"> <img> <xsl:attribute name="src"> <xsl:if test="mode='print'"><xsl:text>../</xsl:text></xsl:if> <xsl:value-of select="@href"/> <

dependency graph traversal in XSLT for copying related elements of an XML model

孤街浪徒 提交于 2021-01-29 17:34:52
问题 I want to demonstrate XSL powerfullness for data exploration by solving the following problem: Given an xml file that describes some kind of "entity-relashionship" model, and for one entity in that model given by a name (assuming an attribute of the XML schema is used as identifier), I want a transformation that produce a new XML model that contains the given entity, plus all of its relatives as per the "Transitive closure of the dependencies relationship" of that given entity. For example,

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

Inserting ENTITY declarations in DOCTYPE XSLT 2.0 Saxon9he

你。 提交于 2021-01-28 20:53:14
问题 I am tasked with breaking up an XML document into individual work packages. The only part I am having trouble with is inserting graphic entity declarations in the DOCTYPE like so: <!DOCTYPE frntcover PUBLIC "-//USA-DOD//DTD TM Assembly REV C" "production.dtd" [ <!ENTITY IMAGE001.jpg SYSTEM "IMAGE001.jpg" NDATA jpg> ]> (Never mind the extension in the entity name, that's how they do it here.) Anyway, the entities will be constructed from all the @boardno that are found in the main XML file

SaxonApiException: The context item for axis step ./CLIENT is absent

那年仲夏 提交于 2021-01-27 19:46:55
问题 I am trying to convert and XML to an XML using XSLT 2.0 in saxon/java. I am using a sample XML I found on stack overflow thread "Applying Muenchian grouping for a simple XML with XSLT" However I am getting an error : XPDY0002: The context item for axis step ./CLIENT is absent. My test XSL: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output omit-xml-declaration="no" indent="yes" /> <xsl:strip-space elements="*" />

SaxonApiException: The context item for axis step ./CLIENT is absent

时间秒杀一切 提交于 2021-01-27 19:22:41
问题 I am trying to convert and XML to an XML using XSLT 2.0 in saxon/java. I am using a sample XML I found on stack overflow thread "Applying Muenchian grouping for a simple XML with XSLT" However I am getting an error : XPDY0002: The context item for axis step ./CLIENT is absent. My test XSL: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output omit-xml-declaration="no" indent="yes" /> <xsl:strip-space elements="*" />

Grouping Nodes by hardcoding node values in XSLT

若如初见. 提交于 2021-01-20 12:43:14
问题 <root> <Entry> <ID>1</ID> <Details> <Code>A1</Code> <Value>1000</Value> </Details> </Entry> <Entry> <ID>2</ID> <Details> <Code>A2</Code> <Value>2000</Value> </Details> </Entry> <Entry> <ID>3</ID> <Details> <Code>B1</Code> <Value>3000</Value> </Details> </Entry> <Entry> <ID>4</ID> <Details> <Code>B2</Code> <Value>4000</Value> </Details> </Entry> </root> I have this input XML which I am looking to group via XSLT wherein the grouping happens by hardcoding node values . Let me explain that in

How to apply a function to a sequence of nodes in XSLT

怎甘沉沦 提交于 2021-01-04 04:31:00
问题 I need to write an XSLT function that transforms a sequence of nodes into a sequence of strings. What I need to do is to apply a function to all the nodes in the sequence and return a sequence as long as the original one. This is the input document <article id="4"> <author ref="#Guy1"/> <author ref="#Guy2"/> </article> This is how the calling site: <xsl:template match="article"> <xsl:text>Author for </xsl:text> <xsl:value-of select="@id"/> <xsl:variable name="names" select="func:author-names(