XSLT concat() problem.

Help guys, this XSLT is getting me down!
Im quite simply trying to take a string, and replace tabs with 4 non-breaking space characters.
Can someone please explain to me why the following template doesnt work? It should take in a string, perform the replacement in a recursive fashion, and finally print it out.
Any help is greatly appreciated.
Cheers,
Lee.
     <xsl:template name="substitute">
          <xsl:param name="string" />
          <xsl:param name="from" select="'&#9;'" />
          <xsl:param name="to">
               &#160;&#160;&#160;&#160;
          </xsl:param>
          <xsl:choose>
               <xsl:when test="contains($string, $from)">                    
                    <xsl:call-template name="substitute">                         
                         <xsl:with-param name="string" select="concat(substring-before($string, $from), $to, substring-after($string, $from))" />
                         <xsl:with-param name="from" select="$from" />
                         <xsl:with-param name="to" select="$to" />
                    </xsl:call-template>
               </xsl:when>
          <xsl:otherwise>
               NO MORE SUBSTITUTION REQUIRED - FINAL STRING IS : <xsl:value-of select="$string"/>
          </xsl:otherwise>
          </xsl:choose>
     </xsl:template>

Help guys, this XSLT is getting me down!
Im quite simply trying to take a string, and replace
tabs with 4 non-breaking space characters.
Can someone please explain to me why the following
template doesnt work? It should take in a string,
perform the replacement in a recursive fashion, and
finally print it out.
Any help is greatly appreciated.
Cheers,
Lee.
     <xsl:template name="substitute">
          <xsl:param name="string" />
          <xsl:param name="from" select="'     '" />
          <xsl:param name="to">
               ����
          </xsl:param>
          <xsl:choose>
               <xsl:when test="contains($string, $from)">                    
                    <xsl:call-template name="substitute">                         
<xsl:with-param name="string"
ing" select="concat(substring-before($string, $from),
$to, substring-after($string, $from))" />
                         <xsl:with-param name="from" select="$from" />
                         <xsl:with-param name="to" select="$to" />
                    </xsl:call-template>
               </xsl:when>
          <xsl:otherwise>
NO MORE SUBSTITUTION REQUIRED - FINAL STRING IS :
: <xsl:value-of select="$string"/>
          </xsl:otherwise>
          </xsl:choose>
     </xsl:template>
It is not concat() problem, it is a recursion problem -- too many recursive calls.
I wouldn't recommand using recursion in XSL, yeah, it works, but you can't increase the stack size without restarting the JVM...
anyway, you can use translate function to do replacing, also you can call a java extension method to do string replacement. it is cleaner anyway and more efficient anyway.

Similar Messages

  • XSLT mapping problem

    Hi
    Im doign xslt mapping in XI bw two structures..while doing htis i have come across a requirment, where i have to map different values to nodes which are repeating in different sub structures.
    Ex: source structure and target structure are same..
      <Flight>
       <Pflight>
         <fltno>
         <fltname>
         <fltcode>
      </Pflight>
       <Wflight>
            <fltno>
            <fltname>
            <fltcode>
        </Wflight>
       <Rflight>
          <fltno>
          <fltname>
          <fltcode>
        </Rflight>
    </Flight>
    In this each <fltno>,<fltname> nodes have seperate values...
    I have mapped 'fltno' under each sub structure using this statement.
    <xsl:value-of select=".//*[local-name() = 'fltno'
    Here problem is in target structure it is getting same 'fltno'  under all structures. it means it will be passing the value of 'fltno' under first structure(Pflight) to all the <fltno> nodes.
    But my requirment is <Pflight>, <Wflight>, <Rflight> have seperate 'fltno' and they should get their own value in target structure.
    Can somebody help me.....Really Appreciated
    Thanks And Regards
    Rajesh

    Use the whole path or a partial path which is unique:
    <xsl:value-of select="/Flight/Pflight/fltno">
    or
    <xsl:value-of select="//Pflight/fltno">

  • XSLT Mapping - problem with prefixes when calling template

    Hi all,
    I am having a problem with using an XSLT mapping in XI to combine various fields from 2 input messages of different structures into a single output message.  I understand that XI puts a wrapper around the 2 input messages so the structure of the XML I am mapping is:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns2:Messages xmlns:ns2="http://sap.com/xi/XI/SplitAndMerge">
    <ns2:Message1>
    <ns:(root of first message)>
    </ns:(root of first message)>
    </ns2:Message1>
    <ns2:Message2>
    <ns:(root of second message)>
    </ns: (root of second message)>
    </ns2:Message2>
    </ns2:Messages>
    Currently my XSL looks like the following:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://example.co.uk/example" xmlns:ns2="http://sap.com/xi/XI/SplitAndMerge" xmlns:javamap="java:systemDate.CurrentDate" version="2.0">
    <xsl:output method="xml" version="1.0" encoding="UTF-8"/>
    <xsl:param name="inputparam"/>
    <xsl:template match="ns2:Messages">
    ...<xsl:calltemplate name="FormattingTemplate"/>
    </xsl:template>
    <xsl:template name="FormattingTemplate">
    </xsl:template>
    </xsl:stylesheet>
    When I test the mapping it works fine until it calls the FormattingTemplate.  Then it throws out a "transformer exception" error saying the prefix 'ns2' is not mapped to a namespace.
    If anyone could tell me where I am going wrong I would be very grateful.
    Thanks,
    Mike

    Hi Udo,
    Thanks for your reply.
    When testing the stylesheet locally with XMLSpy, it works fine, but I have just noticed that it adds information in the root tag of the target message as follows:
    <(root of target message) xmlns:javamap="java:systemDate.CurrentDate" xmlns:ns="http://example.co.uk/example" xmlns:ns2="http://sap.com/xi/XI/SplitAndMerge">
    I checked the root tag of the target message in XI and it does not automatically add this information. Thus I added it in my stylesheet so the information above is projected in the target message, but the same error message appears when the call template function is called.  Do you know if I need to somehow add a namespace to templates other than the main one? If so, do you know how I go about doing that?
    Thanks,
    Mike

  • XML XSLT Maping Problem in XI

    Hi,
    I'm actually doing some tests with the possibility to invoke a ABAP-Mapping (ABAP-Class).
    So my scenario is quite simple:
    I have a import xml where I want to substitute exactly one value (database select).
    Now my problem is that the xml comes in with a namespace at the toplevel element (I wrote the complete source string to the trace in my execute function) called "ns0".
    So I stored the output of the trace to a local file for testing and developing a XSLT-Mapping.
    In debugging mode I see that the command:
    <xsl:for-each select="ns0:BAPI_SALESORDER_CREATEFROMDAT2/ORDER_PARTNERS">
    doesn't work as (I) expected (want to loop at the partners) on this content:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:BAPI_SALESORDER_CREATEFROMDAT2 xmlns:ns0="urn:sap-com:document:sap:rfc:functions">
    <ORDER_HEADER_IN>
    <DOC_TYPE>TA</DOC_TYPE>
    <SALES_ORG>1000</SALES_ORG>
    <DISTR_CHAN>10</DISTR_CHAN>
    <DIVISION>00</DIVISION>
    <PURCH_NO_C>654</PURCH_NO_C>
    </ORDER_HEADER_IN><ORDER_ITEMS_IN>
    <item>
    <PO_ITM_NO>10</PO_ITM_NO>
    <MATERIAL>100-100</MATERIAL>
    <TARGET_QTY>100</TARGET_QTY>
    <T_UNIT_ISO>PCE</T_UNIT_ISO>
    </item>
    <item><PO_ITM_NO>20</PO_ITM_NO>
    <MATERIAL>P-100</MATERIAL>
    <TARGET_QTY>100</TARGET_QTY>
    <T_UNIT_ISO>PCE</T_UNIT_ISO>
    </item>
    </ORDER_ITEMS_IN>
    <ORDER_PARTNERS>
    <item>
    <PARTN_ROLE>AG</PARTN_ROLE>
    <PARTN_NUMB>0000001000</PARTN_NUMB>
    </item>
    <item>
    <PARTN_ROLE>WE</PARTN_ROLE>
    <PARTN_NUMB>0000001000</PARTN_NUMB>
    </item>
    </ORDER_PARTNERS>
    </ns0:BAPI_SALESORDER_CREATEFROMDAT2>
    Anyone an idea?
    Thnx
    Olli

    Hi Olli,
    Did you declare the namespace in the XSLT itself?
    Did your write something like?
    <xsl:stylesheet
      exclude-result-prefixes="xsl ns0"
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:ns0="urn:sap-com:document:sap:rfc:functions">
    Actually, the prefix is something you can freely choose.  It is not necessary to use the same prefix as in the source document.  You could just as well use the prefix "x" in your XSLT and write:
    <xsl:stylesheet ...
      xmlns:x="urn:sap-com:document:sap:rfc:functions">
      <xsl:for-each select="x:BAPI_SALESORDER_CREATEFROMDAT2/ORDER_PARTNERS">
    Kind regards, Guy Crets

  • XSLT linefeeds problem

    Hi,
    I have a XML and I wrote a XSL to transform the XML to another XML. The problem is of linefeed in the generated XML. See the output XML where everything comes in one line when I open the XML in notepad whereas my XSL is properly indented. What is the problem?
    Input XML -><?xml version="1.0" encoding="UTF-8"?>
    <Source>
         <FirstName>Bhushan</FirstName>
         <LastName>Bhangale</LastName>
    </Source>XSL -><?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml"/>
    <xsl:template match="/">
         <Result>
              <Name><xsl:value-of select="concat(Source/FirstName, ' ', Source/LastName"/></Name>
         </Result>
    </xsl:template>
    </xsl:stylesheet>Output XML -><?xml version="1.0" encoding="UTF-8"?>
    <Result><Name>Bhushan Bhangale</Name></Result>Java code which I am using ->import javax.xml.transform.*;
    import java.io.*;
    public class TransformXML {
    public static void main(String[] args) {
         try {
              TransformerFactory tFactory = TransformerFactory.newInstance();
              Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource("test.xsl"));
              transformer.transform(new javax.xml.transform.stream.StreamSource("input.xml"), new javax.xml.transform.stream.StreamResult( new FileOutputStream("output.xml")));
         catch (Exception e) {
              e.printStackTrace( );
    }

    Infact I found the standard way of doing it when searched a lot on google.
    <xsl:output method = "xml"
         version = "1.0"
         encoding = "UTF-8"
         omit-xml-declaration = "no"
         indent = "yes"
         media-type = "text/plain"/>
    The indent = "yes" solves the problem but not to the tabs extent. It only takes care of linefeed.

  • XSLT Transformation problem

    Hi,
    hope anybody can help.
    I try to transform a object to another object via XSLT transformation.
    Here is my coding :
      DATA: wa_transformation TYPE y0dpl_structures.
      DATA: obj_import TYPE abap_trans_srcbind_tab,
            wa_import TYPE abap_trans_srcbind.
      DATA: obj_export TYPE abap_trans_resbind_tab,
            wa_export TYPE abap_trans_resbind.
      DATA: obj_data TYPE REF TO data.
    * Get transformation data
      SELECT SINGLE *
      INTO wa_transformation
      FROM y0dpl_structures
      WHERE filetype = i_file_type.
    * Create table with internal structure
      CREATE DATA e_data TYPE (wa_transformation-structure_name).
      wa_import-name = 'IMPORT'.
      GET REFERENCE OF i_data INTO wa_import-value.
      APPEND wa_import TO obj_import.
    * Call transformation
      CALL TRANSFORMATION (wa_transformation-transformation)
      SOURCE (obj_import)
      RESULT (obj_export).
    i_data is a import parameter from type "ref to data".
    My problem is, that "Call transformation" makes a shortdump when calling them.
    Regards,
    Anton

    Found a solution for my problem. Now it works!
      DATA: wa_transformation TYPE y0dpl_structures.
      DATA: obj_import TYPE abap_trans_srcbind_tab,
            wa_import TYPE abap_trans_srcbind.
      DATA: obj_data TYPE REF TO data.
      DATA: wa_return TYPE bapiret2.
      FIELD-SYMBOLS: <data> TYPE ANY TABLE.
    * Get transformation data
      SELECT SINGLE *
      INTO wa_transformation
      FROM y0dpl_structures
      WHERE filetype = i_file_type.
      IF sy-subrc IS INITIAL.
    * Create table with internal structure
        CREATE DATA e_data TYPE STANDARD TABLE OF (wa_transformation-structure_name).
        ASSIGN i_data->* TO <data>.
        wa_import-name = 'IMPORT'.
        GET REFERENCE OF <data> INTO wa_import-value.
        APPEND wa_import TO obj_import.
    * Call transformation
        CALL TRANSFORMATION (wa_transformation-transformation)
        SOURCE (obj_import)
        RESULT export_data = e_data.
      ELSE.
        MOVE:  'Y0_DPL' TO wa_return-id,
               'E'      TO wa_return-type,
               '108'    TO wa_return-number.
        APPEND wa_return TO e_return.
        CLEAR: wa_return.
      ENDIF.

  • XSLT Redundancy Problem

    Hi all,
    I have a serious problem with redundancy in XSLT. In my conversion XML input file, I have many tags like that:
    <tag1 name="..." date1a="..." date1b="...">
    </tag1>
    <tag2 name="..." date2="..." date2b="...">
    </tag2>
    All with different tag names and different attribute names (although the attributes hold similar information).
    Now what I need is a template that could be applied to a combination of tag-attribute, e.g. to tag1, using the values of date1a.
    My current solution has a template for each combination - which is very redundant.
    Any idea how to optimize this without changing the input file? I thought of global variables to store the attribute value but they are "final", so that does not work. Local variables seem to be limited to a single template, so they cannot be used either.
    Any help will be appreciated,
    Ralf

    Hi,
    This is a typical line from the input file:
    <WebAppM3.SingleInfo xmi.id="a71" xmi.uuid="7e33f8b02e0f30f5:00a981ca:000000f425774313:8181" Name="StaticPage" Entity="a67 a66" SubView="a72 a73">
    </WebAppM3.SingleInfo>
    This is a typical transformation rule for it (the relevant rules are for Entity and SubView:
    <xsl:template match="WebAppM3.SingleInfo">
    <!-- Each instance of SingleInfo gets its own class using as much of its old values as
    possible-->
    <Model.Class annotation="" isRoot="false" isLeaf="true" isAbstract="false"
    visibility="public_vis" isSingleton="false">
    <xsl:copy-of select="@xmi.id"/>
    <xsl:copy-of select="xmi.uuid"/>
    <xsl:attribute name="name">
    <xsl:value-of select="@Name"/>
    </xsl:attribute>
    <Model.Namespace.contents>
    <xsl:apply-templates select="descendant::WebAppM3.M2Attribute"/>
    <xsl:apply-templates select="attribute::Entity" mode="link"/>
    <xsl:apply-templates select="attribute::SubView" mode="link"/>
    </Model.Namespace.contents>
    </Model.Class>
    </xsl:template>
    <xsl:template match="@Entity" mode="link">
    <!-- References to the new Associations of type DBConnection -->
    <xsl:variable name="data" select="stringhelp:tokenize(.)"/>
    <xsl:variable name="anc_id" select="ancestor::WebAppM3.SingleInfo/@xmi.id"/>
    <xsl:variable name="targets" select="../WebAppM3.DataSet"/>
    <xsl:for-each select="$data/token">
    <Model.Reference annotation="" scope="instance_level"
    visibility="public_vis" type="a23" isChangeable="true">
    <xsl:attribute name="name">Entity_<xsl:value-of select="."/></xsl:attribute>
    <xsl:attribute name="xmi.id">
    <xsl:value-of select="$anc_id"/>_<xsl:value-of select="."/>
    </xsl:attribute>
    <xsl:attribute name="xmi.uuid">
    <xsl:value-of select="$anc_id"/>_<xsl:value-of select="."/>
    </xsl:attribute>
    <xsl:attribute name="referencedEnd">
    TEST
    </xsl:attribute>
    <Model.StructuralFeature.multiplicity>
    <Model.MultiplicityType lower="0" upper="-1" is_ordered="false" is_unique="false" />
    </Model.StructuralFeature.multiplicity>
    </Model.Reference>
    </xsl:for-each>
    </xsl:template>
    <xsl:template match="@SubView" mode="link">
    <!-- References to the new Associations of type DBConnection -->
    <xsl:variable name="data" select="stringhelp:tokenize(.)"/>
    <xsl:variable name="anc_id" select="ancestor::WebAppM3.SingleInfo/@xmi.id"/>
    <xsl:variable name="targets" select="../WebAppM3.DataSet"/>
    <xsl:for-each select="$data/token">
    <Model.Reference annotation="" scope="instance_level"
    visibility="public_vis" type="a23" isChangeable="true">
    <xsl:attribute name="name">Entity_<xsl:value-of select="."/></xsl:attribute>
    <xsl:attribute name="xmi.id">
    <xsl:value-of select="$anc_id"/>_<xsl:value-of select="."/>
    </xsl:attribute>
    <xsl:attribute name="xmi.uuid">
    <xsl:value-of select="$anc_id"/>_<xsl:value-of select="."/>
    </xsl:attribute>
    <xsl:attribute name="referencedEnd">
    TEST
    </xsl:attribute>
    <Model.StructuralFeature.multiplicity>
    <Model.MultiplicityType lower="0" upper="-1" is_ordered="false" is_unique="false" />
    </Model.StructuralFeature.multiplicity>
    </Model.Reference>
    </xsl:for-each>
    </xsl:template>
    Cheers,
    Ralf

  • Is this a CONCAT problem re: David Powers, or a Magic Quotes problem...

    I've tried to figure this out with the posts (and some info
    on David's site, etc), and I just can't seem to figure out the real
    problem.
    I'm working on a tutorial and I can't figure out if the error
    message is correct and it's improper coding inserted by DW (and if
    so, I can't figure out what to correct) or
    If this is a problem with DW8.0.2 along the lines of what the
    hotfix that seems to be so hard to get will fix, or
    If this is along the lines of an example of why magic quotes
    should be turned off, and if so, where/how do I turn them off, and
    will that correct the code, and if not, how would it be properly
    corrected?
    Here is the error message:
    Parse Error: parse error, unexpected '=', expecting ',' or
    ')' in <thefile> on line 34.
    Here is the code it is referencing:
    32 $Search_rsSearch = "abc";
    33 if (isset(#txtSearch#)) {
    34 $Search_rsSearch = (get_magic_quotes_gpc()) ? #txtSearch#
    : addslashes(#txtSearch#);
    35 }
    36 mysql_select_db($database_dorknozzle, $dorknozzle);
    37 $query_rsSearch = sprintf("SELECT * FROM EmployeeStore
    WHERE ItemName LIKE CONCAT('%%', %s,
    '%%')", GetSQLValueString($Search_rsSearch, "text"));
    38 $rsSearch = mysql_query($query_rsSearch, $dorknozzle) or
    die(mysql_error());
    39 $row_rsSearch = mysql_fetch_assoc($rsSearch);
    40 $totalRows_rsSearch = mysql_num_rows($rsSearch);
    I'm using php4.4.4, mysql5.0.24, apache2.2.3
    Thank You,
    Jeff G.

    xViPERed wrote:
    > If this is a problem with DW8.0.2 along the lines of
    what the hotfix that
    > seems to be so hard to get will fix,
    That will fix part of your problem, but the error is caused
    by something
    else:
    > Here is the error message:
    >
    Parse Error: parse error, unexpected '=', expecting ',' or
    ')' in
    > <thefile> on line 34.
    >
    > Here is the code it is referencing:
    > 32 $Search_rsSearch = "abc";
    > 33 if (isset(#txtSearch#)) {
    > 34 $Search_rsSearch = (get_magic_quotes_gpc()) ?
    #txtSearch# :
    > addslashes(#txtSearch#);
    > 35 }
    # is one of the PHP characters used to comment out part of a
    script. I
    suspect that you have got this from the Dreamweaver help
    files, which
    are particularly unhelpful on this point. The show the
    runtime value
    expression as #formFieldName#, which is ColdFusion style, not
    PHP. You
    need to replace #txtSearch# with something like
    $_GET['search'] or
    $_POST['search'].
    What makes things worse is that the code inserted by 8.0.2
    without the
    hotfix is also incorrect. Line 34 should be something like
    this:
    $Search_rsSearch = $_GET['search'];
    Line 37 is also wrong.
    > 37 $query_rsSearch = sprintf("SELECT * FROM
    EmployeeStore WHERE ItemName LIKE
    > CONCAT('%%', %s,
    > '%%')", GetSQLValueString($Search_rsSearch, "text"));
    It should be this:
    $query_rsSearch = sprintf("SELECT * FROM EmployeeStore WHERE
    ItemName
    LIKE %s", GetSQLValueString("%" . $Search_rsSearch . "%",
    "text"));
    David Powers
    Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    http://foundationphp.com/

  • Transforming XML/XSLT : CDATA problem

    Hi!
    I have a problem transforming xml with XSLT using the API javax.xml.
    The result is correct until I have a CDATA section in my xml document.
    The transforming process encodes all the & < > (special characters) it finds in.
    This occurs problem for the follow of my treatement because the content of my CDATA is already encoded.
    For example, this xml code :
    <?xml version='1.0' encoding="ISO-8859-1" ?>
    <article>
    <article-contenu><![CDATA[Accent : &eacute; Signe : &lt;]]></article-contenu>
    </article>
    produces in my output :
    Accent : &amp;eacute; Signe : &amp;lt;
    This is my java code :
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Source xmlSource = new StreamSource(readerXml);
    Source xslSource = new StreamSource( fileXsl );
    // Generate the transformer.
    Transformer transformer = tFactory.newTransformer(xslSource);
    // Perform the transformation, sending the output to the response.
    transformer.transform(xmlSource, new javax.xml.transform.stream.StreamResult(sw));
    How can I tell the transformer not to do that?
    Thanks for your answers!

    I am having a similar problem. I have enclosed my text data in my xml file like this:
    <![CDATA[<b>Hello World!</b>]]>
    My select statement in my XSLT sheet is as follows:
    <xsl:value-of select="." disable-output-escaping="yes"/>
    I have tried setting xsl:output to text, to html, and to xml. The <, >, and & get converted to xhtml entities.
    Where should I begin to troubleshoot? If the Xalan xslt jars? My stylesheet. My xml doc? Java code?
    Any feedback welcome.

  • XSLT Cache problem including remote host stylesheets

    Hi.
    We are building an XSL page that includes changing named templates through xsl:includes where the included stylesheet is on a remote server.
    The content of the remote stylesheet can change at any time. The problem is that the Oracle XSLT caching mecanism does not "see" this, so we get the old page..
    How can we turn the caching off? Is it possible to turn caching off for selected stylesheets?
    Any clues or pointers?
    Regards
    Lionel

    Hi.
    We are building an XSL page that includes changing named templates through xsl:includes where the included stylesheet is on a remote server.
    The content of the remote stylesheet can change at any time. The problem is that the Oracle XSLT caching mecanism does not "see" this, so we get the old page..
    How can we turn the caching off? Is it possible to turn caching off for selected stylesheets?
    Any clues or pointers?
    Regards
    Lionel

  • Java object XSLT parameters problem. JDK vs Xalan.

    Hello all,
    I need to create a small application which requires to run some transformation interacting with a number of Java classes.
    Small example is below: I have a Java class, which I'm going to use within transformation.
    package com.example;
    public class Document
      private String filename=null;
      public String getFilename() {
        return this.filename;
    }and transformation which extracts some information from the passed parameter object
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:document="com.example.Document">
        <xsl:param name="theDocument"/>
        <xsl:template match="/">
            <example>
                <xsl:value-of select="document:getFilename($theDocument)"/>
            </example>
        </xsl:template>
    </xsl:stylesheet>The code which launches transformation is following:
            try {
                TransformerFactory factory = TransformerFactory.newInstance();
                Templates template = factory.newTemplates(new StreamSource(new FileInputStream(transformationFilename)));
                Source source = new StreamSource(new FileInputStream(theSourceFilename));
                Result result = new StreamResult(new FileOutputStream(theTargetFilename));
                Transformer transformer = template.newTransformer();
                transformer.setParameter("theDocument", theDocument);
                transformer.transform(source, result);
            } catch (TransformerConfigurationException e) {
                e.printStackTrace();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
        }When I run it I get
    ERROR:  'Cannot find external method 'com.example.Document.getFilename' (must be public).'
    FATAL ERROR:  'Could not compile stylesheet'at this line
      Templates template = factory.newTemplates(new StreamSource(new FileInputStream(transformationFilename)));I made a test with a variable, when Document instance is not a parameter but an instance created within transformation and assigned to an XSLT variable. Everything works fine in variable case, but not with parameter.
    Once I've added Xalan-2.7.1 .jars to the classpath it had been fixed. I guess the issue is described here (yep, I'm using 1.5).
    XSLTC does not support all the extensions that Xalan does. These extensions are beyond the definition of the JAXP and XSLT specifications. For those users impacted by this, the work around of downloading the Xalan classes from Apache is still available. Also, going forward we expect to be supporting more and more extensions in XSLTC.
    However, I'd like to find Xalan free solution. Could someone explain what is the difference and how implement the same behaviour without using Xalan?
    Thank you in advance.

    georgemc, your answer may not have helped the original poster, but it just helped me out. So, thank you very much.
    To clarify, for the benefit of anyone else who encounters this issue, it looks as if a possible cause of the 'Cannot find external method' error is that the transformer is defaulting to something - possibly XSLTC - that does not support certain extension methods. Ensuring that a recent Xalan JAR is in the classpath may resolve the problem.
    Edited by: slamci on Mar 13, 2010 11:14 AM

  • Iif and concat problem in email body - solution

    Hi all, it is not a question, just some information if somebody will try to do it:
    If you want to send an email from workflow and use the IIf function with concatenated results, the concat syntax in the help will not work.
    The solution is: Use + character in place of || and so on :)
    For exlampe:
    %%%IIf(PRE('<dDate_field1_ITAG>')<>[<dDate_field1_ITAG>],'Any text '+PRE('<dDate_field1_ITAG>')+'-->'+[<dDate_field1_ITAG>], '')%%%
    The result when the field HAD a value and it is changing to another: Any text 11/11/2011 --> 12/11/2011
    If the field is changing from NULL to something, use this:
    %%%IIf(IfNull(PRE('<dDate_field1_ITAG>'),0)<>[<dDate_field1_ITAG>],'Any text'+PRE('<dDate_field1_ITAG>')+'-->'+[<dDate_field1_ITAG>], '')%%%
    And if U want to see the every change (null -> value, value -> value, and value -> null), use this beauty:
    %%%IIf(IfNull(PRE('<dDate_field1_ITAG>'),0)<>[<dDate_field1_ITAG>] OR ([<dDate_field1_ITAG>] IS NULL AND PRE('<dDate_field1_ITAG>') IS NOT NULL),'Any text'+PRE('<dDate_field1_ITAG>')+'-->'+[<dDate_field1_ITAG>], '')%%%
    Regards,
    A.

    >
    my problem is my email body is
    please clik on this link www.gmail.com
    iii am concating the text please clik on this link ||' '||www.gmail.com
    but in email www.gmail.com is shown on text only.Correct. As the e-mail body is in text/plain MIME format.
    If you want to use formatting in the e-mail body, you need to create a text/html body. At [RFC FAQs|http://www.faqs.org/rfcs/rfc-titles.html], refer to the following RFCs:
    - RFC 2049 - Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples
    - RFC 2048 - Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures
    - RFC 2047 - MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text
    - RFC 2046 - Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types
    - RFC 2045 - Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies
    In simple terms, your e-mail message body needs to look something like this:
    Subject: Test E-mail
    From: "John Doe" <[email protected]>
    To: "Jane Doe" <[email protected]>
    Content-Type: multipart/alternative; boundary="=-2zP89iYM0w6fRrmCDsDv"
    Mime-Version: 1.0
    --=-2zP89iYM0w6fRrmCDsDv
    Content-Type: text/plain
    Content-Transfer-Encoding: 7bit
    This is the start of the e-mail message in plain text format.
    blah blah..
    --=-2zP89iYM0w6fRrmCDsDv
    Content-Type: text/html; charset="utf-8"
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
    <html>
    This is the start of the e-mail message in HTML text format.
    </html>
    --=-2zP89iYM0w6fRrmCDsDv--

  • String concat PROBLEM??? Please Help

    I have this strange Question regarding String concat
    If I say:
    String str = "Welcome";
    str.concat(" to Java");
    System.out.println(str);
    The output is: Welcome.
    How do I get the output to Welcome to Java??

    I have this strange Question regarding String concat
    If I say:
    String str = "Welcome";
    str.concat(" to Java");
    System.out.println(str);
    The output is: Welcome.
    How do I get the output to Welcome to Java??
    The problem is that String is immutable, The String you have held in str does not change, rather a new Srtring is returned. So all yo have to do is grab the new String
    str = str.concat("to Java");
    or use the new String without keeping it.
    ie
    System.out.println(str.concat("to Java"));

  • String concat problem

    Hi folks,-
    i know this question might be very simple but i just cannot see what i am doing wrong here.
    String stringA, stringB, stringC;
    stringA= new String();
    stringB= new String();
    stringC= new String();
    stringA = null;
    stringB = "TRUE";
    stringC = "Error:";
    stringA.concat(stringB); // my code stops and quits here w/o error
    // other codewhat is wrong here?
    thanks much

    could you then please explain the following?
    public String concat(String str)Concatenates the
    specified string to the end of this string.
    If the length of the argument string is 0, thenthis
    String object is returned. Otherwise, a new String
    object is created, representing a charactersequence
    that is the concatenation of the charactersequence
    represented by this String object and thecharacter
    sequence represented by the argument string.
    Examples:
    "cares".concat("s") returns "caress"
    "to".concat("get").concat("her") returns"together"
    Parameters:
    tr - the String that is concatenated to the end of
    this String.
    Returns:
    a string that represents the concatenation of this
    object's characters followed by the stringargument's
    characters.
    Throws:
    NullPointerException - if str is null.It returns a new String, which you are
    throwing away. Change your code like this:
    stringA = stringA.concat(stringB);
    and then you'd get somewhere.yes, it makes sense but the description does not say this.
    i think that will work but my problem is with the description of this
    concat operation on the java web site.
    thanks for the help

  • Xslt transform problem on Sun AS 8PE

    Hi,
    I have following xslt:
    <xsl:call-template name="CustomerFilter">
    <xsl:with-param name="custFilterPath" select="CustomerFilter"/>
    </xsl:call-template>
    <xsl:template name="CustomerFilter">
         <xsl:param name="custFilterPath"/>
         <xsl:text>Customer filter: </xsl:text>
         <strong>
              <xsl:value-of select="$custFilterPath/Type/text()"/> - <xsl:value-of select="$custFilterPath/Name/text()"/>
         </strong>
    </xsl:template>
    I have following xml :
    <CustomerFilter id="0" idDb="0">
    <Name>All</Name>
    <Type>All</Type>
    </CustomerFilter>
    I perform a server xml-xslt tranform to html using xalan 2.5.2 on tomcat5.0.x server with following code without any errors:
    TransformerFactory tf = TransformerFactory.newInstance();
    tf.setURIResolver(new ServerURIResolver(server_url));
    Transformer t = tf.newTransformer(new StreamSource(stylesheet));
    t.setOutputProperty(OutputKeys.INDENT, indenting);
    t.setOutputProperty(OutputKeys.ENCODING, encoding);
    t.setParameter("server_url", server_url);
    t.transform(new DOMSource(response_doc), new StreamResult(response_stream));
    But when I deployed the code on Sun App Server Update1 I get following error:
    [#|2004-10-25T11:54:48.757+0200|SEVERE|sun-appserver-pe8.0.0_01|javax.enterp
    rise.system.container.web|_ThreadID=13;|StandardWrapperValve[xmlgate]:
    Servlet.service() for servlet xmlgate threw exception
    javax.xml.transform.TransformerException: java.lang.RuntimeException:
    Invalid conversion from 'reference' to 'java.lang.String'.
    at
    org.apache.xalan.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:6
    44)
    at
    org.apache.xalan.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:3
    17)
    at
    the last line of sample code
    This code ran without any problems on Sun AS 7 (with Xalan 2.3.1_01).
    I don't know why it's not working. Can anybody help me?
    Thank you,
    Miro

    Actually Xalan version shipped with AS 8.0 is Xalan 2.5.2 + bugfixes. So it is possible that slightly different version might have gone into Tomcat but i am not sure here.
    So it would be good to know, how are you making sure that the same Xalan version is used with AS 8.0 or Tomcat ?
    Best Regards

Maybe you are looking for

  • OS 8.6 – USB devices don't work

    Hi! I can't continue my work on the 4400/200, so I'm trying to get an iMac G3 Rev.D 333 Mhz Tray Loading working. Somebody has installed a later OS 9 for iMac DV slot loading and messed the OS. Well, my actual problem: I'd like to copy the System Fol

  • Dreamweaver CS4 has stopped working

    *** Bug Report *** "Dreamweaver crashes when trying to open it." April 19th - 8:00 PM Reproduce Error: Launch Dreamweaver CS4 from start menu. What happens: Does not load.  Error message appears: Notes: Has been working fine for past 3 days. Errors o

  • Data handling tool

    plz enlist  data handling tools in labview?

  • Reducing Data points

    I am trying to look at the graph patterns of average joint motion angles (X, Y, Z) from many trials of 13 subjects during a certain phase recored at sampling rate of 100 Hz.  This phase of each trial has different data points (For example, trial 1 ha

  • Printing from iMac using bonjour to a printer connected to netgear wifi router USB port

    Wondering if someone could help provide advice. I have just purchased my first iMac and a new NetGear W600 wifi router. I have connected my Canon multifunction MX310 printer directly to my iMac and it prints and scans perfectly. However when I connec