Writing a Custom Transformer

Hi, I'm currently using a transformer to output a DOM structure as an XML file. I have not modified the transformer in any way. What I need to do is:
If a DOM Element node has an attribute called "disable" then don't write its XML tag, else write its tag as normal.
Is there a way to modify the transformer to do this? Any help appreciated.
Current code:
  public void fWrite(File fOut) {
    try {
      // Use a Transformer for output
      TransformerFactory tFactory =
          TransformerFactory.newInstance();
      Transformer transformer = tFactory.newTransformer();
      DOMSource source = new DOMSource(te.document);
      StreamResult result = new StreamResult(fOut);
      transformer.transform(source, result);
    catch (TransformerConfigurationException tce) {
      // Error generated by the parser
      System.out.println("* Transformer Factory error");
      System.out.println("  " + tce.getMessage());
      // Use the contained exception, if any
      Throwable x = tce;
      if (tce.getException() != null)
        x = tce.getException();
      x.printStackTrace();
    catch (TransformerException e) {
      // Error generated by the parser
      System.out.println("* Transformation error");
      System.out.println("  " + e.getMessage());
      // Use the contained exception, if any
      Throwable x = e;
      if (e.getException() != null)
        x = e.getException();
      x.printStackTrace();
  }THX
Manehad

You will need to add a XSL to your transformer (refer to XMl tutorial: http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/xslt/index.html ). You add a Source to the newTransformer method, which will be used when transforming...
Code example:
import java.io.File;
import javax.xml.transform.stream.StreamSource;
StreamSource xslsource = new StreamSource( new File( "xslfile.xsl" ) );
Transformer transformer = tFactory.newTransformer( xslsource );
You now need to specify the xsl-sourcefile, I recommend you read through the tutorial listed above, and maybe even the XSL/XSLT specification from http://www.w3.org/Style/XSL/ if you feel the need. In the xsl-file, you can use something like the following code to determine whether the attribute is there or not and choose what to do if...
Code example:
<xsl:choose>
     <xsl:when test="@disable"></xsl:when>
     <xsl:otherwise>
     ... Your code goes in here ...
     </xsl:otherwise>
</xsl:choose>
I hope this helps, I am not an expert programmer but I myself am trying to learn how to do this at the moment...
good luck...
/Richard

Similar Messages

  • Problem Deploying Custom Transformation Provider to Remote System

    Hello Experts,
    I have successfully created a custom XML Transformation Provider/transformer and deployed it to my local development system and to a remote sandbox system. We are using NWDI and the transformation provider is within the context of a DC.  However, I am deploying to both my local dev and the remote sandbox systems using the u201CQuick PAR Uploadu201D in NWDS.
    After deploying the same PAR to both my local portal and the remote sandbox systems I can see the new service is deployed in both portals (System Administation -> Support -> Runtime -> etc..).  I can also see the service registered successfully in the portal registryu2014again, in both systems.
    Everything works fine on my local dev when I run code to retrieve and apply the custom transformer to source XML.  The new transformer is also available when creating an XML iView.   However, I cannot retrieve or use the new transformer (u201Cno such transformeru201D errors) using the same code on the remote sandbox system.  Also, the new transformer is not available when using the XML iView wizard.
    It seems the custom transformation provider is deploying successfully on the remote system, but the transformer is not.
    Both systems are ostensibly identical, NW 7.0 EP SPS14.  The credentials Iu2019m using when performing the Quick PAR Upload have Administrator/Super Admin Role privileges.  (I even tried uploading the PAR directly into the portal using the Admin Console to see if that made a differenceu2026it did not).
    Any ideas why a transformer would not be available after a custom transformation provider deploys without any apparent errors to the remote system?
    Thanks for your time!

    Hi,
    I presume this issue is not that common.
    Any ideas on where to look (logs) for results after a PAR is deployed to the server?  I do not see any errors in the defaultTrace related to the deployment and I've looked through other logs, too.  In any case, the "custom" transformation provider service appears in the portal, but I still don't see the tranformer itself.
    Thanks again,
    Dave

  • Writing a custom component with multiple fields.

    Does anyone have some pointers on writing a custom component that properly handles multiple input fields?
    An example usage might be as follows:
    Assume the following java classes:
    public interface Address {
        //... getters/setters for Address.
    public class Company{
        Address getAddress(){...};
    }The tag usage might be something like the following:
    <custom:address value="#{myCompanyBean.address}" />
    Extending UIComponentBase I can easily render the output and create all the needed input elements. I'm also able to properly retrieve the submitted values in the decode method. But I'm unsure how to handle the "UpdateModelValues" step. Do I simply over-ride processUpdates, or is there more housekeeping to be done?
    Thanks.

    I'm guessing that doing addChild inside createChildren causes an infinite loop.
    Why aren't you just doing this with MXML?  it would be a lot simpler.

  • Writing a Custom Property Renderer

    Hello all,
    I am new to KMC development.  I want to know how to go about writing a custom property renderer.  Detail step by step instructions as to where to start and what are the configurations, etc. would be a great help for me.
    Thanks in advance.
    Vicky R.

    Hello Vicky,
    Step by Step guide to creating Property renderer is:
    1. Program an implementation of AbstractPropertyRenderer.
    2. Implement a RFServerWrapper service to register your property renderer with CrtClassLoaderRegistry.
    CrtClassLoaderRegistry.addClassLoader(this.getClass().getClassLoader());
    3. Technical mapping to your coding in the Property Metadata service.
    4.Restart your server for the changes to take effect.
    Check this link for more infos:
    https://forums.sdn.sap.com/thread.jspa?threadID=41619
    Also check the implementations of RFServerWrapper service in examples at this link:
    http://sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c739e546-0701-0010-53a9-a370e39a5a20
    Greetings,
    Praveen Gudapati

  • Doucmentation/Guide on Writing a custom component (a DSC)

    Hello,
    I'd like to learn more about writing a custom component (a DSC), does any one know if there is documentation/guide/tutorial on how to start on it? Please share your comments.
    Thanks in advance,
    Han Dao

    Hello,
    Thank you for all replies, they are very helpful for starting to learn more about DSC.
    I do have another question, is it possible to re-write an already built-in service to customize it in a different way. e.g. The Service Operation "Read Document" in Foundation > FileUtilsService to accept a different type of its Input?
    Thanks,
    Han Dao

  • Custom transform fails

    I'm creating a custom transformation by implementing oracle.oai.agent.server.transform.Transformable and reading in the .tdf file in IStudio. The contents of the .tdf file is:
    name=ConcatStringsAdvanced
    package=mypackage
    class=ConcatStringsAdvanced
    description=Concats two strings, but leaves out space if second string is empty
    number types=1
    param0 name=Delimiter
    param0 option=.
    my implementation is (I've only included the important part:
    package mypackage;
    import ...
    public class ConcatStringsAdvanced implements Transformable
    public Vector transform (Vector objects,
    Vector params,
    MessageObject sourceMessageObject,
    MessageObject destinationMessageObject) {
    //implementation is here
    I've included the jar file containing my implementation in the classpath of the adapter. When I try to run it, the adapter throws a ClassNotFoundException. If I do not include a package name in the tdf file and change the implementation and jar-file accordingly, it works perfectly. Any suggestions as to what the error can be.

    Be careful with the Option key in transformation shortcuts -- it also means duplicate when held down and transforming. Change the shortcut to Command-Control-R and you'll be OK.
    Also, Option-R is the ® character, so by assigning it to a shortcut you're using a slot that's usually used for a keystroke -- although perhaps you already knew that.
    Dave

  • Bridge Output Module: Use Custom Transformer.xslt?

    Hello,
    I've been poking around the Adobe Output Module in CS4 to determine if we might be able to use it instead of the old Web Photo Gallery plug-in for Photoshop. I can understand the reasoning behind using XSLT / XML to generate HTML gallery pages, but I'm baffled by what appears to be a complete inability to specify a custom "transformer.xslt" which would be specific to a media gallery template. Is there any way to tell Bridge's Output Module to use a custom transformer.xslt so I don't have to edit or replace the default one?
    Many thanks for any help.

    SERIOUSLY.  And how about all of the other things missing from the old Contact Sheet:
    1. How many pdf pages will be generated?  ***MAY BE USEFUL when calculating the images per colum/row
    2. the ability to output directly to Photoshop.  Is it that hard?  Do you really believe people didn't use that?
    3. fix the stupid zoom.  It's a POINTER FINGER, but when you click it zooms.  And God forbid you keep anything consistent with any of your other software - ZOOM OUT IS *SHIFT*, not Command.  Even then, the cursor stays a stupid finger.

  • How to: Reconcile Public Custom Transformations

    I created some procedures in R1 as public transformations. When migrating to R2 they became public custom transformations. Now I altered the number of parameters and I want to reconcile them into R2. Helas there is no option to import them. Does anyone have a clou? TNKS Phil

    Hi,
    public transformations are deployed as usual objects using the control center manager. They are available in every project and every location.
    "Global" means they are defined in one place and available (and deployable) everywhere. It does not mean that they are deployed just to one schema. On contrary, they can be deployed to every target location and must be deployed to every location where mappings that use them are deployed.
    Regards,
    Carsten.

  • OWB10.1 Deploying public custom transformations

    We are in the process of upgrading from OWB 9.0.4 to 10.1.
    We have come across a problem in 10.1 that we can't remember ever having in 9.0.4.
    When a public custom transformation is selected in the deployment manager no record appears on the right hand side of the screen. This is different behavior to what is expected, and the observed behavior for other object types (mappings, process flows & database transformations) in 10.1.
    The result of not seeing the object in the right hand side of the deployment manager is that we are unable to select a deployment action so we are unable to deploy the functions.
    Any ideas?

    Does anyone use OWB 10.1?

  • Writing a custom UIOutput component

    Hi,
    I'm attempting to write a custom tag (with facelets) to conditionally render its child components.
    The tag should be something like this:
    <mw:menu>
      <h:outputText value="blabla"/>
    </mw:menu>My menu tag will try to a menu file, and if it exists must insert that file's content as the child content of the mw:menu tag. If not, it should render the default, in this case "<h:outputText value="blabla">". Here's the problem, I can't work that one out, so I hoped you guys could help me along.
    Here's what I have (simplified):
    public class Menu extends UIOutput {
         private boolean renderDefaultMenu = false;
         public Menu() {
              super();
         public void encodeBegin(FacesContext context) {
              String url = null;
              try {
                   // .... Get and read the menu file .....
                   String inputLine;
                   while ((inputLine = in.readLine()) != null)
                        context.getResponseWriter().write(inputLine);
                   in.close();
                   // We printed the menu, so skip the default menu
                   // that is in this tag's body.
                   return;
              } catch (FileNotFoundException ex) {
                   log.warn("Menu file not found (" + url + "), reverting to default menu.");
              } catch (Exception ex) {
                   // ... Some logging ...
              renderDefaultMenu = true;
         public boolean getRendersChildren() {
              return renderDefaultMenu;
         public void encodeChildren(FacesContext context) throws IOException {
              super.encodeChildren(context);
         @Override
       public String getFamily(){
           return "be.xxx.web.Menu";
         @Override
         public String getRendererType() {
              return null;
    }So far I have only been testing the case of FileNotFoundException, but my menu tag never renders its children.
    Anyone knows what I'm doing wrong here?
    Thanks

    Hi,
    Thanks for the quick response. Could you please suggest me a way to go about writing your own custom renderers?
    Thanks.

  • Writing a custom RMI Activator process

    Hello Group,
    I am in the process of implementing a custom RMI activation scheme, in which remote Activatable objects will be hosted in a custom EXE process, instead of the standard Java.exe/Javaw.exe. I intend to use JNI to create the JVM in this custom EXE process and then load Java classes. I have used JNI to create JVMs in native processes before, but have no experience writing custom RMI activation systems.
    Has anyone attempted this before, and knows if there are any gotchas that I should know early on?
    Thanks,
    Ranjit

    I have a breakthrough. I am able to host a simple RMI server inside a custom EXE. All I do is inside the main of a Win32 EXE, create the JVM and use JNI to call the ‘main’ of a Java class I wrote below.
    This class runs (some undocumented) code to bootstrap the RMI machinery. Hereafter my EXE process process remains alive and is available to service RMI requests. Using this approach, I wouldn’t need to recompile java.c inorder to rename it as long as my custom JNI code is able to parse in all the VM options passed in by RMID in order to create the JVM.
    I was missing the crucial step of calling back into rmid (the Activator) and registering the newly created group, only after which would rmid start creating instances of the remote object. Your advice that I carefully read the spec helped!
    public class Host {
    public static void main(String[] args) throws Exception {
    Class clsInputStream = Class.forName("sun.rmi.server.MarshalInputStream");
    Constructor ctor = clsInputStream.getConstructor(InputStream.class);
    Method readObj = clsInputStream.getMethod("readObject", null);
    Method readLong = clsInputStream.getMethod("readLong", null);
    // Instantiate MarshalInputStream
    Object in = ctor.newInstance(System.in);
    // Read all the data passed in by the Activator (rmid)
    ActivationGroupID id = (ActivationGroupID) readObj.invoke(in);
    ActivationGroupDesc desc = (ActivationGroupDesc) readObj.invoke(in);
    long incarnation = (Long) readLong.invoke(in);
    // Create the ActivationGroup
    ActivationGroup grp = ActivationGroup.createGroup(id, desc, incarnation);
    // Callback into rmid to register the group.
    ActivationGroup.getSystem().activeGroup(id, grp, incarnation);
    // rmid will now invoke ActivationGroup.newInstance to create the RMI server
    Thanks,
    Ranjit

  • Writing a custom renderer for the component  "af:processTrain" in 10g

    Hello,
    I have a requirement where we need to customize the way the af:processTrain is rendered. For this, the simpler and the more generic way would be to write a custom renderer for the af:processTrain component. Is there any documentation or examples that could help in accomplishing this as I could not get any relevant examples or documents.
    Thanks,
    Swapna

    Hi,
    Thanks for the quick response. Could you please suggest me a way to go about writing your own custom renderers?
    Thanks.

  • SD3.0 EA3: Where do I place my custom transformations?

    When running SQL Developer 3.0 EA3 I keep seeing the default transformation scripts even after replacing:
    C:\sqldeveloper3EA3\sqldeveloper\extensions\oracle.datamodeler\types\dr_custom_scripts.xml (containing all my custom scripts)
    What am I missing?
    - Marc de Oliveira
    Edited by: marc66 on 2011-01-19 06:33

    Marc,
    this is default location of "Default System Data types" directory as it's called in preferences. It's the new location of the file with scripts. Probably you have changed it in preferences - content of directory (4 files) is copied to new location if files do not exist there.
    Philip

  • Sql Developer Data Modeler 3.0 EA1: Custom transformation script

    What is the object model used by:
    Tools -> Design Rules -> Transformations
    From looking at the examples (and guessing) I have managed to create ID attributes on all my entities, but how do I set its sequence number or set it as the primary key?
    entities = model.getEntitySet().toArray();
    for (var e = 0; e<entities.length; e++)
    entity = entities[e];
    att = entity.createAttribute();
    att.setName('ID');
    - Marc de Oliveira

    content of XML files:
    1) class described, parent class if there is one
    2)<property .../>
    describes property - set and get method, data type of property, default value
    3) <collection ... />
    describes collection of objects belonging to class - 5 collections are defined in Table.xml - columns, indexes, table check constraints, column groups and spatial definitions
    - get method - to get collection
    - create item method - method of described class used to create item for that collection; so for columns collection table.createColumn() will create column in table
    - other methods - add, move, remove if are defined
    4)other meta data
    definitions in 1) .. 4) are used by Oracle SQL Developer Data Modeler, so it'll be wrong to modify those xml files
    5)<roproperty ../>
    Data Modeler doesn't parse/process these definitions, we decided to not filter them out however you should not rely that much on them
    6)some junk left
    For each object you can set your own properties and they will be persisted (also included in compare/merge in versioning) together with other information for object - look at "template table" example in transformation scripts. Here are methods you can use:
    void setProperty(String key, String value);
         String getProperty(String key);
         boolean hasProperty(String key);
         boolean hasProperty(String key, String value);
         void removeProperty(String key);
         void clearProperties();
         Iterator getPropertyNames();
    Philip

  • Writing a Custom StartPoint

    Hi,
    I want to know whether i can  write a custom startpoint just like a custom component? .
    Let me know if there is any way to do it. Please share me any documents or URL's related to it which will help.
    Thanks,

    When you say like a custom component, I take that as you want to write some Java code which allows for a new way of initiating a process. That would mean the first code run is your code as opposed to the entry point being one of the provided Adobe entry points to a process. Write code with whatever method of kicking it off you want then use APIs to call the LiveCycle process.

Maybe you are looking for