xslt-2.0

How to use for each group in XSL

末鹿安然 提交于 2019-11-26 23:14:55
问题 im still learning for-each-group what is the best way of grouping something like this using XSL?(by country) i'm trying to use XSL to convert this XML to another XML. <?xml version="1.0" encoding="UTF-8"?> <Person> <Student> <Info Country="England" Name="Dan" Age="20" Class="C" /> </Student> <Student> <Info Country="England" Name="Dan" Age="20" Class="B" /> </Student> <Student> <Info Country="England" Name="Sam" Age="20" Class="A" /> </Student> <Student> <Info Country="Australia" Name="David"

dynamic xpath in xslt?

北城余情 提交于 2019-11-26 23:06:20
I have follwing set of files: SourceFile.xml: <?xml version="1.0" encoding="utf-8" ?> <Employees> <Employee id="1"> <firstname relationship="headnote">Atif</firstname> <lastname relationship="lname">Bashir</lastname> <age relationship="age">32</age> </Employee> </Employees> ParamerterSettings.xml <?xml version="1.0" encoding="utf-8"?> <Settings> <Employee id="1"> <sourceFile>Lookup1.xml</sourceFile> <sourceXpathfield>Employees/Employee[@id</sourceXpathfield> <lookupXpathfield>Employees/Employee[@id='1']</lookupXpathfield> <elementstoinsert>xyz</elementstoinsert> </Employee> </Settings> Lookup

Check if a string is null or empty in XSLT

醉酒当歌 提交于 2019-11-26 21:15:03
How can I check if a value is null or empty with XSL ? For example, if categoryName is empty? I'm using a when choosing construct. For example: <xsl:choose> <xsl:when test="categoryName !=null"> <xsl:value-of select="categoryName " /> </xsl:when> <xsl:otherwise> <xsl:value-of select="other" /> </xsl:otherwise> </xsl:choose> steamer25 test="categoryName != ''" Edit : This covers the most likely interpretation, in my opinion, of "[not] null or empty" as inferred from the question, including it's pseudo-code and my own early experience with XSLT. I.e., "What is the equivalent of the following

XSL xsl:template match=“/”

这一生的挚爱 提交于 2019-11-26 19:24:37
I am just learning XML and how to use XSL files. In an XSL file I found the following term: xsl:template match="/" What does this stand for? And what could I use instead of the / ? Could I write table or any other HTML tag instead of / ? Dimitre Novatchev The value of the match attribute of the <xsl:template> instruction must be a match pattern . Match patterns form a subset of the set of all possible XPath expressions . The first, natural, limitation is that a match pattern must select a set of nodes. There are also other limitations. In particular, reverse axes are not allowed in the

xsl: how to split strings?

北战南征 提交于 2019-11-26 16:34:01
I want to split an address on semicolons ( ; ) into rows separated by <br /> : e.g. if address = 123 Elm Street , I want to output 123 Elm Street , but if address = 123 Elm Street;PO Box 222 , I want to output 123 Elm Street<br />PO Box 222 and if address = 123 Elm Street;PO Box 222;c/o James Jones , I want to output 123 Elm Street<br />PO Box 222<br />c/o James Jones Is there a way to do this? (probably easy but I'm not that familiar with XSLT) The plain XSL selector is <xsl:value-of select="address"/> and I would like to modify this XSLT fragment to split on semicolon. update : Apparently

How to remove elements from xml using xslt with stylesheet and xsltproc?

江枫思渺然 提交于 2019-11-26 15:12:39
I have a lot of XML files which have something of the form: <Element fruit="apple" animal="cat" /> Which I want to be removed from the file. Using an XSLT stylesheet and the Linux command-line utility xsltproc, how could I do this? By this point in the script I already have the list of files containing the element I wish to remove, so the single file can be used as a parameter. EDIT: the question was originally lacking in intention. What I am trying to achieve is to remove the entire element "Element" where (fruit=="apple" && animal=="cat"). In the same document there are many elements named

Two phase processing: Do not output empty tags from phase-1 XSLT 2.0 processing

橙三吉。 提交于 2019-11-26 14:31:30
问题 I have some complex XSLT 2.0 transformations. I'm trying to find out if there is general purpose way to ensure that no empty tags are output. So... conceptually, a final stage of processing that recursively removes all empty tags. I understand this could be done by a separate XSLT that did nothing but filter out empty tags, but I need to have it all packaged together in a single one. 回答1: This XSLT 2.0 transformation illustrates how multi-pass (in this case 2-pass) processing can be done :

XSLT: How to change an attribute value during <xsl:copy>?

梦想的初衷 提交于 2019-11-26 12:24:23
问题 I have an XML document, and I want to change the values for one of the attributes. First I copied everything from input to output using: <xsl:template match=\"@*|node()\"> <xsl:copy> <xsl:apply-templates select=\"@*|node()\"/> </xsl:copy> </xsl:template> And now I want to change the value of the attribute \"type\" in any element named \"property\" . 回答1: Tested on a simple example, works fine: <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> <

dynamic xpath in xslt?

无人久伴 提交于 2019-11-26 12:19:41
问题 I have follwing set of files: SourceFile.xml: <?xml version=\"1.0\" encoding=\"utf-8\" ?> <Employees> <Employee id=\"1\"> <firstname relationship=\"headnote\">Atif</firstname> <lastname relationship=\"lname\">Bashir</lastname> <age relationship=\"age\">32</age> </Employee> </Employees> ParamerterSettings.xml <?xml version=\"1.0\" encoding=\"utf-8\"?> <Settings> <Employee id=\"1\"> <sourceFile>Lookup1.xml</sourceFile> <sourceXpathfield>Employees/Employee[@id</sourceXpathfield>

Preserving entity references when transforming XML with XSLT?

核能气质少年 提交于 2019-11-26 11:38:03
问题 How can I preserve entity references when transforming XML with XSLT (2.0)? With all of the processors I\'ve tried, the entity gets resolved by default. I can use xsl:character-map to handle the character entities, but what about text entities? For example, this XML: <!DOCTYPE doc [ <!ENTITY so \"stackoverflow\"> <!ENTITY question \"How can I preserve the entity reference when transforming with XSLT??\"> ]> <doc> <text>Hello &so;!</text> <text>&question;</text> </doc> transformed with the