xslt

XSLT remove elements that do not match regex

南楼画角 提交于 2021-02-17 04:44:41
问题 I want a simple XSLT which will only keep the elements which contain a certain regex: <example> <abc>text</abc> <bc>text</bc> <ab>text</ab> </example> I want the same XML output but only with the elements which contain an "a": <example> <abc>text</abc> <ab>text</ab> </example> 回答1: Start with the identity transform and add a template that suppresses elements whose name does not match your regex: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org

XSLT How to apply recursion to transform from a flat file to a nested tree

為{幸葍}努か 提交于 2021-02-11 17:55:34
问题 I know that there are several other question/answers similar to this, but I haven't read one that addresses my confusion over this transform. I need to move an XML document from this format: <root> <row> <t0>1</t0> <title>Main Title</title> </row> <row> <t0>2</t0> <title>Secondary Title</title> <note>Note</note> </row> <row> <t0>3</t0> <title>Tertiary Title</title> </row> <row> <t0>3</t0> <title>Another Title</title> </row> <row> <t0>2</t0> <title>A Second Secondary Title</title> <note>Note<

Convert Date / Time from 02/13/2013 23:59:59 to UNIX Milliseconds (1360817999000)

南笙酒味 提交于 2021-02-11 16:52:11
问题 Here is my beginning XML: <leaveBalanceTotal> <employeeId>0001234</employeeId> <uscId>1234567894654</uscId> <leaveDescription>Sick</leaveDescription> <leaveCodeStr>SS</leaveCodeStr> <balanceAmount>90.22</balanceAmount> <leaveDescription>Vacation</leaveDescription> <leaveCodeStr>VA</leaveCodeStr> <balanceAmount>187.11</balanceAmount> <leaveDescription>Winter Recess</leaveDescription> <leaveCodeStr>WR</leaveCodeStr> <balanceAmount>30</balanceAmount> <effectiveDate>03/11/2013 23:59:59<

Convert Date / Time from 02/13/2013 23:59:59 to UNIX Milliseconds (1360817999000)

那年仲夏 提交于 2021-02-11 16:51:35
问题 Here is my beginning XML: <leaveBalanceTotal> <employeeId>0001234</employeeId> <uscId>1234567894654</uscId> <leaveDescription>Sick</leaveDescription> <leaveCodeStr>SS</leaveCodeStr> <balanceAmount>90.22</balanceAmount> <leaveDescription>Vacation</leaveDescription> <leaveCodeStr>VA</leaveCodeStr> <balanceAmount>187.11</balanceAmount> <leaveDescription>Winter Recess</leaveDescription> <leaveCodeStr>WR</leaveCodeStr> <balanceAmount>30</balanceAmount> <effectiveDate>03/11/2013 23:59:59<

XSLT How to call XML item without ID partameter?

纵饮孤独 提交于 2021-02-11 15:16:34
问题 I have to create HTML table using XML data file and XSLT style sheet with < xsl:for-each > instruction. I should use names of items included into XML file. My data are organised in one XML file in two ways. Structure is as below: <Data> <FieldBook> (...) </FieldBook> <Reductions> (...) </Reductions> </Data> <FieldBook> <PointRecord ID="00000017" TimeStamp="2020-08-04T14:42:41"> <Name>osn2t</Name> <Code></Code> <Description1 Name="Description">k</Description1> <Method>GpsStaticObservation<

Adding common attribute to all chains in recursion

放肆的年华 提交于 2021-02-11 14:53:15
问题 A follow-up question to: Limit recursion with one deepest loop and assign exact id to all elements This code collects recursion. It is necessary that at the same time all recursion elements receive a COMMON-ID attribute with the value from the first element of the chain. This first element has also an attribue STATUS="0" . Other elements have STATUS="1" (for solution it may be useful). 1-source <root> <object id="a" id-3="COMMON-ID-1" STATUS="0"/> <object id="b" id-3="COMMON-ID-2" STATUS="0"/

XSLT select the second occurrence of an attribute

瘦欲@ 提交于 2021-02-11 14:34:18
问题 Is there a dynamic way to get the 2nd occurrence of an attribute ? For this XML example, I'd like to get the first 12 values of the SummaryCell/@Name value into a variable Month01, Month02, and so on; <SummaryHeader> <SummaryColumnGroup Name="2014"> <SummaryCell Name="Feb14" Type="Text" Value="Feb"/> <SummaryCell Name="Jan14" Type="Text" Value="Jan"/> </SummaryColumnGroup> <SummaryColumnGroup Name="2013"> <SummaryCell Name="Dec13" Type="Text" Value="Dec"/> <SummaryCell Name="Nov13" Type="Text

Saxon 9 HE, Java - Static errors, XTSE0210, XTSE0165, XPST0017

二次信任 提交于 2021-02-11 14:30:56
问题 When invoking an XSL transform using Saxon from my application I receive the following error Static error at xsl:import on line 34 column 45 XTSE0210: A stylesheet cannot import itself Static error at xsl:import on line 42 column 39 XTSE0165: Reported 1 error in imported stylesheet module Static error in {leg:IsCurrentWelsh(/)} in expression in xsl:when/@test on line 101 column 43 XPST0017: Cannot find a 1-argument function named . . . net.sf.saxon.trans.XPathException: Errors were reported

Saxon 9 HE, Java - Static errors, XTSE0210, XTSE0165, XPST0017

可紊 提交于 2021-02-11 14:30:21
问题 When invoking an XSL transform using Saxon from my application I receive the following error Static error at xsl:import on line 34 column 45 XTSE0210: A stylesheet cannot import itself Static error at xsl:import on line 42 column 39 XTSE0165: Reported 1 error in imported stylesheet module Static error in {leg:IsCurrentWelsh(/)} in expression in xsl:when/@test on line 101 column 43 XPST0017: Cannot find a 1-argument function named . . . net.sf.saxon.trans.XPathException: Errors were reported

For mixed-namespace XML content, how do I prevent redundant xmlns: definitions on newly created elements?

Deadly 提交于 2021-02-11 14:17:38
问题 I have the following HTML document that contains a MathML-namespaced element: <html> <head> <title>Equations</title> </head> <body> <p> <!-- MathML element --> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> <mi>m</mi> </mrow> </math> </p> </body> </html> I have the following XSLT that matches/modifies/creates content in both the top-level (default) and MathML namespaces: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version=