Sunday, September 28, 2014

How to Remove Default Attribute Values From the Output Java XML Transformer

Instructions

    1

    Open the Java editor you use to create your applications. Open the project, and then double-click the Java source code file you want to use with the Transformer class.

    2

    Add the libraries to the top of the source code file. You must add the "includes" to use the libraries. The following code adds the includes to the source code:

    include javax.xml.transform;

    3

    Initialize the Java Transformer class. The following code code initializes the class:

    TransformerFactory trans = TransformerFactory.newInstance( );

    4

    Load the XLST file you want to use to transform the XML data. The following code loads a file named "styles.xlst":

    Transformer file = transFact.newTransformer("stles.xlst");

    5

    Remove the default attribute. You remove the default attribute by setting it to a blank string. The following code removes the attribute:

    file.setParameter("default", "");

    6

    Save the changes and click the "Run" button in the editor's toolbar to view the code changes in the debugger.



No comments:

Post a Comment