XSLT How to

From Plex-XML
Jump to: navigation, search

Contents

Some tips and tricks how to...

...open a new request in the same window like it is done in a wizard:

Use the next request as a reaction for your request an use page as style parameter.

...
<response>
 <error type="reaction" name="OK" response="C2PV700AE" value="OK"/>
 <error type="default" name="DEFAULT"/>
 <reaction type="DEFAULT" target="DISPLAY" name="/WEB-INF/contract/resources/C2PV700AE_IN.xslt" localized="true"/>
 <reaction type="OK" target="WEBREQUEST" name="C2PV700AE">
  <parameter type="web" response="C2PV700AE" field="UpdateKey_C2_IdentCode" targetfield="C2 IdentCode"/>
  <parameter type="fix" targetfield="style" value="page"/>
 </reaction>      
</response>
...

Use the REDIRECT-Request if the complete page should be replaced:

...
<response>
 <error type="reaction" name="OK" response="C2PV701AE" value="OK"/>
 <error type="default" name="DEFAULT"/>
 <reaction type="DEFAULT" target="DISPLAY" name="/WEB-INF/contract/resources/C2PV701AE.xslt" localized="true"/>
 <reaction type="OK" target="WEBREQUEST" name="REDIRECT">
  <parameter type="fix" value="ObjectMTab" targetfield="parNextRequest"/>
  <parameter type="fix" value="ObjectMain" targetfield="parPar01"/>
  <parameter type="fix" value="ObjectGroup" targetfield="parPar02"/>
  <parameter type="fix" value="ObjectType" targetfield="parPar03"/>
  <parameter type="fix" value="Action" targetfield="parPar04"/>
  <parameter type="web" response="ObjectMCopy" field="NewKey_IdentifierObjectMain" targetfield="parValue01"/>
  <parameter type="web" response="ObjectMCopy" field="NewKey_IdentifierObjectGroup" targetfield="parValue02"/>
  <parameter type="web" response="ObjectMCopy" field="NewKey_IdentifierObjectType" targetfield="parValue03"/>
  <parameter type="fix" value="U" targetfield="parValue04"/>
  <parameter type="fix" targetfield="parFormat" value="Update"/>
 </reaction>      
</response>
...

The Redirect-Request could also handle Secured Fields!

...suppress the label for the first field in a row:

Use 'no label' as translation in your format-field definition.

...send a Mail as response:

Define a target="SENDMAIL" as reaction e.g.:

...
<reaction type="READY" mime="text/html" target="SENDMAIL" localized="true" name="/WEB-INF/toolbox/style/ReqFormSendMail.xslt">
 <parameter type="web" targetfield="server" response="ReqFormSendMail" field="MailOutput_MailServerName" />
 <parameter type="web" targetfield="user" response="ReqFormSendMail" field="MailOutput_MailSMTPUser" />
 <parameter type="web" targetfield="password" response="ReqFormSendMail" field="MailOutput_MailSMTPPassword" />
 <parameter type="web" targetfield="subject" response="ReqFormSendMail" field="MailOutput_MailSubject" />
 <parameter type="web" targetfield="to" response="ReqFormSendMail" field="MailOutput_MailAddressTo" />
 <parameter type="web" targetfield="cc" response="ReqFormSendMail" field="MailOutput_MailAddressCC" />
 <parameter type="web" targetfield="bcc" response="ReqFormSendMail" field="MailOutput_MailAddressBCC" />
 <parameter type="web" targetfield="from" response="ReqFormSendMail" field="MailOutput_MailAddressFrom" />
 <parameter type="web" targetfield="replyto" response="ReqFormSendMail" field="MailOutput_MailAddressReplyTo" />
 <success-page usedefaultstyle="false" name="/WEB-INF/resources/@common_html@/ready.xslt"/>
 <error-page name="/WEB-INF/resources/common/Error.xslt"/>
</reaction>
...

The body of your mail will created in xslt in the first part. It could use any part from your xml response as HTML or TEXT mail.

Mail Parameters like mail-server, user, password, from, reply-to are stored in System Parameter.

see also: Web-Requests#Reaction_Types


If yyou like to send mails inside a Plex-Function you could use the "SEC_V20/BusinessExtraFunctions.sendFullMail" function. It takes the same parameters like the reaction described above. The body should be build with the "SEC_20/FormatMessage" function. So you are able to customize and translate your body/subject text in the S2Dictionary table.

...use find and replace in xslt

Use as Header:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 xmlns:set="http://exslt.org/sets"
 xmlns:plex="http://xml.apache.org/xalan/de.bodow.plex.PleXML" 
 xmlns:str="http://xml.apache.org/xalan/java/java.lang.String" 
 exclude-result-prefixes="plex str">

Example how to replace "\n" with "<br/>"

<xsl:value-of select='str:replaceAll(str:new(string(@value)), "\n","<br/>")'/>

...show HTML content from your xml

<xsl:value-of select="@value" disable-output-escaping="yes"/>

...hide the format selector

...in the upper right corner of a dictionary function. Just put the empty template in your first xslt filter:

<!-- Hide Formatselector -->
<xsl:template name="formatSelector"/>
Personal tools