w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » XSLT » Page 1
XSL partial match on Name
I am only guessing here (since you won't show us your input) that you want to match: <xsl:template match="FieldRef[contains(@Name, 'Phone') or contains(@Name, 'phone')]">

Categories : Xslt

Read XML file and using it for 2nd XML in XSLT
I have assumed your xml to be like this as your "roles.xml" had some errors: <?xml version="1.0" encoding="UTF-8"?> <OperatorRange> <Role> <node_id>1</node_id> <user_start>1</user_start> <user_end>499</user_end> <manager_start>500</manager_start> <manager_end>699</manager_end> <training_star

Categories : Xslt

how to perform xslt transformation for input request in adapter
XSLT is not converting XML to JSON. XSLT transforms XML into another XML not JSON. Once your adapter has retrieved XML from a backend the WL Server infrastructure will automcatically convert it to JSON. In case you have XSLT defined the original XML retrieved from a backend will first be translated into new XML according to XSLT and after that the new XML will be converted to JSON. There's no o

Categories : Xslt

XSLT Add incremental id attribute to element
Try this: <xsl:template match="Comment"> <feedback> <xsl:attribute name="id"> <xsl:value-of select="count(preceding::Comments)+1"/> </xsl:attribute> <xsl:value-of select="."/> </feedback>

Categories : Xslt

self closing tags issue on XSLT
Try this: XML: <root> <name> <FirstName>Kishan</FirstName> <LastName>Kumar</LastName> </name> <name> <FirstName></FirstName> <LastName>Raj</LastName> </name> </root> XSLT: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding=

Categories : Xslt

How to retain the maximum valued mspace (having alpha-numeric content), if found successively along with other mspaces
If the unit will always be pts and you simply want to compare the number value contained in there then you could remove all letters to extract the number: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mf="http://example.com/mf" exclude-result-prefixes="xs mf"> <xsl:output indent="yes"/> <xsl

Categories : Xslt

How to retain the maximum valued mspace, if found successively along with other mspaces
Here is my suggestion using XSLT 2.0: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="math[descendant::

Categories : Xslt

How to retain maximum valued element
How about: XSLT 2.0 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="article"/> <!-- identity transform --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy&g

Categories : Xslt

To Avoid French Characters in Request XML
If each "French character" needs to be replaced with a single "English character", you can do so very easily by using the translate() function. If there are characters that need to be replaced by more than one character, for example "œ" to "oe", then you can use the replace() function - if you are using XSLT 2.0. Otherwise you will need a named recursive template to perform this operation. I a

Categories : Xslt

How to generate an XSLT programatically
Well, for a start, there have been 26 major releases and innumerable maintenance releases of Saxon since release 7.0, so forget anything you read there. It's not clear from your question whether you want to write your XSLT code generator in Java or in XSLT. I can't see why you would want to do it in Java rather than XSLT, but neither is difficult. The main problem with your question is that you d

Categories : Xslt

Creating Author Index with the help of xsl:for-each-group method
You've got to group authors twice, once by the first letter of fnm and then by concat(fnm,snm). Here is my try: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xs

Categories : Xslt

How to frame XML String Request in WSO2 esb
It should work for you. <x xmlns="http://ws.apache.org/ns/synapse"> declare namespace xs = "http://www.w3.org/2001/XMLSchema"; declare namespace env="http://eai.googl.afr/Envelope"; declare namespace kls="http://eai.klsdop.inso/klsservice"; declare variable $Id as xs:string+ external; declare variable $Name as xs:string+ external; declare variable $Message as xs:string+ exte

Categories : Xslt

How to ignore a group of elements if a specific node does not exist XSLT
I am guessing you want something like: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <document> <xsl:for-each select="file/files/segmentpair[Comments/Comment]"> <xsl:apply-templates select="Comments/Comment"/&g

Categories : Xslt

How to generate range(sequence) of values from given two input values
You can use the following: <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:template match="article/range"> <range> <xsl:attribute name="ID"> <xsl:for-each select="xs:integer(tokenize(.,'-')[1]) to xs:integer(tokenize(.,'-')[2])">

Categories : Xslt

xslt 1.0 template that reduces multiple spaces to a single space
You could use normalize-space(): <xsl:template match="text()"> <xsl:value-of select="normalize-space()"/> </xsl:template> This will remove any leading and trailing whitespace and reduce multiple spaces to a single space. For reference: https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/normalize-space

Categories : Xslt

Extreme XSLT 1 Flat to Hierarchial Transform needed
I'd really like some help getting started. Try this as your starting point: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tns="http://www.myco.com/DataService"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:key name="store" match="tns:storeID" use="." /> <xsl:key n

Categories : Xslt

Xslt to translate one to another and adding a row
It is all to do with the namespaces, basically your template match above only hits object if there is no namespace in the source XML. However you do have a namespace set xmlns="urn:partner.com" so you need to use the following to remove the binding to the namespace: <xsl:template match="*:objects">. I think you are looking for this, but it defiantly pushes you in the right direction: <x

Categories : Xslt

Removing duplicate records from xml
To remove the duplicate records, you can use Muenchian Grouping: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="no" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:key name="seqNumByRecord" match="Record" use="SeqNum"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:appl

Categories : Xslt

xsl copy if attribute of current node equals to attribute of another node
How about: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:param name="oid" select="'haveit'"/> <xsl:key name="meta" match="*" use="Ref/@MDID" /> <xsl:template match="/XML"> <xsl:variable name="matching-items" se

Categories : Xslt

Create list of nodes by copying from another lists
I think you want something like: XSLT 1.0 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="utf-8" indent="yes"/> <xsl:key name="vo" match="vo/field" use="@name" /> <xsl:template match="/"> <xsl:for-each select="root/input/field"> <xsl:choose&g

Categories : Xslt

How to define attribute name dynamically in XSLT?
You could write <xsl:template name="title"> <xsl:apply-templates select="$navigation" mode="title" /> </xsl:template> <xsl:template match="item" mode="title"> <xsl:if test="$navigation-id = @id"> <xsl:choose> <xsl:when test="$current-language = 'de'"> <xsl:value-of select="@title-de" /> </xsl:when>

Categories : Xslt

How do I skip xslt code when xml condition is true?
Try something along these lines: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates select="Integration[not(ControlPoint/@UserID='MOO' and (ControlPoint='SAVE-EVENT' or ControlPoint='SAVE-SENTENCE'))]/Case"/> </xsl:templa

Categories : Xslt

How to loop through common id values in XSLT
The following XSLT <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="@*|node()"> <xsl:apply-templates select="@*|node()" /> </xsl:template> <xsl:template match="@*

Categories : Xslt

Pass boolean value to a .Net Extension object
Define the variable as <xsl:variable name="PriorityCall" select="$PriorityFlag = 1 or $PriorityFlag = 2 or $PriorityFlag =3"/>. With your current setup your variable is (in XSLT 1.0) of type result tree fragment, a result tree fragment which contains a single, non empty text node which happens to contain the representation of a boolean value. But that will always be converted to true. If yo

Categories : Xslt

XSLT remove duplicate nodes based on element value
You can remove the duplicate with following XSLT: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()" /> </xsl:copy> </xsl:template>

Categories : Xslt

XPath/XSLT 1.0: Identifying element based on a sub element value
If you simply want to select based on a condition then the XPath expression object[attribute[@name='original_file_name' and substring(., string-length() - 3) = '.prt']] in your copy-of should suffice. With your edited sample I think you simply want <xsl:template match="/object"> <xsl:variable name="fileNames" select="object/attribute[@name='original_file_name']"/>

Categories : Xslt

How to generate a blank table cell?
Your have <xsl:when test="*"> ... is that node empty? If that is your outside test and passes, but the other IFs (you do not show) do not pass their test, your template yields nothing. Breaking this down with comments: <xsl:when test="*"> <xsl:if test="....."> <!-- If this does not pass, you get nothing --> <xsl:if test=".......">

Categories : Xslt

How to retain space in XSL
Will be better if you insert space in stylesheet <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:strip-space elements="author"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template

Categories : Xslt

Suppress default attributes when using xsl:copy-of
You do not have the ability to exclude attributes or nodes when using xsl:copy-of. It performs a deep copy of the selected node. Since you are already using the identity transformation with an empty template to suppress the @shape attribute and already have an empty template matching //div[@class='table']//p[@class='table-caption'], the easiest thing to do would be to change the <xsl:copy-of&g

Categories : Xslt

XSL-FO make text different color in single element
Here's an example of how you could use XSLT 2.0 (xsl:analyze-string) to add color. It could use some tweaking, but illustrates what I was thinking... XML Input <verbatimText>&lt;para>&lt;quantity> &lt;quantityGroup quantityUnitOfMeasure="ft.lbf">&lt;quantityValue>10&lt;/quantityValue> &lt;quantityTolerance quantityToleranceType="plusorminus" quantity

Categories : Xslt

Increment Letter's in XSL 1.0
To translate a string like "AA" to its numerical value, you can use the following template: <xsl:template name="string-to-num"> <xsl:param name="string"/> <xsl:param name="alpha" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> <xsl:param name="magnitude" select="1"/> <xsl:param name="carryover" select="0"/> <xsl:param name="bit" select="substring($s

Categories : Xslt

XSLT for selecting specific elements and attributes and outputing to csv
First thing: if you want your output to be CSV, then set your output method to "text", and do not copy elements of the source XML. Here's something you could use as your starting point: XSLT 1.0 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" encoding="UTF-8"/> <xsl:template match="/"> <xsl:for-each select="pdm

Categories : Xslt

remove child node namespace and copy another node into a variable
Try; <xsl:template match="/"> <xsl:variable name="SOAPHeader" select="/soap:Envelope/soap:Header/node()" /> <xsl:text>MessageHeader INFO:</xsl:text> <xsl:copy-of select="$SOAPHeader"/> </xsl:template> Note: <xsl:text> cannot contain child elements; your version has conflicting templates for soap:Envelope.

Categories : Xslt

Removing superfluous complex types in XML Schema using XSLT
I'm trying (but not getting very far...) to write an XSLT transform to: Replace the type of each element with the corresponding complex type's base type. E.g. the type of ElementName1 above would become ActualType1. Remove the entire complexType from the output. These two could be achieved by: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transf

Categories : Xslt

Select template based on attribute-defined order
Have you tried this? <xsl:template match="section[@visible='1']"> <dl> <dt><xsl:call-template name="content"/></dt> <xsl:apply-templates select="(page|file|section)[@visible='1']" mode="m"> <xsl:sort select="@pos"/> </xsl:apply-templates> </dl> </xsl:template> <xsl:template match="*" mode="m"

Categories : Xslt

xslt analyze string not allowing "value-of" selection
You need to store the context node outside of the analyze-string with <xsl:variable name="item" select="."/> then inside of the analyze-string you can use <title><xsl:value-of select="$item/title"/></title> <questionTitle><xsl:value-of select="$item/questionTitle"/></questionTitle>

Categories : Xslt

XSLT: foreach with a nested IF clause, how to get "first TRUE result"?
It is quite tough to find an answer without an input XML. You can use the following code instead of your for-each block: <xsl:for-each select="../partite/risultatopartita"> <xsl:if test="esperto = 'F'"> <tr> <xsl:if test="not(preceding-sibling::risultatopartita/esperto='F')"> <td rowspan="4" class='centra'>Favorite</td> </xsl:

Categories : Xslt

How to find all possible entities
Well in the XSLT/XPath data model there are only text nodes with Unicode characters, using XSLT/XPath there is no way to know or find out whether the lexical markup of the document that was parsed into a tree contained an Unicode letter literally or as a character reference or as an entity reference. So XSLT is not the right tool for that, unless you use some preprocessor like http://andrewjwelch.

Categories : Xslt

Remove an element based on its ancestor presence in first child of its ancestor
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <!-- The identity transform. --> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <!-- Match mstyle and output

Categories : Xslt




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.