xslt-1.0

Merge functionality of two xsl files into a single file (continued…)

浪尽此生 提交于 2019-12-02 07:16:01
This is in continuation of my question: Merge functionality of two xsl files into a single file (not a xsl import or include issue) I have to merge the solution (xsl) of above question to below xsl: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:template match="/"> <Declaration> <Message> <Meduim> <xsl:value-of select="/Declaration/Message/Meduim"/> </Meduim> <MessageIdentifier> <xsl:value-of select="/Declaration/Message/MessageIdentifier"/> </MessageIdentifier> <ControlingAgencyCode> <xsl:value-of select="

Choosing between different namespaces in XSLT

放肆的年华 提交于 2019-12-02 07:00:38
问题 The XML I am expecting is supposed to be only one url/urn (xmlns:urn="urn:123:456") like below: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:urn="urn:123:456" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl" exclude-result-prefixes="urn"> When used with the below namespace it's OK: <Document xmlns="123:456" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> But recently I am receiving a different document with the same

XPath/XSLT contains() for multiple strings

为君一笑 提交于 2019-12-02 06:20:38
问题 Does contains() work for multiple words stored in a variable? Will the below one work? If it won't work, please help me with a solution. <xsl:variable name="games" select="footballvolleyballchesscarrom"/> <xsl:when test="contains($games,'chess,carrom')">CORRECT</xsl:when> 回答1: Assuming that you're looking to do a logical OR of substring containment ... First of all, this select is likely wrong 1 : <xsl:variable name="games" select="footballvolleyballchesscarrom"/> It's looking for an element

Merge different products belong to each standard

家住魔仙堡 提交于 2019-12-02 05:58:28
I have to transform the following xml content, <Standards xmlns="http://ws.wso2.org/dataservice"> <Standard> <ProductID>200057</ProductID> <Prefix>ISO</Prefix> <SNumber>1001</SNumber> <DraftProducts> <RelatedProduct> <ProductID>1500163</ProductID> </RelatedProduct> </DraftProducts> <ReferenceProducts> <RelatedProduct> <ProductID>263973</ProductID> <RelationId>708519</RelationId> <Designation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> </RelatedProduct> <RelatedProduct> <ProductID>320056</ProductID> <RelationId>934789</RelationId> <Designation xmlns:xsi="http://www.w3

check condition in xslt

∥☆過路亽.° 提交于 2019-12-02 05:51:26
Below is the input XML (Little Big) sorry for the bigger input XML and as well as output xml <tutorial> <lessons> <lesson> chapter unit 1 page </lesson> <lesson> chapter unit 10~ page </lesson> <lesson> chapter unit page </lesson> <lesson> note lesson </lesson> <lessons1> <lesson> chapter unit 1 page </lesson> <lesson> description page </lesson> <lesson> chapter unit page </lesson> </lessons1> </lessons> </tutorial> Below is my Output Xml <?xml version="1.0" encoding="ISO-8859-1"?> <Geography> <historical> <social> <toc1> <toc> <chapter>chapter</chapter> <unit>unit 1</unit> <pages>page</pages>

How to eliminate all <TAG/> and all attribute=“” by XSLT?

回眸只為那壹抹淺笑 提交于 2019-12-02 05:51:00
In a xsl:stylesheet I have this "identity like" transform, to eliminate comments, empty (terminal) tags and empty attributes... But the second xsl:when not works <xsl:template match="node()"> <xsl:choose> <xsl:when test="name()='p' and not(./*) and not(normalize-space(.))"></xsl:when> <xsl:when test="not(name()='img') and not(name()='br') and not(./*) and not(text())" ></xsl:when> <!-- this line NOT WORKS --> <xsl:otherwise><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy></xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="@*"> <xsl:choose> <xsl:when test="not

Remove the word 'and' in XSLT using translate function

社会主义新天地 提交于 2019-12-02 05:24:54
问题 I would like to remove the word ' and ' from a string using the translate function rather than using a replace . for instance: <xsl:variable name="nme" select="translate(./Name/text(), ',:, '')" /> in addition to ",:" i would like to remove the word ' and ' as well. Please suggest. 回答1: The translate function can't do this, it can only remove or replace single characters, not multi-character strings. Like so many things in XSLT 1.0 the escape route is a recursive template, the simplest

Adding one or incrementing variable in xslt

不想你离开。 提交于 2019-12-02 04:39:00
I want to make a Counter value getting incremented based on a condition. But i was not able to increment a value or add 1 to a global variable. I was using the following code <xsl:variable name="count">0</xsl:variable> <xsl:variable name="incre">1</xsl:variable> <xsl:template match="/"> <xsl:if test="$video1 != ''"> <xsl:variable name="count" select="number($count)+number($incrementor)"/> <!-- display video1 --> </xsl:if> <xsl:if test="$video2 != ''"> <xsl:variable name="count" select="number($count)+number($incrementor)"/> <!-- display video2 --> </xsl:if> <xsl:if test="$video3 != ''"> <xsl

Storing html tags within an xsl variable

*爱你&永不变心* 提交于 2019-12-02 03:59:25
Sorry if this is a dumb question, but it is possible to store, and retrieve, a HTML snippet within an xsl 1.0 variable? EG: <xsl:variable name="something"><p>Hi there</p><p>How are you today?</p></xsl:variable> <xsl:value-of disable-output-escaping="yes" select="$something"/> It just when I try, it seems to strip the HTML tags out. Thanks. You need to use <xsl:copy-of select="$something"/> instead of xsl:value-of . I'll add some explanation of what's happening :) The reason you're not getting the html tags is that the $something variable contains a dom fragment, not a string: the value-of

Pass absolute file path from java code to xslt document()

北慕城南 提交于 2019-12-02 02:44:40
In my xslt I'd like to look up an xml file. I need to pass the path to this file from java code.I have the followings: ... Transformer transformer = TRANSFORMER_FACTORY.newTransformer(); transformer.setParameter("mypath", "/home/user/repository"); xslt: <?xml version="1.0"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:param name="mypath"/> ... <xsl:template match="connection[@id]"> <xsl:variable name="lookupStore" select="document('$mypath/myfile.xml')/connections"/> <xsl:copy> <xsl:apply-templates select="