Search Results

Search found 837 results on 34 pages for 'xsl'.

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

  • How do I fix the issue with tables in xsl-fo, please help...

    - by atrueguy
    <?xml version="1.0" encoding="ISO-8859-1"?> <?xml:stylesheet type="text/xsl" href="currency.xslt"?> <currencylist> <title>Currencies By Country</title> <countries> <country>Australia</country> <currency>Australian Dollar</currency> </countries> <countries> <country>Austria</country> <currency>Schilling</currency> </countries> <countries> <country>Belgium</country> <currency>Belgium Franc</currency> </countries> <countries> <country>Canada</country> <currency>Canadian Dollar</currency> </countries> <countries> <country>England</country> <currency>Pound</currency> </countries> <countries> <country>Fiji</country> <currency>Fijian Dollar</currency> </countries> <countries> <country>France</country> <currency>Franc</currency> </countries> <countries> <country>Germany</country> <currency>DMark</currency> </countries> <countries> <country>Hong Kong</country> <currency>Hong Kong Dollar</currency> </countries> <countries> <country>Italy</country> <currency>Lira</currency> </countries> <countries> <country>Japan</country> <currency>Yen</currency> </countries> <countries> <country>Netherlands</country> <currency>Guilder</currency> </countries> <countries> <country>Switzerland</country> <currency>SFranc</currency> </countries> <countries> <country>USA</country> <currency>Dollar</currency> </countries> </currencylist> This is my exact xml code. I have written a xsl-fo for this xml file and I am failing to produce the output in a table. please check and help me in this. ASAP. <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master master-name="Letter" page-height="11in" page-width="8.5in"> <fo:region-body region-name="only_region" margin="1in" background-color="#CCCCCC"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="Letter"> <fo:flow flow-name="only_region"> <fo:block text-align="left"><xsl:call-template name="show_title"/></fo:block> <fo:table-and-caption> <fo:table> <fo:table-column column-width="25mm"/> <fo:table-column column-width="25mm"/> <fo:table-column column-width="25mm"/> <fo:table-header> <fo:table-row> <fo:table-cell> <fo:block font-weight="bold">SI No</fo:block> </fo:table-cell> <fo:table-cell> <fo:block font-weight="bold">Country</fo:block> </fo:table-cell> <fo:table-cell> <fo:block font-weight="bold">Currency</fo:block> </fo:table-cell> </fo:table-row> </fo:table-header> <fo:table-body> <fo:table-row> <fo:table-cell> <fo:block><xsl:call-template name="select_position"/></fo:block> </fo:table-cell> <fo:table-cell> <fo:block><xsl:call-template name="select_country"/></fo:block> </fo:table-cell> <fo:table-cell> <fo:block><xsl:call-template name="select_currency"/></fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:table-and-caption> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> <xsl:template name="show_title" match="currencylist"> <h2><xsl:value-of select="currencylist/title"/></h2> </xsl:template> <xsl:template name="select_position" match="currencylist"> <xsl:for-each select="currencylist/countries"> <xsl:value-of select="position()"/> </xsl:for-each> </xsl:template> <xsl:template name="select_country" match="currencylist"> <xsl:for-each select="currencylist/countries"> <xsl:value-of select="country"/> </xsl:for-each> </xsl:template> <xsl:template name="select_currency" match="currencylist"> <xsl:for-each select="currencylist/countries"> <xsl:value-of select="currency"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> Kindly help me out in this to produce a output in the table.

    Read the article

  • JSTL XML Transforms not working with nested XSL includes

    - by timxyz
    I have a bit of JSP that does this: <c:import url="/xsl/Transformer.xsl" var="xslt" /> <x:transform doc="${actionBean.dom}" xslt="${xslt}" xsltSystemId="/xsl/"> This transforms the XML exactly as expected so long as Transformer.xsl contains no <xsl:include> tags or so long as any documents it does include do not include anything. However, if I use an XSL which includes a document which in turn includes another document, I get the following error: ERROR: 'Invalid URI 'NestedInclude.xsl Could not resolve entity reference: "NestedInclude.xsl"'.' Note that the JSP is contained in the directory below the xsl documents. If all my XSLs and JSPs are in the same directory (and I remove the xsltSystemId attribute) then everything would work fine, but I don't really want to do this. Can anyone see anything I'm doing wrong, as it's a bit of a killer at the moment and the JSTL documentation is next to useless.

    Read the article

  • Display different xsl:attribute depending on the ending of a string

    - by Johann
    Dear All, I have the following xsl code in an xsl document <A target="_blank" style="text-decoration=none"> <xsl:attribute name="href">viewdoc.aspx?doc=<xsl:value-of select="URLFilePath"/>&amp;mode=inline</xsl:attribute> <xsl:attribute name="prefix"><xsl:value-of select="FileName"/>: </xsl:attribute> <IMG src="images/word_small.gif" border="0"/> </A> and in the code-behind I am doing this newItemNode = xmlDocument.CreateElement("URLFilePath") newItemNode.InnerText = correctedPath xmlItemNode.ParentNode.AppendChild(newItemNode) Now that works fine for word documents. However I need a way in code to check the extension of the file, and display the correct Image and xsl:attribute depending on the If statement. So the If statement will be like this:- If correctedPath.ToLower.Contains(".doc") Then //display the word icon and attributes Else //display the excel icon and attributes End If Can you please give me some tips and help on how I can achieve this? Thanks

    Read the article

  • Display different xsl:attribute depending on the code

    - by Johann
    Dear All, I have the following xsl code in an xsl document <A target="_blank" style="text-decoration=none"> <xsl:attribute name="href">viewdoc.aspx?doc=<xsl:value-of select="URLFilePath"/>&amp;mode=inline</xsl:attribute> <xsl:attribute name="prefix"><xsl:value-of select="FileName"/>: </xsl:attribute> <IMG src="images/word_small.gif" border="0"/> </A> and in the code-behind I am doing this newItemNode = xmlDocument.CreateElement("URLFilePath") newItemNode.InnerText = correctedPath xmlItemNode.ParentNode.AppendChild(newItemNode) Now that works fine for word documents. However I need a way in code to check the extension of the file, and display the correct Image and xsl:attribute depending on the If statement. So the If statement will be like this:- If correctedPath.ToLower.Contains(".doc") Then //display the word icon and attributes Else //display the excel icon and attributes End If Can you please give me some tips and help on how I can achieve this? Thanks

    Read the article

  • NSXMLDocument objectByApplyingXSLT with XSL Include

    - by Kristof
    I'm having some trouble with XSL-processing when there are stylesheets that include other stylesheets relatively. (the XML-files may be irrelevant but are included for completeness - code is at the bottom). Given the XML-file: <?xml version="1.0" ?> <famous-persons> <persons category="medicine"> <person> <firstname> Edward </firstname> <name> Jenner </name> </person> <person> <firstname> Gertrude </firstname> <name> Elion </name> </person> </persons> </famous-persons> and the XSL-file: <?xml version="1.0" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude" version="1.0"> <xsl:template match="/"> <html><head><title>Sorting example</title></head><body> <xsl:apply-templates select="famous-persons/persons"> <xsl:sort select="@category" /> </xsl:apply-templates> </body></html> </xsl:template> <xsl:include href="included.xsl" /> </xsl:stylesheet> referencing this stylesheet in included.xsl: <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude" version="1.0"> <xsl:template match="persons"> <h2><xsl:value-of select="@category" /></h2> <ul>Irrelevant</ul> </xsl:template> </xsl:stylesheet> how can I make it that the following code fragment: NSError *lError = nil; NSXMLDocument *lDocument = [ [ NSXMLDocument alloc ] initWithContentsOfURL: [ NSURL URLWithString: @"file:///pathto/data.xml" ] options: 0 error: &lError ]; NSXMLDocument *lResult = [ lDocument objectByApplyingXSLTAtURL: [ NSURL URLWithString: @"file:///pathto/style.xsl" ] arguments: nil error: nil ]; does not give me the error: I/O warning : failed to load external entity "included.xsl" compilation error: element include xsl:include : unable to load included.xsl I have been trying all sorts of options. Also loading XML documents with NSXMLDocumentXInclude beforehand does not seem to help. Is there any way to make the XSL processing so that a stylesheet can include another stylesheet in its local path?

    Read the article

  • Improving the performance of XSL

    - by Rachel
    I am using the below XSL 2.0 code to find the ids of the text nodes that contains the list of indices that i give as input. the code works perfectly but in terms for performance it is taking a long time for huge files. Even for huge files if the index values are small then the result is quick in few ms. I am using saxon9he Java processor to execute the XSL. <xsl:variable name="insert-data" as="element(data)*"> <xsl:for-each-group select="doc($insert-file)/insert-data/data" group-by="xsd:integer(@index)"> <xsl:sort select="current-grouping-key()"/> <data index="{current-grouping-key()}" text-id="{generate-id( $main-root/descendant::text()[ sum((preceding::text(), .)/string-length(.)) ge current-grouping-key() ][1] )}"> <xsl:copy-of select="current-group()/node()"/> </data> </xsl:for-each-group> </xsl:variable> In the above solution if the index value is too huge say 270962 then the time taken for the XSL to execute is 83427ms. In huge files if the index value is huge say 4605415, 4605431 it takes several minutes to execute. Seems the computation of the variable "insert-data" takes time though it is a global variable and computed only once. Should the XSL be addessed or the processor? How can i improve the performance of the XSL.

    Read the article

  • How to transform a cached XML via XSL?

    - by TruMan1
    I have a PHP script that caches a remote XML file. I want to XSL transform it before caching, but don't know how to do this: <?php // Set this to your link Id $linkId = "0oiy8Plr697u3puyJy9VTUWfPrCEvEgJR"; // Set this to a directory that has write permissions // for this script $cacheDir = "temp/"; $cachetime = 15 * 60; // 15 minutes // Do not change anything below this line // unless you are absolutely sure $feedUrl="http://mydomain.com/messageService/guestlinkservlet?glId="; $cachefile = $cacheDir .$linkId.".xml"; header('Content-type: text/xml'); // Send from the cache if $cachetime is not exceeded if (file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile))) { include($cachefile); echo "<!-- Cached ".date('jS F Y H:i', filemtime($cachefile))." -->\n"; exit; } $contents = file_get_contents($feedUrl . $linkId); // show the contents of the XML file echo $contents; // write it to the cache $fp = fopen($cachefile, 'w'); fwrite($fp, $contents); fclose($fp); ?> This is the XSL string I want to use to transform it: <xsl:template match="/"> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <xsl:apply-templates select="messageList" /> </Document> </kml> </xsl:template> <xsl:template match="messageList"> <name>My Generated KML</name> <xsl:apply-templates select="message" /> </xsl:template> <xsl:template match="message"> <Placemark> <name><xsl:value-of select="esnName" /></name> <Point> <coordinates> <xsl:value-of select="latitude" />,<xsl:value-of select="longitude" /> </coordinates> </Point> </Placemark> </xsl:template> I want to actually transform XML input and save/return a KML format. Can someone please help adjust this script? This was given to me and I am a little new to it.

    Read the article

  • parameterized doctype in xsl:stylesheet

    - by Flavius
    How could I inject a --stringparam (xsltproc) into the DOCTYPE of a XSL stylesheet? The --stringparam is specified from the command line. I have several books in docbook5 format I want to process with the same customization layer, each book having an unique identifier, here "demo", so I'm running something like xsltproc --stringparam course.name demo ... for each book. Obviously the parameter is not recognized as such, but as verbatim text, giving the error: warning: failed to load external entity "http://edu.yet-another-project.com/course/$(course.name)/entities.ent" Here it is how I've tried, which won't work: <?xml version='1.0'?> <!DOCTYPE stylesheet [ <!ENTITY % myent SYSTEM "http://edu.yet-another-project.com/course/$(course.name)/entities.ent"> %myent; ]> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <!-- the docbook template used --> <xsl:import href="http://docbook.org/ns/docbook/xhtml/chunk.xsl"/> <!-- processor parameters --> <xsl:param name="html.stylesheet">default.css</xsl:param> <xsl:param name="use.id.as.filename">1</xsl:param> <xsl:param name="chunker.output.encoding">UTF-8</xsl:param> <xsl:param name="chunker.output.indent">yes</xsl:param> <xsl:param name="navig.graphics">1</xsl:param> <xsl:param name="generate.revhistory.link">1</xsl:param> <xsl:param name="admon.graphics">1</xsl:param> <!-- here more stuff --> </xsl:stylesheet> Ideas?

    Read the article

  • Extract a subset of XML file using XSL

    - by Lucas -luky- Noleto
    I have this XML file: <Response> <errorCode>error Code</errorCode> <errorMessage>msg</errorMessage> <ResponseParameters> <className> <attribute1>a</attribute1> <attribute2>b</attribute2> </className> </ResponseParameters> </Response> And I want the output to be: <className> <attribute1>a</attribute1> <attribute2>b</attribute2> </className> My current XSL file is including also "ResponseParameters" tag, which I do not want. EDIT: note that the node className is dynamic. I do not know what will be this name at runtime. <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes" /> <xsl:template match="/"> <xsl:copy-of select="//ResponseParameters"> </xsl:copy-of> </xsl:template> </xsl:stylesheet>

    Read the article

  • xsl transform: problem with Ampersand URL parameters

    - by Rac123
    I'm having issues with transforming XSL with parameters in a URL. I'm at a point that I can't change the C# code anymore, only can make changes to xsl file. C# code: string xml = "<APPLDATA><APPID>1052391</APPID></APPLDATA>"; XmlDocument oXml = new XmlDocument(); oXml.LoadXml(xml); XslTransform oXslTransform = new XslTransform(); oXslTransform.Load(@"C:\Projects\Win\ConsoleApps\XslTransformTest\S15033.xsl"); StringWriter oOutput = new StringWriter(); oXslTransform.Transform(oXml, null, oOutput) XSL Code: <body> <xsl:variable name="app"> <xsl:value-of select="normalize-space(APPLDATA/APPID)" /> </xsl:variable> <div id="homeImage" > <xsl:attribute name="style"> background-image:url("https://server/image.gif?a=10&amp;Id='<xsl:value-of disable-output-escaping="yes" select="$app" />'") </xsl:attribute> </div> </body> </html> URL transformed: https://server/image.gif?a=10&Id='1052391' URL Expected: https://server/image.gif?a=10&Id='1052391' How do I fix this? The output (oOutput.ToString()) is being used in an email template so it's taking the URL transformed literally. When you click on this request (with the correct server name of course), the 403 (Access forbidden) error is being thrown.

    Read the article

  • XSLT - make xsl:analyze-string return string instead of sequence of strings?

    - by tohuwawohu
    Is it possible to make xsl:analyze-string return one string instead of a sequence of strings? Background: I'd like to use xsl:analyze-string in a xsl:function that should encapsulate the pattern matching. Ideally, the function should return an xs:string to be used as sort criteria in an xsl:sort element. At the moment, i have to apply string-join() on every result of the function call since xsl:analyze-string returns a sequence of strings, and xsl:sort doesn't accept such a sequence as sort criteria. See line 24 of the stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="www.my-personal-namespa.ce" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:output indent="yes" method="xml" /> <xsl:function name="my:sortierung" > <xsl:param name="inputstring" as="xs:string"/> <xsl:analyze-string select="$inputstring" regex="[0-9]+"> <xsl:matching-substring> <xsl:value-of select="format-number(number(.), '00000')" /> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="." /> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:function> <xsl:template match="/input"> <result> <xsl:apply-templates select="value" > <xsl:sort select="string-join((my:sortierung(.)), ' ')" /> </xsl:apply-templates> </result> </xsl:template> <xsl:template match="value"> <xsl:copy-of select="." /> </xsl:template> </xsl:stylesheet> with this input: <?xml version="1.0" encoding="UTF-8"?> <input> <value>A 1 b 120</value> <value>A 1 b 1</value> <value>A 1 b 2</value> <value>A 1 b 1a</value> </input> In my example, is there a way to modify the xsl:function to return a xs:string instead of a sequence?

    Read the article

  • XSLT big integer (int64) handling msxml

    - by Farid Z
    When trying to do math on an big integer (int64) large number in xslt template I get the wrong result since there is no native 64-bit integer support in xslt (xslt number is 64-bit double). I am using msxml 6.0 on Windows XP SP3. Are there any work around for this on Windows? <tables> <table> <table_schem>REPADMIN</table_schem> <table_name>TEST_DESCEND_IDENTITY_BIGINT</table_name> <column> <col_name>COL1</col_name> <identity> <col_min_val>9223372036854775805</col_min_val> <col_max_val>9223372036854775805</col_max_val> <autoincrementvalue>9223372036854775807</autoincrementvalue> <autoincrementstart>9223372036854775807</autoincrementstart> <autoincrementinc>-1</autoincrementinc> </identity> </column> </table> </tables> This test returns true due to overflow (I am assuming) but actually is false if I could tell the xslt processor somehow to use int64 rather than the default 64-bit double for the data since big integer is the actual data type for the numbers in the xml input. <xsl:when test="autoincrementvalue = (col_min_val + autoincrementinc)"> <xsl:value-of select="''"/> </xsl:when> here is the complete template <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <!--Reseed Derby identity column--> <xsl:output omit-xml-declaration='yes' method='text' /> <xsl:param name="stmtsep">;</xsl:param> <xsl:param name="schemprefix"></xsl:param> <xsl:template match="tables"> <xsl:variable name="identitycount" select="count(table/column/identity)"></xsl:variable> <xsl:for-each select="table/column/identity"> <xsl:variable name="table_schem" select="../../table_schem"></xsl:variable> <xsl:variable name="table_name" select="../../table_name"></xsl:variable> <xsl:variable name="tablespec"> <xsl:if test="$schemprefix"> <xsl:value-of select="$table_schem"/>.</xsl:if><xsl:value-of select="$table_name"/></xsl:variable> <xsl:variable name="col_name" select="../col_name"></xsl:variable> <xsl:variable name="newstart"> <xsl:choose> <xsl:when test="autoincrementinc > 0"> <xsl:choose> <xsl:when test="col_max_val = '' and autoincrementvalue = autoincrementstart"> <xsl:value-of select="''"/> </xsl:when> <xsl:when test="col_max_val = ''"> <xsl:value-of select="autoincrementstart"/> </xsl:when> <xsl:when test="autoincrementvalue = (col_max_val + autoincrementinc)"> <xsl:value-of select="''"/> </xsl:when> <xsl:when test="(col_max_val + autoincrementinc) &lt; autoincrementstart"> <xsl:value-of select="autoincrementstart"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="col_max_val + autoincrementinc"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="autoincrementinc &lt; 0"> <xsl:choose> <xsl:when test="col_min_val = '' and autoincrementvalue = autoincrementstart"> <xsl:value-of select="''"/> </xsl:when> <xsl:when test="col_min_val = ''"> <xsl:value-of select="autoincrementstart"/> </xsl:when> <xsl:when test="autoincrementvalue = (col_min_val + autoincrementinc)"> <xsl:value-of select="''"/> </xsl:when> <xsl:when test="(col_min_val + autoincrementinc) > autoincrementstart"> <xsl:value-of select="autoincrementstart"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="col_min_val + autoincrementinc"/> </xsl:otherwise> </xsl:choose> </xsl:when> </xsl:choose> </xsl:variable> <xsl:if test="not(position()=1)"><xsl:text> </xsl:text></xsl:if> <xsl:choose> <!--restart with ddl changes both the next identity value AUTOINCREMENTVALUE and the identity start number AUTOINCREMENTSTART eventhough in this casewe only want to change only the next identity number--> <xsl:when test="$newstart != '' and $newstart != autoincrementvalue">alter table <xsl:value-of select="$tablespec"/> alter column <xsl:value-of select="$col_name"/> restart with <xsl:value-of select="$newstart"/><xsl:if test="$identitycount>1">;</xsl:if></xsl:when> <xsl:otherwise>-- reseed <xsl:value-of select="$tablespec"/> is not necessary</xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> </xsl:stylesheet>

    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 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 Escape Character not working

    - by liveek
    I am trying to use escape charaters in my text output, as i would like too surround the output in emailData tags. I am using <xsl:text>&#60;emailData&#62;</xsl:text> In the XSLT to esnure that this works however because i am using a tool called Cast Iron for some reason it is not converting the &#60; into < and just spits out &lt;emailData> You can see am image of it HERE that illustrates the output i am getting. My source code is this. How else could i wrap this in emailData tags? <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="header"> <xsl:text>&#60;emailData&#62;</xsl:text> <xsl:text>&#10;</xsl:text> <xsl:text>From: </xsl:text> <xsl:value-of select="from/text()"/> <xsl:text>&#10;</xsl:text> <xsl:text>To: </xsl:text> <xsl:value-of select="to/text()"/> <xsl:text>&#10;</xsl:text> <xsl:text>Subject: </xsl:text> <xsl:value-of select="subject/text()"/> <xsl:text>&#10;</xsl:text> <xsl:text>Content-Type: </xsl:text> <xsl:value-of select="contentType/text()"/> <xsl:text>&#10;</xsl:text> <xsl:text> boundary="</xsl:text> <xsl:value-of select="boundary/text()"/> <xsl:text>"</xsl:text> <xsl:text>&#10;</xsl:text> <xsl:text>MIME-Version: </xsl:text> <xsl:value-of select="mimeVersion/text()"/> </xsl:template> <xsl:template match="email"> <xsl:text>&#10;&#10;</xsl:text> <xsl:text>--</xsl:text> <xsl:value-of select="../header/boundary/text()"/> <xsl:text>&#10;</xsl:text> <xsl:text>Content-Type: </xsl:text> <xsl:value-of select="contentTypeBody/text()"/> <xsl:text> charset="us-ascii"</xsl:text> <xsl:text>&#10;</xsl:text> <xsl:text>Content-Transfer-Encoding: </xsl:text> <xsl:value-of select="contentTransfer/text()"/> <xsl:text>&#10;&#10;</xsl:text> <xsl:value-of select="body/text()"/> </xsl:template> <xsl:template match="Attachment"> <xsl:for-each select="Attachments"> <xsl:text>&#0010;&#0010;</xsl:text> <xsl:value-of select="../../header/boundary/text()"/> <xsl:text>&#10;</xsl:text> <xsl:text>Content-Type: </xsl:text> <xsl:value-of select="attachmentContentType/text()"/> <xsl:text> name="</xsl:text> <xsl:value-of select="attachmentDescription/text()"/> <xsl:text>"</xsl:text> <xsl:text>&#10;</xsl:text> <xsl:text>Content-Description: </xsl:text> <xsl:value-of select="attachmentDescription/text()"/> <xsl:text>&#10;</xsl:text> <xsl:text>Content-Disposition: attachment; filename="</xsl:text> <xsl:value-of select="atachementDisposition/text()"/> <xsl:text>"</xsl:text> <xsl:text>&#10;</xsl:text> <xsl:text>Content-Transfer-Encoding: </xsl:text> <xsl:value-of select="attachmentContentTransfer/text()"/> <xsl:text>&#10;&#10;</xsl:text> <xsl:value-of select="attachementBody/text()"/> <xsl:text>&#10;</xsl:text> <xsl:text>&#60;/emailData&#62;</xsl:text> </xsl:for-each> </xsl:template> <xsl:template match="text()"/> </xsl:stylesheet>

    Read the article

  • XSLT apply templates in different order of xml reading.

    - by David
    I am new to this, so please bear with me... If we have the following xml fragment: <docXML> <PARRAFO orden='1' tipo='parrafo'> <dato> <etiqueta>Título</etiqueta> <tipo>TextBox</tipo> <valor>¿Cuándo solicitar el consejo genético?</valor> <longitud>1500</longitud> <comentario></comentario> <enlace></enlace> <target_enlace>I</target_enlace> </dato> <dato> <etiqueta>Texto</etiqueta> <tipo>Resumen</tipo> <valor>Resumen text</valor> <longitud>8000</longitud> <comentario></comentario> <enlace></enlace> <target_enlace></target_enlace> </dato> <dato> <etiqueta>Imagen</etiqueta> <tipo>TextBox</tipo> <valor>http://url/Imagenes/7D2BE6480CF4486CA288A75932606181.jpg</valor> <longitud>1500</longitud> <comentario></comentario> <enlace></enlace> <target_enlace>I</target_enlace> </dato> </PARRAFO> <PARRAFO orden='1' tipo='parrafo'> <dato> <etiqueta>Título</etiqueta> <tipo>TextBox</tipo> <valor>TextBox text</valor> <longitud>1500</longitud> <comentario></comentario> <enlace></enlace> <target_enlace>I</target_enlace> </dato> <dato> <etiqueta>Texto</etiqueta> <tipo>Resumen</tipo> <valor>Resumen text</valor> <longitud>8000</longitud> <comentario></comentario> <enlace></enlace> <target_enlace></target_enlace> </dato> </PARRAFO> </docXML> .. I am going to apply templates to each section depending on the value of the label "etiqueta" per node "dato" in "PARRAFO" by using the following XSLT: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xsl" exclude-result-prefixes="msxsl"> <xsl:output method="html" encoding="iso-8859-1"/> <xsl:template match="/"> <xsl:variable name="xml-doc-parrafo" select="documentoXML/PARRAFO"/> <!-- PARRAFOS --> <xsl:choose> <xsl:when test="count($xml-doc-parrafo)>0"> <div class="seccion_1"> <xsl:for-each select="$xml-doc-parrafo"> <xsl:choose> <xsl:when test="self::node()[@tipo = 'parrafo']"> <div class="parrafo"> <xsl:for-each select="self::node()[@tipo = 'parrafo']/dato"> <xsl:variable name="dato" select="self::node()[@tipo = 'parrafo']/dato"/> <xsl:variable name="nextdato" select="following::dato[1]/@etiqueta"/> <xsl:choose> <xsl:when test="etiqueta = 'Título'"> <xsl:call-template name="imprimeTituloParrafo"> <xsl:with-param name="etiqueta" select="etiqueta"></xsl:with-param> <xsl:with-param name="valor" select="valor"></xsl:with-param> <xsl:with-param name="longitud" select="longitud"></xsl:with-param> <xsl:with-param name="comentario" select="comentario"></xsl:with-param> <xsl:with-param name="enlace" select="enlace"></xsl:with-param> <xsl:with-param name="target_enlace" select="target_enlace"></xsl:with-param> </xsl:call-template> </xsl:when> <xsl:when test="etiqueta = 'Subtitulo'"> <xsl:call-template name="imprimeSubtituloParrafo"> <xsl:with-param name="etiqueta" select="etiqueta"></xsl:with-param> <xsl:with-param name="valor" select="valor"></xsl:with-param> <xsl:with-param name="longitud" select="longitud"></xsl:with-param> <xsl:with-param name="comentario" select="comentario"></xsl:with-param> <xsl:with-param name="enlace" select="enlace"></xsl:with-param> <xsl:with-param name="target_enlace" select="target_enlace"></xsl:with-param> </xsl:call-template> </xsl:when> <xsl:when test="etiqueta = 'Imagen'"> <xsl:call-template name="imprimeImagenParrafo"> <xsl:with-param name="etiqueta" select="etiqueta"></xsl:with-param> <xsl:with-param name="valor" select="valor"></xsl:with-param> <xsl:with-param name="longitud" select="longitud"></xsl:with-param> <xsl:with-param name="comentario" select="comentario"></xsl:with-param> <xsl:with-param name="enlace" select="enlace"></xsl:with-param> <xsl:with-param name="target_enlace" select="target_enlace"></xsl:with-param> </xsl:call-template> </xsl:when> <xsl:when test="etiqueta = 'Pie Imagen'"> <xsl:call-template name="imprimePieImagenParrafo"> <xsl:with-param name="etiqueta" select="etiqueta"></xsl:with-param> <xsl:with-param name="valor" select="valor"></xsl:with-param> <xsl:with-param name="longitud" select="longitud"></xsl:with-param> <xsl:with-param name="comentario" select="comentario"></xsl:with-param> <xsl:with-param name="enlace" select="enlace"></xsl:with-param> <xsl:with-param name="target_enlace" select="target_enlace"></xsl:with-param> </xsl:call-template> </xsl:when> <xsl:when test="etiqueta = 'Texto'"> <xsl:call-template name="imprimeTextoParrafo"> <xsl:with-param name="etiqueta" select="etiqueta"></xsl:with-param> <xsl:with-param name="valor" select="valor"></xsl:with-param> <xsl:with-param name="longitud" select="longitud"></xsl:with-param> <xsl:with-param name="comentario" select="comentario"></xsl:with-param> <xsl:with-param name="enlace" select="enlace"></xsl:with-param> <xsl:with-param name="target_enlace" select="target_enlace"></xsl:with-param> </xsl:call-template> </xsl:when> <xsl:when test="etiqueta = 'Pie Parrafo'"> <xsl:call-template name="imprimePieParrafo"> <xsl:with-param name="etiqueta" select="etiqueta"></xsl:with-param> <xsl:with-param name="valor" select="valor"></xsl:with-param> <xsl:with-param name="longitud" select="longitud"></xsl:with-param> <xsl:with-param name="comentario" select="comentario"></xsl:with-param> <xsl:with-param name="enlace" select="enlace"></xsl:with-param> <xsl:with-param name="target_enlace" select="target_enlace"></xsl:with-param> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:for-each> </div> </xsl:when> </xsl:choose> </xsl:for-each> </div> </xsl:when> <!-- si no hay resultados --> <xsl:otherwise> <br></br> <p style="text-align:center;">El documento no contiene datos.</p> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="imprimeTituloParrafo"> <xsl:param name="etiqueta"></xsl:param> <xsl:param name="valor"></xsl:param> <xsl:param name="longitud"></xsl:param> <xsl:param name="enlace"></xsl:param> <xsl:param name="target_enlace"></xsl:param> <h2 class="titulo"> <xsl:choose> <xsl:when test="string-length($enlace) > 0"> <xsl:call-template name="imprimeEnlace"> <xsl:with-param name="valor" select="valor"></xsl:with-param> <xsl:with-param name="longitud" select="longitud"></xsl:with-param> <xsl:with-param name="comentario" select="comentario"></xsl:with-param> <xsl:with-param name="enlace" select="enlace"></xsl:with-param> <xsl:with-param name="target_enlace" select="target_enlace"></xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$valor"/> </xsl:otherwise> </xsl:choose> </h2> </xsl:template> <xsl:template name="imprimeSubtituloParrafo"> <xsl:param name="etiqueta"></xsl:param> <xsl:param name="valor"></xsl:param> <xsl:param name="longitud"></xsl:param> <xsl:param name="enlace"></xsl:param> <xsl:param name="target_enlace"></xsl:param> <h3 class="subtitulo"> <xsl:choose> <xsl:when test="string-length($enlace) > 0"> <xsl:call-template name="imprimeEnlace"> <xsl:with-param name="valor" select="valor"></xsl:with-param> <xsl:with-param name="longitud" select="longitud"></xsl:with-param> <xsl:with-param name="comentario" select="comentario"></xsl:with-param> <xsl:with-param name="enlace" select="enlace"></xsl:with-param> <xsl:with-param name="target_enlace" select="target_enlace"></xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$valor"/> </xsl:otherwise> </xsl:choose> </h3> </xsl:template> <xsl:template name="imprimeTextoParrafo"> <xsl:param name="etiqueta"></xsl:param> <xsl:param name="valor"></xsl:param> <xsl:param name="longitud"></xsl:param> <xsl:param name="enlace"></xsl:param> <xsl:param name="target_enlace"></xsl:param> <div class="texto"> <p class="texto"> <xsl:copy-of select="$valor/node()"/> </p> </div> </xsl:template> <xsl:template name="imprimeImagenParrafo"> <xsl:param name="etiqueta"></xsl:param> <xsl:param name="valor"></xsl:param> <xsl:param name="longitud"></xsl:param> <xsl:param name="comentario"></xsl:param> <xsl:param name="enlace"></xsl:param> <xsl:param name="target_enlace"></xsl:param> <xsl:choose> <xsl:when test="string-length($enlace) = 0"> <xsl:call-template name="imprimeImagen"> <xsl:with-param name="etiqueta" select="etiqueta"></xsl:with-param> <xsl:with-param name="valor" select="valor"></xsl:with-param> <xsl:with-param name="longitud" select="longitud"></xsl:with-param> <xsl:with-param name="comentario" select="comentario"></xsl:with-param> <xsl:with-param name="enlace" select="enlace"></xsl:with-param> <xsl:with-param name="target_enlace" select="target_enlace"></xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <a> <xsl:choose> <xsl:when test="$target_enlace/node() = 'E'"> <xsl:attribute name="target"> <xsl:text>_blank</xsl:text> </xsl:attribute> </xsl:when> <xsl:when test="$target_enlace/node() = 'I'"> <xsl:attribute name="target"> <xsl:text>_self</xsl:text> </xsl:attribute> </xsl:when> </xsl:choose> <xsl:attribute name="href"> <xsl:value-of select="$enlace"/> </xsl:attribute> <xsl:call-template name="imprimeImagen"> <xsl:with-param name="etiqueta" select="etiqueta"></xsl:with-param> <xsl:with-param name="valor" select="valor"></xsl:with-param> <xsl:with-param name="longitud" select="longitud"></xsl:with-param> <xsl:with-param name="comentario" select="comentario"></xsl:with-param> <xsl:with-param name="enlace" select="enlace"></xsl:with-param> <xsl:with-param name="target_enlace" select="target_enlace"></xsl:with-param> </xsl:call-template> </a> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="imprimeImagen"> <xsl:param name="etiqueta"></xsl:param> <xsl:param name="valor"></xsl:param> <xsl:param name="longitud"></xsl:param> <xsl:param name="comentario"></xsl:param> <xsl:param name="enlace"></xsl:param> <xsl:param name="target_enlace"></xsl:param> <div class="imagen_pie"> <img> <xsl:attribute name="src"> <xsl:value-of select="$valor"/> </xsl:attribute> <xsl:attribute name="alt"> <xsl:value-of select="$comentario"/> </xsl:attribute> </img> </div> </xsl:template> <xsl:template name="imprimeEnlace"> <xsl:param name="valor"></xsl:param> <xsl:param name="longitud"></xsl:param> <xsl:param name="comentario"></xsl:param> <xsl:param name="enlace"></xsl:param> <xsl:param name="target_enlace"></xsl:param> <a> <xsl:choose> <xsl:when test="$target_enlace/node() = 'E'"> <xsl:attribute name="target"> <xsl:text>_blank</xsl:text> </xsl:attribute> </xsl:when> <xsl:when test="$target_enlace/node() = 'I'"> </xsl:when> <xsl:when test="$target_enlace/node() = 'D'"> </xsl:when> </xsl:choose> <xsl:attribute name="href"> <xsl:value-of select="enlace"/> </xsl:attribute> <xsl:value-of select="$valor"/> </a> </xsl:template> .... </xsl:stylesheet> I need to first apply the template image (if exists in this "PARRAFO") "Imagen" just before the text "Texto" Now apply the template text first and then the image because it is before the text node before the image as shown in xml Thanks a lot!

    Read the article

  • How can i call an XSL template within a hyperlink in the XSL stylesheet

    - by AdRock
    I am making my own XSL stylesheet which will perform different views on the same XML document Because the XML document is so large, i would like some links at the top of the outputted page to call each template that will be used to display the data. At the moment I can create links that use anchors to a place in the document but it would be better if i just call each template as needed. How can i just call each template in a link? Would i have to use xlink? <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="folktask"> <html> <body> <a href="folk.xml#organisers">Show all the users</a> <a href="folk.xml#organisers">Show all the festival organisers</a> <xsl:call-template name="show_all_users" /> <xsl:call-template name="show_all_organisers" /> </body> </html> </xsl:template> </xsl:stylesheet>

    Read the article

  • Why don't copy this dokument attributes from the source xml file??

    - by siegfried storr
    Hi anyone, i'm working the first time with xslt and i really don't understand why this xsl don't copy attributes from the source xml. Perhaps someone can give me a hint?? <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:variable name="rpl" select="document('ParamInvoice.xml')"/> <xsl:template match="/"> <xsl:copy> <xsl:apply-templates select="* | @*"/> </xsl:copy> </xsl:template> <xsl:template match="*"> <xsl:variable name="vInvoiceElement" select="$rpl/StoraInvoice/*[name()=name(current())]"/> <xsl:copy> <xsl:if test="$vInvoiceElement/Attribute"> <xsl:call-template name="AttributeErzeugen"> <xsl:with-param name="pAttr" select="$vInvoiceElement/Attribute"/> </xsl:call-template> </xsl:if> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template name="AttributeErzeugen"> <xsl:param name="pAttr"/> <xsl:for-each select="$pAttr"> <xsl:attribute name="{@name}"><xsl:value-of select="."/></xsl:attribute> </xsl:for-each> </xsl:template> </xsl:stylesheet>

    Read the article

  • XSL(like) declarative language as MVC view over strongtyped model?

    - by Martin Kool
    As a huge XSL fan, I am very happy to use xsl as the view in our proprietary MVC framework on ASP.NET. Objects in the model are serialized under the hood using .NET's xml serializer, and we use quite atomic xsl templates to declare how each object or property should transform. For example: <xsl:template match="/Article"> <html> <body> <div class="article"> <xsl:apply-templates /> </div> </body> </html> </xsl:template> <xsl:template match="Article/Title"> <h1> <xsl:apply-templates /> </h1> </xsl:template> <xsl:template match="@*|text()"> <xsl:copy /> </xsl:template> This mechanism allows us to quickly override default matching templates, like having a template matching on the last item in a list, or the selected one, etc. Also, xsl extension objects in .NET allow us just the bit of extra grip that we need. Common shared templates can be split up and included. However Even though I can ignore the verbosity downside of xsl (because Visual Studio schema intellisense + snippets really is slick, praise to the VS-team), the downside of not having intellisense over strongtyped objects in the model is really something that's bugging me. I've seen ASP.NET MVC + user controls in action and really starting to love it, but I wonder; Is there a way of getting some sort of intellisense over XML that we're iterating over, or do you know of a language that offers the freedom and declarativeness of XSL but has the strongtype/intellisense benefits of say webforms/usercontrols/asp.net.mvc-view? (I probably know the answer: "no", and I'll find myself using Phil Haack's utterly cool mvc shizzle soon...)

    Read the article

  • Converting XML to RSS

    - by hkw
    I've got an xml feed that will be published in one location of our website, and would like to repurpose that for an RSS feed. A few different pages on the website will also be referencing the same xml - all of those transformations are set up and working. The base xml file (XMLTEST.xml) is using this structure: <POST> <item> <POST_ID>80000852</POST_ID> <POST_TITLE>title</POST_TITLE> <POST_CHANNEL>I</POST_CHANNEL> <POST_DESC>description</POST_DESC> <LINK>http://www...</LINK> <STOC>N</STOC> </item> </POST> I'm trying to transform the xml into an RSS feed using the following setup (feed.xml + rss.xsl) feed.xml: <?xml-stylesheet href="rss.xsl" type="text/xsl"?> <RSSChannels> <RSSChannel src="XMLTEST.xml"/> </RSSChannels> rss.xsl: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" omit-xml-declaration="yes" /> <xsl:template match="RSSChannels"> <rss version="2.0"> <channel> <title>site title</title> <link></link> <description>Site description...</description> <xsl:apply-templates /> </channel> </rss> </xsl:template> <xsl:template match="RSSChannel"> <xsl:apply-templates select="document(@src)" /> </xsl:template> <xsl:template match="item"> <xsl:choose> <xsl:when test="STOC = 'Y'"></xsl:when> <xsl:when test="POST_CHANNEL = 'I'"></xsl:when> <xsl:otherwise> <item> <title> <xsl:value-of select="*[local-name()='POST_TITLE']" /> </title> <link> <xsl:value-of select="*[local-name()='LINK']" /> </link> <description> <xsl:value-of select="*[local-name()='POST_DESC']" /> </description> </item> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> When I try to view the output of feed.xml in Firefox, all of the filtering is applied correctly (sorting out items that shouldn't be published in that channel), but the page outputs as plain text, rather than the usual feed-detection that takes place in Firefox. Any ideas on what I'm missing? Thanks for any suggestions you can provide.

    Read the article

  • Can anyone write a XSL-fo for this XML File with SVG tags?

    - by atrueguy
    Hi all this XML file is very unique with SVG tags, I am stuck in writing an XSL-fo for this xml file, can one help me out in writing a XSL FO, if not the exact answer, atleast give me a idea of how to write, please see the xml file in the below link. http://kzekaa.bay.livefilestore.com/y1pDRDfrEn98IkEO7MQ9MEkC-RQE4QxwsrgVV57WrGWK_AEsqzpwJWkydbnE3NVwrMNT2l9mIG7rErd_NPO94Fmrhrm2Z_zleID/Cleaned_file_source.xml

    Read the article

  • xslt cookbook example not working

    - by Liza dawson
    Hi I am working on this from xslt cookbook type my.xml <?xml version="1.0" encoding="UTF-8"?> <people> <person name="Al Zehtooney" age="33" sex="m" smoker="no"/> <person name="Brad York" age="38" sex="m" smoker="yes"/> <person name="Charles Xavier" age="32" sex="m" smoker="no"/> <person name="David Williams" age="33" sex="m" smoker="no"/> <person name="Edward Ulster" age="33" sex="m" smoker="yes"/> <person name="Frank Townsend" age="35" sex="m" smoker="no"/> <person name="Greg Sutter" age="40" sex="m" smoker="no"/> <person name="Harry Rogers" age="37" sex="m" smoker="no"/> <person name="John Quincy" age="43" sex="m" smoker="yes"/> <person name="Kent Peterson" age="31" sex="m" smoker="no"/> <person name="Larry Newell" age="23" sex="m" smoker="no"/> <person name="Max Milton" age="22" sex="m" smoker="no"/> <person name="Norman Lamagna" age="30" sex="m" smoker="no"/> <person name="Ollie Kensington" age="44" sex="m" smoker="no"/> <person name="John Frank" age="24" sex="m" smoker="no"/> <person name="Mary Williams" age="33" sex="f" smoker="no"/> <person name="Jane Frank" age="38" sex="f" smoker="yes"/> <person name="Jo Peterson" age="32" sex="f" smoker="no"/> <person name="Angie Frost" age="33" sex="f" smoker="no"/> <person name="Betty Bates" age="33" sex="f" smoker="no"/> <person name="Connie Date" age="35" sex="f" smoker="no"/> <person name="Donna Finster" age="20" sex="f" smoker="no"/> <person name="Esther Gates" age="37" sex="f" smoker="no"/> <person name="Fanny Hill" age="33" sex="f" smoker="yes"/> <person name="Geta Iota" age="27" sex="f" smoker="no"/> <person name="Hillary Johnson" age="22" sex="f" smoker="no"/> <person name="Ingrid Kent" age="21" sex="f" smoker="no"/> <person name="Jill Larson" age="20" sex="f" smoker="no"/> <person name="Kim Mulrooney" age="41" sex="f" smoker="no"/> <person name="Lisa Nevins" age="21" sex="f" smoker="no"/> </people> type generic-attr-to-csv.xslt <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:csv="http://www.ora.com/XSLTCookbook/namespaces/csv"> <xsl:param name="delimiter" select=" ',' "/> <xsl:output method="text" /> <xsl:strip-space elements="*"/> <xsl:template match="/"> <xsl:for-each select="$columns"> <xsl:value-of select="@name"/> <xsl:if test="position( ) != last( )"> <xsl:value-of select="$delimiter/> </xsl:if> </xsl:for-each> <xsl:text>&#xa;</xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="/*/*"> <xsl:variable name="row" select="."/> <xsl:for-each select="$columns"> <xsl:apply-templates select="$row/@*[local-name(.)=current( )/@attr]" mode="csv:map-value"/> <xsl:if test="position( ) != last( )"> <xsl:value-of select="$delimiter"/> </xsl:if> </xsl:for-each> <xsl:text>&#xa;</xsl:text> </xsl:template> <xsl:template match="@*" mode="map-value"> <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet> type my.xsl <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:csv="http://www.ora.com/XSLTCookbook/namespaces/csv"> <xsl:import href="generic-attr-to-csv.xslt"/> <!--Defines the mapping from attributes to columns --> <xsl:variable name="columns" select="document('')/*/csv:column"/> <csv:column name="Name" attr="name"/> <csv:column name="Age" attr="age"/> <csv:column name="Gender" attr="sex"/> <csv:column name="Smoker" attr="smoker"/> <!-- Handle custom attribute mappings --> <xsl:template match="@sex" mode="csv:map-value"> <xsl:choose> <xsl:when test=".='m'">male</xsl:when> <xsl:when test=".='f'">female</xsl:when> <xsl:otherwise>error</xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> using the apache xalan parser D:\Test>java org.apache.xalan.xslt.Process -in my.xml -xsl my.xsl -out my.csv [Fatal Error] generic-attr-to-csv.xslt:15:6: The value of attribute "select" associated with an element type "xsl:v alue-of" must not contain the '<' character. file:///D:/Test/generic-attr-to-csv.xslt; Line #15; Column #6; org.xml.sax.SAXParseException: The value of attribut e "select" associated with an element type "xsl:value-of" must not contain the '<' character. java.lang.NullPointerException at org.apache.xalan.transformer.TransformerImpl.createSerializationHandler(TransformerImpl.java:1171) at org.apache.xalan.transformer.TransformerImpl.createSerializationHandler(TransformerImpl.java:1060) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1268) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1251) at org.apache.xalan.xslt.Process.main(Process.java:1048) Exception in thread "main" java.lang.RuntimeException at org.apache.xalan.xslt.Process.doExit(Process.java:1155) at org.apache.xalan.xslt.Process.main(Process.java:1128) Any ideas what am i doing wrong

    Read the article

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