Search Results

Search found 933 results on 38 pages for 'xslt 1 0'.

Page 1/38 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Why do XSLT editors insert tab or space characters into XSLT to format it?

    - by pgfearo
    All XSLT editors I've tried till now add tab or space characters to the XSLT to indent it for formatting. This is done even in places within the XSLT where these characters are significant to the XSLT processor. XSLT modified for formatting in this way can produce output very different to that of the original XSLT if it had no formatting. To prevent this, xsl:text elements or other XSLT must be added to a sequence constructor to help separate formatting from content, this additional XSLT impacts on maintainability. Formatting characters also adversely impact on general usability of the tool in a number of ways (this is why word-processors don't use them I guess) and add to the size of the file. As part of a larger project I've had to develop a light-weight XSLT editor, it's designed to format XSLT properly, but without tab or space characters, just a dynamic left-margin for each new line. The XSLT therefore doesn't need additional elements to separate formatting tab or space characters from content. The problem with this is that if XSLT from this editor is opened in other XSLT editors, characters will be added for formatting reasons and the XSLT may therefore no longer behave as intended. Why then do existing XSLT editors use tabs or spaces for formatting in the first place? I feel there must be valid reasons, perhaps historical, perhaps practical. An answer will help me understand whether I need to put compatibility options in place in my XSLT editor somehow, whether I should simply revert to using tabs or spaces for both XSLT content and formatting (though this seems like a backwards step to me), or even whether enough XSLT users might be able to persuade their tools vendors to include alternative formatting methods to tabs or spaces. Note: I provided an XSLT sample demonstrating formatting differences in this answer to the question: Tabs versus spaces—what is the proper indentation character for everything, in every situation, ever?

    Read the article

  • XSLT and possible alternatives [on hold]

    - by wirrbel
    I had a look at XSLT for transforming one XML file into another one (HTML, etc.). Now while I see that there are benefits to XSLT (being a standardized and used tool) I am reluctant for a couple of reasons XSLT processors seem to be quite huge / resource hungry XML is a bad notation for programming and thats what XSLT is all about. It do not want to troll XSLT here though I just want to point out what I dislike about it to give you an idea of what I would expect from an alternative. Having some Lisp background I wonder whether there are better ways for tree-structure transformations based upon some lisp. I have seen references to DSSSL, sadly most links about DSSSL are dead so its already challenging to see some code that illustrates it. Is DSSSL still in use? I remember that I had installed openjade once when checking out docbook stuff. Jeff Atwood's blog post seems to hint upon using Ruby instead of XSLT. Are there any sane ways to do XML transformations similar to XSLT in a non-xml programming language? I would be open for input on Useful libraries for scripting languages that facilitate XML transformations especially (but not exclusively) lisp-like transformation languages, or Ruby, etc. A few things I found so far: A couple of places on the web have pointed out Linq as a possible alternative. Quite generally I any kind of classifications, also from those who have had the best XSLT experience. For scheme http://cs.brown.edu/~sk/Publications/Papers/Published/kk-sxslt/ and http://www.okmij.org/ftp/Scheme/xml.html

    Read the article

  • How to implement multi-source XSLT mapping in 11g BPEL

    - by [email protected]
    In SOA 11g, you can create a XSLT mapper that uses multiple sources as the input. To implement a multi-source mapper, just follow the instructions below, Drag and drop a Transform Activity to a BPEL process Double-click on the Transform Activity, the Transform dialog window appears. Add source variables by clicking the Add icon and selecting the variable and part of the variable as needed. You can select multiple input variables. The first variable represents the main XML input to the XSL mapping, while additional variables that are added here are defined in the XSL mapping as input parameters. Select the target variable and its part if available. Specify the mapper file name, the default file name is xsl/Transformation_%SEQ%.xsl, where %SEQ% represents the sequence number of the mapper. Click OK, the xls file will be opened in the graphical mode. You can map the sources to the target as usual. Open the mapper source code, you will notice the variable representing the additional source payload, is defined as the input parameter in the map source spec and body<mapSources>    <source type="XSD">      <schema location="../xsd/po.xsd"/>      <rootElement name="PurchaseOrder" namespace="http://www.oracle.com/pcbpel/po"/>    </source>    <source type="XSD">      <schema location="../xsd/customer.xsd"/>      <rootElement name="Customer" namespace="http://www.oracle.com/pcbpel/Customer"/>      <param name="v_customer" />    </source>  </mapSources>...<xsl:param name="v_customer"/> Let's take a look at the BPEL source code used to execute xslt mapper. <assign name="Transform_1">            <bpelx:annotation>                <bpelx:pattern>transformation</bpelx:pattern>            </bpelx:annotation>            <copy>                <from expression="ora:doXSLTransformForDoc('xsl/Transformation_1.xsl',bpws:getVariableData('v_po'),'v_customer',bpws:getVariableData('v_customer'))"/>                <to variable="v_invoice"/>            </copy>        </assign> You will see BPEL uses ora:doXSLTransformForDoc XPath function to execute the XSLT mapper.This function returns the result of  XSLT transformation when the xslt template matching the document. The signature of this function is  ora:doXSLTransformForDoc(template,input, [paramQName, paramValue]*).Wheretemplate is the XSLT mapper nameinput is the string representation of xml input, paramQName is the parameter defined in the xslt mapper as the additional sourceparameterValue is the additional source payload. You can add more sources to the mapper at the later stage, but you have to modify the ora:doXSLTransformForDoc in the BPEL source code and make sure it passes correct parameter and its value pair that reflects the changes in the XSLT mapper.So the best practices are : create the variables before creating the mapping file, therefore you can add multiple sources when you define the transformation in the first place, which is more straightforward than adding them later on. Review ora:doXSLTransformForDoc code in the BPEL source and make sure it passes the correct parameters to the mapper.

    Read the article

  • Twitter Feeds in Umbraco using XSLT

    - by Vizioz Limited
    There are currently two packages tagged on the Umbraco forum that can be used to add a twitter feed to your website. I was playing around with "Twitter for Umbraco" by Warren Buckley and noticed a bug in the way it converted twitter @names to links, so I thought I would try and solve this using XSLT.It may also be useful for those of you using Darren Ferguson's "Feed Cache" package as the demo on Darren's site does not add links to the tweets.To use this XSLT you simple call the XSLT Template passing in your Twitter message:<xsl:call-template name="formaturl"> <xsl:with-param name="url" select="text"/></xsl:call-template>Then add the XSLT template to your XSLT macro (outside of the main template)<xsl:template name="formaturl"> <xsl:param name="twitterfeed"/> <xsl:variable name="transform-http" select="Exslt.ExsltRegularExpressions:replace($twitterfeed, '(http\:\/\/\S+)',ig,'<a href="$1">$1</a>')"/> <xsl:variable name="transform-https" select="Exslt.ExsltRegularExpressions:replace($transform-http, '(HTTps\:\/\/\S+)',ig,'<a href="$1">$1</a>')"/> <xsl:variable name="transform-AT" select="Exslt.ExsltRegularExpressions:replace($transform-https, '(^|\s)@(\w+)',ig,' <a href="http://www.twitter.com/$2">@$2</a>')"/> <xsl:variable name="transform-HASH" select="Exslt.ExsltRegularExpressions:replace($transform-AT, '(^|\s)#(\w+)',ig,' <a href="http://www.twitter.com/search?q=$2">#$2</a>')"/> <xsl:value-of select="$transform-HASH" disable-output-escaping="yes"/> </xsl:template>You should find that this now replaces all the @names, #names and URL's with links!

    Read the article

  • Displaying XML data using XSLT transformations in an ASP.Net site

    - by nikolaosk
    In this post, I will try to show you how to display xml data in asp.net website after making some xslt transformations. You will need to know a few things about XSLT. The best place to find out about XSLT is this link . I am going to explain a few things about XSLT elements and functions in this post, anyway. You will see the namespaces we are going to use and some of the main classes and methods.All these come with the FCL (Framework class library) and we just have to know what they do. We will...(read more)

    Read the article

  • Pattern Matching with XSLT

    - by genesis11
    I'm trying to match a pattern into a string in XSLT/XPath using the matches function, as follows: <xsl:when test="matches('awesome','awe')"> ... </xsl:when> However, in both Firefox 3.5.9 and IE8, it doesn't show up. IE8 tells me that "'matches' is not a valid XSLT or XPath function." Is this due to XSLT 2.0 not being supported, and is there a way around this?

    Read the article

  • XSLT: look for a word and it's context

    - by farhad
    Hello! I need to search a word and it's context into an xml. For example <line>hello world, my name is farhad and i'm having trouble with xslt</line> looking for 'and', context of 3 words: <line>hello world, my <span class="context">name is farhad <span class="word">and</span> i'm having</span> trouble with xslt</line> How can i do? I wrote some xslt to find the word, but i can't go back 3 words to set span. This is my xslt: <xsl:variable name="delimiters">[,.;!?\s"()]+</xsl:variable> <xsl:template match="/"> <xsl:apply-templates select="//line"/> </xsl:template> <xsl:template match="line"> <line> <xsl:for-each select="tokenize(.,'\s')"> <xsl:choose> <!-- se l'ultimo carattere è di punteggiatura, prendo la sottostringa senza la punteggiatura --> <xsl:when test="compare(replace(.,$delimiters,'$1'),'red') = 0"> <span class="word"> <xsl:value-of select="."/> </span> </xsl:when> <xsl:otherwise> <xsl:value-of select="."/> <xsl:choose> <xsl:when test="position()=last()"> <xsl:text></xsl:text> </xsl:when> <xsl:otherwise> <xsl:text> </xsl:text> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:for-each> </line><xsl:text> </xsl:text> </xsl:template> This is an example xml: http://pastebin.com/eAVM9CDQ . I have to search for context also on preceding tags, for example: <line>hello world,</line> <line>my name</line> <line>is farhad </line> <line>and i'm having</line> <line>trouble with xslt</line> so, looking for 'and', context of 3 words: <line>hello world,</line> <line>my <span class="context">name</line> <line>is farhad </line> <line><span class="word">and</span> i'm having</span></line> <line>trouble with xslt</line> with problems of overlapping, but now it's not a problem (i think i know how manage it). How can i search a word and its context? Thank you very much.

    Read the article

  • Flatten XML using XSLT but based on nesting level

    - by user2532750
    I'm new to XSLT and I'm trying to write some XSLT that will flatten any given XML such that a new line occurs whenever the nesting level changes. My input can be any XML document, with any number of nested levels so the structure isn't known to the XSLT. Due to the tools available to me, my solution has to use XSLT version 1.0. For example. <?xml version="1.0"?> <ROWSET> <ROW> <CUSTOMER_ID>0</CUSTOMER_ID> <NAME>Default Company</NAME> <BONUSES> <BONUSES_ROW> <BONUS_ID>21</BONUS_ID> <DESCRIPTION>Performance Bonus</DESCRIPTION> </BONUSES_ROW> <BONUSES_ROW> <BONUS_ID>26</BONUS_ID> <DESCRIPTION>Special Bonus</DESCRIPTION> </BONUSES_ROW> </BONUSES> </ROW> <ROW> <CUSTOMER_ID>1</CUSTOMER_ID> <NAME>Dealer 1</NAME> <BONUSES> <BONUSES_ROW> <BONUS_ID>27</BONUS_ID> <DESCRIPTION>June Bonus</DESCRIPTION> <BONUS_VALUES> <BONUS_VALUES_ROW> <VALUE>10</VALUE> <PERCENT>N</PERCENT> </BONUS_VALUES_ROW> <BONUS_VALUES_ROW> <VALUE>11</VALUE> <PERCENT>Y</PERCENT> </BONUS_VALUES_ROW> </BONUS_VALUES> </BONUSES_ROW> </BONUSES> </ROW> <ROWSET> needs to becomes.... 0, Default Company 21, Performance Bonus 26, Special Bonus 1, Dealer 1 27, June Bonus 10, N 11, Y The XSLT I've written so far is... <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" encoding="iso-8859-1"/> <xsl:strip-space elements="*" /> <xsl:template match="/*/child::*"> <xsl:apply-templates select="*"/> </xsl:template> <xsl:template match="*"> <xsl:value-of select="text()" /> <xsl:if test="position()!= last()"><xsl:text>,</xsl:text></xsl:if> <xsl:if test="position()= last()"><xsl:text>&#xD;</xsl:text></xsl:if> <xsl:apply-templates select="./child::*"/> </xsl:template> </xsl:stylesheet> but my output just isn't correct, with gaps and unnecessary data. 0,Default Company, ,21,Performance Bonus 26,Special Bonus 1,Dealer 1, 27,June Bonus, ,10,N 11,Y It seems there needs to be a check as whether or not a node can contain text, but I'm stuck and could do with an XSLT expert's help.

    Read the article

  • C# and XSLT (using document() function in XSLT generates error)

    - by Simon
    I'd like to use embedded resources in my XSLT file, but while invoking 'document(...)' C# complains that "Error during loading document ..." I'd like to use defined resources in XSLT file and get them by this: "document('')//my:resources/"... How can i do that?? ex xsl: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="xslt-gruper-v1.2.xsl" exclude-result-prefixes="my"> tryb <xsl:variable name="res" select="document('')/*/my:resources/("/> How can i get access to such structure without exceptions in C#? I'll add that during static transform via ex. Opera everything works fine.

    Read the article

  • Removing elements using XSLT 1.0

    - by pmdarrow
    I'm attempting to remove Component elements from the XML below that have File children with the extension "config." I've managed to do this part, but I also need to remove the matching ComponentRef elements that have the same IDs as these Components. <Fragment> <DirectoryRef Id="MyWebsite"> <Component Id="Comp1"> <File Source="Web.config" /> </Component> <Component Id="Comp2"> <File Source="Default.aspx" /> </Component> </DirectoryRef> </Fragment> <Fragment> <ComponentGroup Id="MyWebsite"> <ComponentRef Id="Comp1" /> <ComponentRef Id="Comp2" /> </ComponentGroup> </Fragment> Based on other SO answers, I've come up with the following XSLT to remove these Component elements: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" /> <xsl:template match="Component[File[substring(@Source, string-length(@Source)- string-length('config') + 1) = 'config']]" /> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> Unfortunately, this doesn't remove the matching ComponentRef elements. The XSLT will remove the component with the Id "Comp1" but not the ComponentRef with Id "Comp1". How do I achieve this using XSLT 1.0?

    Read the article

  • Removing related elements using XSLT 1.0

    - by pmdarrow
    I'm attempting to remove Component elements from the XML below that have File children with the extension "config." I've managed to do this part, but I also need to remove the matching ComponentRef elements that have the same "Id" values as these Components. <Fragment> <DirectoryRef Id="MyWebsite"> <Component Id="Comp1"> <File Source="Web.config" /> </Component> <Component Id="Comp2"> <File Source="Default.aspx" /> </Component> </DirectoryRef> </Fragment> <Fragment> <ComponentGroup Id="MyWebsite"> <ComponentRef Id="Comp1" /> <ComponentRef Id="Comp2" /> </ComponentGroup> </Fragment> Based on other SO answers, I've come up with the following XSLT to remove these Component elements: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" /> <xsl:template match="Component[File[substring(@Source, string-length(@Source)- string-length('config') + 1) = 'config']]" /> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> Unfortunately, this doesn't remove the matching ComponentRef elements (i.e. those that have the same "Id" values). The XSLT will remove the component with the Id "Comp1" but not the ComponentRef with Id "Comp1". How do I achieve this using XSLT 1.0?

    Read the article

  • XSLT Attribute not being added

    - by shaunhare.co.uk
    Trying to mark radio inputs as selected with XSLT 1.0 using the below xslt code but this does not produced the desired result desrired result <input type="radio" value="available" title="email" selected="selected" /> Actual output <input type="radio" value="available" title="email" selected /> Anyone any ideas why not please? XSLT <xsl:variable name="selected">selected</xsl:variable> <xsl:for-each select="item"> <tr> <td><xsl:value-of select="title" /></td> <td> <input type="radio" value="available" > <xsl:attribute name="name"> <xsl:value-of select="title" /> </xsl:attribute> <xsl:if test="category='available'"> <xsl:attribute name="selected"> <xsl:value-of select="$selected"/> </xsl:attribute> </xsl:if> </input> </td> <td> <input type="radio" value="unavailable" > <xsl:attribute name="name"> <xsl:value-of select="title" /> </xsl:attribute> <xsl:if test="category='unavailable'"> <xsl:attribute name="selected"> <xsl:value-of select="$selected"/> </xsl:attribute> </xsl:if> </input> </td> <td> <input type="radio" value="warning" > <xsl:if test="category='warning'"> <xsl:attribute name="selected"> <xsl:value-of select="$selected"/> </xsl:attribute> <xsl:attribute name="name"> <xsl:value-of select="title" /> </xsl:attribute> </xsl:if> </input> </td> </tr> </xsl:for-each>

    Read the article

  • XSLT Transforming sequential XML to hierarchical XML

    - by Jean-Paul Smit
    I have a requirement to transform a sequential XML node list into a hierarchical, but I run into some XSLT specific knowledge gap. The input XML contains articles, colors and sizes. In the sample below 'Record1' is an article, 'Record2' represents a color and 'Record3' are the sizes. The number of colors and sizes (record2 and record3) elements can vary. <root> <Record1>...</Record1> <Record2>...</Record2> <Record3>...</Record3> <Record3>...</Record3> <Record2>...</Record2> <Record3>...</Record3> <Record3>...</Record3> <Record3>...</Record3> <Record3>...</Record3> <Record1>...</Record1> <Record2>...</Record2> <Record3>...</Record3> <Record3>...</Record3> <Record2>...</Record2> <Record3>...</Record3> <Record3>...</Record3> <Record3>...</Record3> <Record3>...</Record3> </root> All fields are on the same hierarchical level, but still I have to create this structure as output: <root> <article> -> Record1 <color> -> Record2 <size>...</size> -> Record3 <size>...</size> -> Record3 </color> <color> -> Record2 <size>...</size> -> Record3 <size>...</size> -> Record3 <size>...</size> -> Record3 <size>...</size> -> Record3 </color> </article> <article> -> Record1 <color> -> Record2 <size>...</size> -> Record3 <size>...</size> -> Record3 </color> <color> -> Record2 <size>...</size> -> Record3 <size>...</size> -> Record3 <size>...</size> -> Record3 <size>...</size> -> Record3 </color> </article> </root> I've tried to iterate the nodes sequentially but for example the 'article' (=record1) node tag needs to remain unclosed while 'color' (=record2) nodes are processed. The same counts for processing 'size' (=record3) having 'color' unclosed, but that is not allowed by XSLT. My next idea was to call a template for every article, color and size level, but I don't know how to select for example all 'record3' nodes between the current 'record2' and the next article represented by 'record1'. I've also got a limitation on the XSLT version because I need this transformation in BizTalk Server which only supports XSLT 1.0 Can someone push me in the right direction?

    Read the article

  • XSLT: opening but not closing tags

    - by farhad
    Is there a way to open a tag and not close it? For example: <xsl:for-each select="."> <span> </xsl:for-each> This piece of code is not valid because XSLT is not well formed, but is there a way to do a similar thing? Thank you

    Read the article

  • Renaming nodes and values with xslt

    - by T.K.
    Hello world, I'm new to xslt, and have a task that I'm not really sure where to go with. I want to rename nodes, but maintain the format all node declarations. In the actual context I'll be applying this to, I'll be doing a series of renames like this, but for the sake of brevity, the sample I've written up only involves renaming one node. I am using XSL 1.0. Input: <variables> <var> <RENAME> a </RENAME> </var> <var RENAME='b'/> <var> <DO_NOT_TOUCH> c </DO_NOT_TOUCH> </var> <var DO_NOT_TOUCH='d'/> </variables> Desired Output: <variables> <var> <DONE> a </DONE> </var> <var DONE='b'/> <var> <DO_NOT_TOUCH> c </DO_NOT_TOUCH> </var> <var DO_NOT_TOUCH='d'/> </variables> My xslt: <xsl:template match="RENAME"> <RENAMED> <xsl:apply-templates select="@*|node()"/> </RENAMED> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> Current Output <variables> <var> <RENAMED> a </RENAMED> </var> <var RENAME="b"> </var> <var> <DO_NOT_TOUCH> c </DO_NOT_TOUCH> </var> <var DO_NOT_TOUCH="d"> </var> </variables>

    Read the article

  • Using XSLT for messaging instead of marshalling/unmarshalling Java message objects

    - by Joost van Stuijvenberg
    So far I have been using either handmade or generated (e.g. JAXB) Java objects as 'carriers' for messages in message processing software such as protocol converters. This often leads to tedious programming, such as copying/converting data from one system's message object to an instance of another's system message object. And it sure brings in lots of Java code with getters and setters for each message attribute, validation code, etc. I was wondering whether it would be a good idea to convert one system's XML message into another system's format - or even convert requests into responses from the same system - using XSLT. This would mean I would no longer have to unmarshall XML streams to Java objects, copy/convert data using Java and marshall the resulting message object to another XML stream. Since each message may actually have a purpose I would 'link' the message (and the payload it contains in its properties or XML elements/attributes) to EXSLT functions. This would change my design approach from an imperative to a declarative style. Has anyone done this before and, if so, what are your experiences? Does the reduced amount of Java 'boiler plate' code weigh up to the increased complexity of (E)XSLT?

    Read the article

  • XSLT: How to escape square brackets in Urls

    - by ilariac
    I have a set of records from Solr where field[@name='url'] can have the following format: http://url/blabla/blabla.aspx?sv=[keyword%20keyword,%201] My understanding is that the square brackets denote an array syntax and I would like to use XSLT to remove the square brackets from all Urls. The reason for this is that I am using an Open URL resolver, which does not currently handle well those characters. The best option would be to strip the square brackets from all URLs before such resources are mediated by the Open URL resolver. There are cases where I have multiple occurrences of square brackets per Url. Can you please help me with this? Thanks for your help, I.

    Read the article

  • Grouping every 3 items in xslt 1.0

    - by Piotr Czapla
    I'm having troubles to figure out a way to group items xslt 1.0. I have a source xml similar to the one below: <client name="client A"> <project name = "project A1"/> <project name = "project A2"/> <project name = "project A3"/> <project name = "project A4"/> </client> <client name="client B"> <project name = "project B1"/> <project name = "project B2"/> </client> <client name="client C"> <project name = "project C1"/> <project name = "project C2"/> <project name = "project C3"/> </client> I'd like to select all projects, sort them and then group every 3 project in one boundle as in the example below: <boundle> <project name="project A1"> <project name="project A2"> <project name="project A3"> </boundle> <boundle> <project name="project A4"> <project name="project B1"> <project name="project B2"> </boundle> <boundle> <project name="project C1"> <project name="project C2"> <project name="project C3"> </boundle> Currently to do so I'm using to open a boundle tag and close it later. Can you think about any better solution?

    Read the article

  • More efficient approach to XSLT for-each

    - by Paul
    I have an XSLT which takes a . delimted string and splits it into two fields for a SQL statement: <xsl:for-each select="tokenize(Path,'\.')"> <xsl:choose> <xsl:when test="position() = 1 and position() = last()">SITE = '<xsl:value-of select="."/>' AND PATH = ''</xsl:when> <xsl:when test="position() = 1 and position() != last()">SITE = '<xsl:value-of select="."/>' </xsl:when> <xsl:when test="position() = 2 and position() = last()">AND PATH = '<xsl:value-of select="."/>' </xsl:when> <xsl:when test="position() = 2">AND PATH = '<xsl:value-of select="."/></xsl:when> <xsl:when test="position() > 2 and position() != last()">.<xsl:value-of select="."/></xsl:when> <xsl:when test="position() > 2 and position() = last()">.<xsl:value-of select="."/>' </xsl:when> <xsl:otherwise>zxyarglfaux</xsl:otherwise> </xsl:choose> </xsl:for-each> The results are as follows: INPUT: North OUTPUT: SITE = 'North' AND PATH = '' INPUT: North.A OUTPUT: SITE = 'North' AND PATH = 'A' INPUT: North.A.B OUTPUT: SITE = 'North' AND PATH = 'A.B' INPUT: North.A.B.C OUTPUT: SITE = 'North' AND PATH = 'A.B.C' This works, but is very lengthy. Can anyone see a more efficient approach? Thanks!

    Read the article

  • One to One XSLT map with namespace manipulations

    - by ohadinho
    I have the following xml: <ns0:Root xmlns:ns0="http://root" xmlns:nm="http://notroot"> <nm:MSH> <content>bla</content> </nm:MSH> <ns0:Second> <ns0:item>aaa</ns0:item> </ns0:Second> <ns0:Third> <ns0:itemb>vv</ns0:itemb> </ns0:Third> </ns0:Root> That is my expected result: <Root xmlns="http://root" xmlns:nm="http://notroot"> <nm:MSH> <content>bla</content> </nm:MSH> <Second> <item>aaa</item> </Second> <Third> <itemb>vv</itemb> </Third> </Root> I need to write an xslt 1.0 that perform that map. I really doesn't have a clue how to do it, thus it seems pretty simple. Can anyone please help ?

    Read the article

  • How to group and sum values in XSLT

    - by johkar
    For each "agency" node I need to find the "stmt" elements that have the same key1, key2, key3 values and output just one "stmt" node with the "comm" and "prem" values summed together. For any "stmt" elements within that "agency" that don't match any other "stmt" elements based on key1, key2 and key3 I need to output them as is. So after transformation the first "agency" node would only have two "stmt" nodes (one summed) and the second "agency" node would be passed as is because the keys don't match. XSLT 1.0 or 2.0 solutions are ok...though my stylesheet is currently 1.0. Note that the agency nodes could have any number of "stmt" elements that have matching keys which need to be grouped and summed and any number that don't. <statement> <agency> <stmt> <key1>1234</key1> <key2>ABC</key2> <key3>15.000</key3> <comm>75.00</comm> <prem>100.00</prem> </stmt> <stmt> <key1>1234</key1> <key2>ABC</key2> <key3>15.000</key3> <comm>25.00</comm> <prem>200.00</prem> </stmt> <stmt> <key1>1234</key1> <key2>ABC</key2> <key3>17.50</key3> <comm>25.00</comm> <prem>100.00</prem> </stmt> </agency> <agency> <stmt> <key1>5678</key1> <key2>DEF</key2> <key3>15.000</key3> <comm>10.00</comm> <prem>20.00</prem> </stmt> <stmt> <key1>5678</key1> <key2>DEF</key2> <key3>17.000</key3> <comm>15.00</comm> <prem>12.00</prem> </stmt> </agency>

    Read the article

  • XSLT 1.0 recursion

    - by DashaLuna
    I'm stuck with recursion, was wondering if anyone can help me out with it. I have <Receipts> and <Deposits> elements, that are not verbose, i.e. that a <Receipts> element doesn't have an attribute to show what <Deposit> it is towards. I need to figure out <Deposits> "still amount due" and when a last receipt towards it was paid if any. I'm trying to do it with the following code: The idea was to take 1st deposit and see if there are receipts. If the deposit isn't fully paid and there are more receipts - call that recorsive function with all the same params except now count in following receipt. If there aren't any more receipts or deposit is payed - process it correctly (add required attributes). Otherwise proceed with 2nd deposit. And so on. However, the XSLT crashes with error message that "a processor stack has overflowed - possible cause is infinite template recursion" I would really appreciate any help/teps... I'm not that great with recursion and can't understand why mine here doesn't work. Thanks! :) <!-- Accumulate all the deposits with @DueAmount attribute --> <xsl:variable name="depositsClassified"> <xsl:call-template name="classifyDeposits"> <!-- a node-list of all Deposits elements ordered by DueDate Acs --> <xsl:with-param name="depositsAll" select="$deposits"/> <xsl:with-param name="depositPrevAmount" select="'0'"/> <!-- a node-list of all Receipts elements ordered by ReceivedDate Acs --> <xsl:with-param name="receiptsAll" select="$receiptsAsc"/> <xsl:with-param name="receiptCount" select="'1'"/> </xsl:call-template> </xsl:variable> <xsl:template name="classifyDeposits"> <xsl:param name="depositsAll"/> <xsl:param name="depositPrevAmount" select="'0'"/> <xsl:param name="receiptsAll"/> <xsl:param name="receiptCount"/> <xsl:if test="$deposits"> <!-- Do required operations for the 1st deposit --> <xsl:variable name="depositFirst" select="$depositsAll[1]"/> <xsl:variable name="receiptSum"> <xsl:choose> <xsl:when test="$receiptsAll"> <xsl:value-of select="sum($receiptsAll[position() &lt;= $receiptCount]/@ActionAmount)"/> </xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="diff" select="$depositPrevAmount + $depositFirst/@DepositTotalAmount - $receiptSum"/> <xsl:choose> <xsl:when test="$diff &gt; 0 and $receiptCount &lt; $receiptsQuantityOf"> <xsl:call-template name="classifyDeposits"> <xsl:with-param name="depositsAll" select="$depositsAll"/> <xsl:with-param name="depositPrevAmount" select="$depositPrevAmount"/> <xsl:with-param name="receiptsAll" select="$receiptsAll"/> <xsl:with-param name="receiptCount" select="$receiptCount + 1"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <!-- Record changes to the deposit (@DueAmount and receipt ReceivedDate) --> <xsl:apply-templates select="$depositFirst" mode="defineDeposit"> <xsl:with-param name="diff" select="$diff"/> <xsl:with-param name="latestReceiptForDeposit" select="$receiptsAll[position() = $receiptCount]"/> </xsl:apply-templates> <!-- Recursive call to the next deposit --> <xsl:call-template name="classifyDeposits"> <xsl:with-param name="depositsAll" select="$depositsAll[position() &gt; 1]"/> <xsl:with-param name="depositPrevAmount" select="$depositPrevAmount + $depositFirst/@DepositTotalAmount"/> <xsl:with-param name="receiptsAll" select="$receiptsAll"/> <xsl:with-param name="receiptCount" select="'1'"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:if> </xsl:template> <!-- Determine deposit's status, due amount and payment received date if any --> <xsl:template match="Deposits" mode="defineDeposit"> <xsl:param name="diff"/> <xsl:param name="latestReceiptForDeposit"/> <xsl:choose> <xsl:when test="$diff &lt;= 0"> <xsl:apply-templates select="." mode="addAttrs"> <xsl:with-param name="status" select="'paid'"/> <xsl:with-param name="dueAmount" select="'0'"/> <xsl:with-param name="receipt" select="$latestReceiptForDeposit"/> </xsl:apply-templates> </xsl:when> <xsl:when test="$diff = ./@DepositTotalAmount"> <xsl:apply-templates select="." mode="addAttrs"> <xsl:with-param name="status" select="'due'"/> <xsl:with-param name="dueAmount" select="$diff"/> </xsl:apply-templates> </xsl:when> <xsl:when test="$diff &lt; ./@DepositTotalAmount"> <xsl:apply-templates select="." mode="addAttrs"> <xsl:with-param name="status" select="'outstanding'"/> <xsl:with-param name="dueAmount" select="$diff"/> <xsl:with-param name="receipt" select="$latestReceiptForDeposit"/> </xsl:apply-templates> </xsl:when> <xsl:otherwise/> </xsl:choose> </xsl:template> <xsl:template match="Deposits" mode="addAttrs"> <xsl:param name="status"/> <xsl:param name="dueAmount"/> <xsl:param name="receipt" select="''"/> <!-- Constract a new MultiDeposits element with required info --> <xsl:copy> <xsl:copy-of select="./@*"/> <xsl:attribute name="Status"><xsl:value-of select="$status"/></xsl:attribute> <xsl:attribute name="DueAmount"><xsl:value-of select="$dueAmount"/></xsl:attribute> <xsl:if test="$receipt"> <xsl:attribute name="latestReceiptDate"> <xsl:value-of select="$receipt/@ActionDate"/> </xsl:attribute> </xsl:if> <xsl:copy-of select="./*"/> </xsl:copy> </xsl:template>

    Read the article

  • XSLT 1.0 help with recursion logic

    - by DashaLuna
    Hello guys, I'm having troubles with the logic and would apprecite any help/tips. I have <Deposits> elements and <Receipts> elements. However there isn't any identification what receipt was paid toward what deposit. I am trying to update the <Deposits> elements with the following attributes: @DueAmont - the amount that is still due to pay @Status - whether it's paid, outstanding (partly paid) or due @ReceiptDate - the latest receipt's date that was paid towards this deposit Every deposit could be paid with one or more receipts. It also could happen, that 1 receipt could cover one or more deposits. For example. If there are 3 deposits: 500 100 450 That are paid with the following receipts: 200 100 250 I want to get the following info: Deposit 1 is fully paid (status=paid, dueAmount=0, receiptNum=3. Deposit 2 is partly paid (status=outstanding, dueAmount=50, receiptNum=3. Deposit 3 is not paid (status=due, dueAmount=450, receiptNum=NAN. I've added comments in the code explaining what I'm trying to do. I am staring at this code for the 3rd day now non stop - can't see what I'm doing wrong. Please could anyone help me with it? :) Thanks! Set up: $deposits - All the available deposits $receiptsAsc - All the available receipts sorted by their @ActionDate Code: <!-- Accumulate all the deposits with @Status, @DueAmount and @ReceiptDate attributes Provide all deposits, receipts and start with 1st receipt --> <xsl:variable name="depositsClassified"> <xsl:call-template name="classifyDeposits"> <xsl:with-param name="depositsAll" select="$deposits"/> <xsl:with-param name="receiptsAll" select="$receiptsAsc"/> <xsl:with-param name="receiptCount" select="'1'"/> </xsl:call-template> </xsl:variable> <!-- Recursive function to associate deposits' total amounts with overall receipts paid to determine whether a deposit is due, outstanding or paid. Also determine what's the due amount and latest receipt towards the deposit for each deposit --> <xsl:template name="classifyDeposits"> <xsl:param name="depositsAll"/> <xsl:param name="receiptsAll"/> <xsl:param name="receiptCount"/> <!-- If there are deposits to proceed --> <xsl:if test="$depositsAll"> <!-- Get the 1st deposit --> <xsl:variable name="deposit" select="$depositsAll[1]"/> <!-- Calculate the sum of all receipts up to and including currenly considered --> <xsl:variable name="receiptSum"> <xsl:choose> <xsl:when test="$receiptsAll"> <xsl:value-of select="sum($receiptsAll[position() &lt;= $receiptCount]/@ReceiptAmount)"/> </xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable> <!-- Difference between deposit amount and sum of the receipts calculated above --> <xsl:variable name="diff" select="$deposit/@DepositTotalAmount - $receiptSum"/> <xsl:choose> <!-- Deposit isn't paid fully and there are more receipts/payments exist. So consider the same deposit, but take next receipt into calculation as well --> <xsl:when test="($diff &gt; 0) and ($receiptCount &lt; count($receiptsAll))"> <xsl:call-template name="classifyDeposits"> <xsl:with-param name="depositsAll" select="$depositsAll"/> <xsl:with-param name="receiptsAll" select="$receiptsAll"/> <xsl:with-param name="receiptCount" select="$receiptCount + 1"/> </xsl:call-template> </xsl:when> <!-- Deposit is paid or we ran out of receipts --> <xsl:otherwise> <!-- process the deposit. Determine its status and then update corresponding attributes --> <xsl:apply-templates select="$deposit" mode="defineDeposit"> <xsl:with-param name="diff" select="$diff"/> <xsl:with-param name="receiptNum" select="$receiptCount"/> </xsl:apply-templates> <!-- Recursively call the template with the rest of deposits excluding the first. Before hand update the @ReceiptsAmount. For the receipts before current it is now 0, for the current is what left in the $diff, and simply copy over receipts after current one. --> <xsl:variable name="receiptsUpdatedRTF"> <xsl:for-each select="$receiptsAll"> <xsl:choose> <!-- these receipts was fully accounted for the current deposit. Make them 0 --> <xsl:when test="position() &lt; $receiptCount"> <xsl:copy> <xsl:copy-of select="./@*"/> <xsl:attribute name="ReceiptAmount">0</xsl:attribute> </xsl:copy> </xsl:when> <!-- this receipt was partly/fully(in case $diff=0) accounted for the current deposit. Make it whatever is in $diff --> <xsl:when test="position() = $receiptCount"> <xsl:copy> <xsl:copy-of select="./@*"/> <xsl:attribute name="ReceiptAmount"> <xsl:value-of select="format-number($diff, '#.00;#.00')"/> </xsl:attribute> </xsl:copy> </xsl:when> <!-- these receipts weren't yet considered - copy them over --> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:variable> <xsl:variable name="receiptsUpdated" select="msxsl:node-set($receiptsUpdatedRTF)/Receipts"/> <!-- Recursive call for the next deposit. Starting counting receipts from the current one. --> <xsl:call-template name="classifyDeposits"> <xsl:with-param name="depositsAll" select="$deposits[position() != 1]"/> <xsl:with-param name="receiptsAll" select="$receiptsUpdated"/> <xsl:with-param name="receiptCount" select="$receiptCount"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:if> </xsl:template> <!-- Determine deposit's status and due amount --> <xsl:template match="MultiDeposits" mode="defineDeposit"> <xsl:param name="diff"/> <xsl:param name="receiptNum"/> <xsl:choose> <xsl:when test="$diff &lt;= 0"> <xsl:apply-templates select="." mode="addAttrs"> <xsl:with-param name="status" select="'paid'"/> <xsl:with-param name="dueAmount" select="'0'"/> <xsl:with-param name="receiptNum" select="$receiptNum"/> </xsl:apply-templates> </xsl:when> <xsl:when test="$diff = ./@DepositTotalAmount"> <xsl:apply-templates select="." mode="addAttrs"> <xsl:with-param name="status" select="'due'"/> <xsl:with-param name="dueAmount" select="$diff"/> </xsl:apply-templates> </xsl:when> <xsl:when test="$diff &lt; ./@DepositTotalAmount"> <xsl:apply-templates select="." mode="addAttrs"> <xsl:with-param name="status" select="'outstanding'"/> <xsl:with-param name="dueAmount" select="$diff"/> <xsl:with-param name="receiptNum" select="$receiptNum"/> </xsl:apply-templates> </xsl:when> <xsl:otherwise/> </xsl:choose> </xsl:template> <!-- Add new attributes (@Status, @DueAmount and @ReceiptDate) to the deposit element --> <xsl:template match="MultiDeposits" mode="addAttrs"> <xsl:param name="status"/> <xsl:param name="dueAmount"/> <xsl:param name="receiptNum" select="''"/> <xsl:copy> <xsl:copy-of select="./@*"/> <xsl:attribute name="Status"><xsl:value-of select="$status"/></xsl:attribute> <xsl:attribute name="DueAmount"><xsl:value-of select="$dueAmount"/></xsl:attribute> <xsl:if test="$receiptNum != ''"> <xsl:attribute name="ReceiptDate"> <xsl:value-of select="$receiptsAsc[position() = $receiptNum]/@ActionDate"/> </xsl:attribute> </xsl:if> <xsl:copy-of select="./*"/> </xsl:copy> </xsl:template>

    Read the article

  • XSLT 1.0 count element with the same value in an attribute, and show it

    - by Erick
    I have a variable containing: <col p1="Newman" p2="Paul"/> ... <col p1="Newman" p2="Paolo"/> <col p1="Newman" p2="Paul"/> i wold in output a table with in the first column the value of p2 and in the second the number of time it appear. For each value of p2 should i have only a row. <table> <tr><td>p2</td><td>num</td></tr> <tr><td>Pault</td><td>2</td> ... <tr><td>Paolo</td><td>1</td> </table>

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >