Subjects
Home
Xalan extension functions
Fomatting question serializing DOM with pretty print
xalan with pull parser
Cannot find the declaration
Apache Xalan drop support to run on JRE 1 1 x
Why does Doctype change processing of a document
Node set to XML string via Java extensions in Xalan J: possible?
Templates/Transformers + thread safety???
Problem evaluating xpath with muliple prefix with different namespace
remove an arbitrary attribute from xsl output
Xalan3 XSLT 2 0 XPath 2 0 support?
Problem using compiled translets with Xalan !!
Xalan and jstl 1 1 problem with transform tag
NullPointer in DOM2DTM getLocalName
URIResolvers base parameter with xsltc and cascaded imports
Performance problem for Xalan J on intel dual core
Standard libraries in JAXP?
Serializing a DOM tree to XML file, customize entities replacement
Library Conflict Involving BCEL Library
A question on how users are using <xsl:message >
Kevin Cormier as a new Apache Xalan J committer
Struggling to iterate over tokenized string
Xalan count() trouble
Problem with recursive xpath
Error when switching to java 1 5
document( ' ')
Problem with Xalan2 7 0 transformation
cr/lf options
entity encoded XML
can xalan transform 2 xml using one xslt?
Xalan J JIRA defect review Monday October 16, 2006 from 2:00 to 3:30 pm ED
xsl transform with cdata section elements
xslt parameters not expanded
Weird behavior of XPath evaluate()
How to avoid <xsl:message > instruction prints stylesheet file informations ?
Cannot find SimpleTransform subdirectory after installing Xalan J
recover from document not found exceptions
jdk1 5 and Xalan jar differences?
Performance Issue
Error/Bug adding floating point numbers
XPathAPI: eval exp using nodes with default namespace
modifying xalan to output invalid XML
NullPointerException
mege two separate xml nodes into one
Is this a XALAN document identification bug?
is StylesheetRoot really java io Serializable ?
transform() fails for DOMSource but succeeds for StreamSource
Thoughts on Transformer parameter passing
HELP, Xalan and jstl 1 1 problem with transformer
Problem with XPath namespace axis?
string utils:replace deleting search string if replacement string is an HTML
help with enumeration values pls
xalan 2 5 1 vs 2 7 performance question
How to insert/update in XML document
HTML Serialization and Handling of Ampersands in HREF Attributes
XHTML link tag stripping
SystemId Unknown; Line #24; Column #49; java lang NullPointerException
xpath text() help
Apostrophe problem with xalan 2 7 0
How to set variables in XML document?
Links
Home
Oracle database error code ...
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
RE: Using <xsl:output omit-xml-declaration= "yes "/ > does not work
    with XMLFil

RE: Using <xsl:output omit-xml-declaration= "yes "/ > does not work
    with XMLFil

2003-07-02       - By Aviv Rosenfeld
Reply:     1     2  

  This is the complete example, the XML decleration shows up in the
output:

> foo1.xsl:
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>   <xsl:template match="doc">
>     <out><xsl:value-of select="."/></out>
>   </xsl:template>
> </xsl:stylesheet>
>
> foo2.xsl:
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>   <xsl:template match="out">
>     <out><xsl:value-of select="."/> ...good to see you again!</out>
>   </xsl:template>
> </xsl:stylesheet>
>
> foo3.xsl
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output method="text" omit-xml-declaration="yes"/>
>   <xsl:template match="out">
>     <out><xsl:value-of select="."/> ...and goodby!</out>
>   </xsl:template>
> </xsl:stylesheet>
>
> foo.xml:
> <?xml version="1.0"?>
> <doc>Hello</doc>
>
>
  UseXMLFilters.java :
  import java.io.IOException;

  import javax.xml.transform.TransformerConfigurationException;
  import javax.xml.transform.TransformerException;
  import javax.xml.transform.TransformerFactory;
  import javax.xml.transform.sax.SAXResult;
  import javax.xml.transform.sax.SAXSource;
  import javax.xml.transform.sax.SAXTransformerFactory;
  import javax.xml.transform.stream.StreamSource;

  import org.apache.xml.serializer.Serializer;
  import org.apache.xml.serializer.SerializerFactory;
  import org.apache.xml.serializer.OutputPropertiesFactory;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  import org.xml.sax.XMLFilter;
  import org.xml.sax.XMLReader;
  import org.xml.sax.helpers.XMLReaderFactory;

   /**
    * This example shows how to chain a series of transformations by
    * piping SAX events from one Transformer to another. Each
Transformer
    * operates as a SAX2 XMLFilter/XMLReader.
    */
  public class UseXMLFilters
  {
   public static void main(String[] args)
    throws TransformerException,
TransformerConfigurationException,
          SAXException, IOException    
    {
     // Instantiate  a TransformerFactory.
      TransformerFactory tFactory =
TransformerFactory.newInstance();
     // Determine whether the TransformerFactory supports The use uf
SAXSource
     // and SAXResult
     if (tFactory.getFeature(SAXSource.FEATURE) &&
tFactory.getFeature(SAXResult.FEATURE))
     {
       // Cast the TransformerFactory to SAXTransformerFactory.
       SAXTransformerFactory saxTFactory = ((SAXTransformerFactory)
tFactory);
       // Create an XMLFilter for each stylesheet.
       XMLFilter xmlFilter1 = saxTFactory.newXMLFilter(new
StreamSource("foo1.xsl"));
       XMLFilter xmlFilter2 = saxTFactory.newXMLFilter(new
StreamSource("foo2.xsl"));
       XMLFilter xmlFilter3 = saxTFactory.newXMLFilter(new
StreamSource("foo3.xsl"));
     
       // Create an XMLReader.
       XMLReader reader = XMLReaderFactory.createXMLReader();
     
       // xmlFilter1 uses the XMLReader as its reader.
       xmlFilter1.setParent(reader);
     
       // xmlFilter2 uses xmlFilter1 as its reader.
       xmlFilter2.setParent(xmlFilter1);
     
       // xmlFilter3 uses xmlFilter2 as its reader.
       xmlFilter3.setParent(xmlFilter2);
     
       // xmlFilter3 outputs SAX events to the serializer.
       Serializer serializer = SerializerFactory.getSerializer
 
(OutputPropertiesFactory.getDefaultMethodProperties("xml"));        
       serializer.setOutputStream(System.out);
       xmlFilter3.setContentHandler(serializer.asContentHandler());

       // Perform the series of transformations as follows:
       //   - transformer3 gets its parent (transformer2) as
the XMLReader/XMLFilter
       //     and calls transformer2.parse(new
InputSource("foo.xml")).
       //   - transformer2 gets its parent (transformer1) as the
XMLReader/XMLFilter
       //     and calls transformer1.parse(new
InputSource("foo.xml")).
       //   - transformer1 gets its parent (reader, a SAXParser) as
the XMLReader
       //     and calls reader.parse(new InputSource("foo.xml")).
       //   - reader parses the XML document and sends the SAX
parse events to transformer1,
       //     which performs transformation 1 and sends the
output to transformer2.
       //   - transformer2 parses the transformation 1 output,
performs transformation 2, and
       //     sends the output to transformer3.
       //   - transformer3 parses the transformation 2 output,
performs transformation 3,
       //     and sends the output to the serializer.
       xmlFilter3.parse(new InputSource("foo.xml"));
     }
   }
  }

>   -----Original Message-----
>   From:   Aviv Rosenfeld
>   Sent:   eai uieue 01 eaie 2003 22:32
>   To:   'Siljan Simpson '
>   Subject:   RE: Using <xsl:output omit-xml-declaration="yes"/>
> does not work wit h XMLFilter
>
>   Hi Siljan,
>
>   I am running  exactly the UseXMLFilters example as comes
>   with the installation of Xalan. The only change I made
>   is adding the xsl:output element to the last XSL file.
>
>   When running a "normal" transformation,i.e. using only one
> transformation
>   it works ok and the decleration is dropped, the problem seem to
>   show up when using the XMLFilters for a multiply transformation.
>
>   I tried it with both Xalan 2.2.0 and 2.5.1.
>
>   I am not familiar with XSLTC so I assume the usage is of the
> intepretive
>   XSL, again, axactly as it is in the USEXMLFilters Xalan example.
>
>   Thanks
>   Aviv
>
>   -----Original Message-----
>   From: Siljan Simpson
>   To: Aviv Rosenfeld
>   Sent: 01/07/03 17:57
>   Subject: Re: Using <xsl:output omit-xml-declaration="yes"/>  does
> not work wit h XMLFilter
>
>   I just ran your XSL and the XML declaration is not seen in the
> output.
>
>   What build of xalan are you using ?
>   Are using the XSL in the intepretive mode or compiling it using
> XSLTC ?
>
>   -Siljan
>
>
>   ----- Original Message -----
>   From: Aviv Rosenfeld <AvivR@(protected)>
>   Date: Tue, 1 Jul 2003 11:21:13 +0200
>   To: xalan-j-users@(protected)
>   Subject: Using <xsl:output omit-xml-declaration="yes"/>  does not
> work
>   wit h XMLFilter
>
>   > Hi,
>   >
>   > I would like to drop the XML declaration from the output
>   > of my multiply transformation. Adding the line:
>   > <xsl:output omit-xml-declaration="yes"/>, to the xsl file,
>   > does not seems to work and I still get the XML declaration
>   > in the output.
>   >
>   > I am using a similar code to the "UseXMLFilters" Xalan sample.
>   > I have changed foo3.xsl to the following (added the xsl:output
>   element):
>   >
>   > <?xml version="1.0"?>
>   > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   > version="1.0">
>   >   <xsl:output omit-xml-declaration="yes"/>
>   >   <xsl:template match="out">
>   >     <out><xsl:value-of select="."/> ...and goodby!</out>
>   >   </xsl:template>
>   > </xsl:stylesheet>
>   >
>   > How do I get rid of the XML declaration in the output?
>   >
>   > Thanks
>   > Aviv
>   >
>
>   --
>   __________________________________________________________
>   Sign-up for your own FREE Personalized E-mail at Mail.com
>   http://www.mail.com/?sr=signup