tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r423143 - in /incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src: main/java/org/apache/tuscany/databinding/ main/java/org/apache/tuscany/databinding/trax/ test/java/org/apache/tuscany/databinding/impl/
Date Tue, 18 Jul 2006 17:26:49 GMT
Author: jboynes
Date: Tue Jul 18 10:26:49 2006
New Revision: 423143

URL: http://svn.apache.org/viewvc?rev=423143&view=rev
Log:
apply patch from Raymond Feng to address SAX namespace problems

Modified:
    incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/PushStyleTransformer.java
    incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/InputSource2SAX.java
    incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/Reader2SAX.java
    incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/String2SAX.java
    incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/test/java/org/apache/tuscany/databinding/impl/MediatorImplTestCase.java

Modified: incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/PushStyleTransformer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/PushStyleTransformer.java?rev=423143&r1=423142&r2=423143&view=diff
==============================================================================
--- incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/PushStyleTransformer.java
(original)
+++ incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/PushStyleTransformer.java
Tue Jul 18 10:26:49 2006
@@ -1,47 +0,0 @@
-/**
- *
- * Copyright 2006 The Apache Software Foundation or its licensors as applicable
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.tuscany.databinding;
-
-
-/**
- * A data pumper pushes data from its source into the sink
- * @param <S>
- * @param <R>
- */
-public interface PushStyleTransformer<S, R> {
-    /**
-     * @param source
-     * @param sink
-     * @param context
-     */
-    public void transform(S source, R sink, TransformationContext context);
-
-    /**
-     * @return
-     */
-    public Class<S> getSourceType();
-
-    /**
-     * @return
-     */
-    public Class<R> getSinkType();
-
-    /**
-     * @return
-     */
-    public int getWeight();
-}

Modified: incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/InputSource2SAX.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/InputSource2SAX.java?rev=423143&r1=423142&r2=423143&view=diff
==============================================================================
--- incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/InputSource2SAX.java
(original)
+++ incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/InputSource2SAX.java
Tue Jul 18 10:26:49 2006
@@ -32,6 +32,8 @@
     public void transform(InputSource source, ContentHandler target, TransformationContext
context) {
         try {
             XMLReader reader = XMLReaderFactory.createXMLReader();
+            reader.setFeature("http://xml.org/sax/features/namespaces", true);
+            reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
             reader.setContentHandler(target);
             reader.parse(source);
         } catch (Exception e) {

Modified: incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/Reader2SAX.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/Reader2SAX.java?rev=423143&r1=423142&r2=423143&view=diff
==============================================================================
--- incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/Reader2SAX.java
(original)
+++ incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/Reader2SAX.java
Tue Jul 18 10:26:49 2006
@@ -23,8 +23,6 @@
 import org.apache.tuscany.databinding.TransformationException;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
 
 /**
  * Transform XML string to SAX
@@ -33,9 +31,7 @@
 public class Reader2SAX implements PushTransformer<Reader, ContentHandler> {
     public void transform(Reader source, ContentHandler target, TransformationContext context)
{
         try {
-            XMLReader reader = XMLReaderFactory.createXMLReader();
-            reader.setContentHandler(target);
-            reader.parse(new InputSource(source));
+            new InputSource2SAX().transform(new InputSource(source), target, context);
         } catch (Exception e) {
             throw new TransformationException(e);
         }

Modified: incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/String2SAX.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/String2SAX.java?rev=423143&r1=423142&r2=423143&view=diff
==============================================================================
--- incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/String2SAX.java
(original)
+++ incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/main/java/org/apache/tuscany/databinding/trax/String2SAX.java
Tue Jul 18 10:26:49 2006
@@ -18,31 +18,29 @@
 
 import java.io.StringReader;
 
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.stream.StreamSource;
-
 import org.apache.tuscany.databinding.PushTransformer;
 import org.apache.tuscany.databinding.TransformationContext;
 import org.apache.tuscany.databinding.TransformationException;
 import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
 
 /**
  * Transform XML string to SAX
- *
+ * 
  */
 public class String2SAX implements PushTransformer<String, ContentHandler> {
-    private static final TransformerFactory factory = TransformerFactory.newInstance();
+    /*
+     * private static final TransformerFactory factory = TransformerFactory.newInstance();
+     * 
+     * public void transform(String source, ContentHandler target, TransformationContext
context) { try { javax.xml.transform.Transformer transformer =
+     * factory.newTransformer(); Source domSource = new StreamSource(new StringReader(source));
+     * 
+     * Result result = new SAXResult(target); transformer.transform(domSource, result); }
catch (Exception e) { throw new TransformationException(e); } }
+     */
 
     public void transform(String source, ContentHandler target, TransformationContext context)
{
         try {
-            javax.xml.transform.Transformer transformer = factory.newTransformer();
-            Source domSource = new StreamSource(new StringReader(source));
-           
-            Result result = new SAXResult(target);
-            transformer.transform(domSource, result);
+            new InputSource2SAX().transform(new InputSource(new StringReader(source)), target,
context);
         } catch (Exception e) {
             throw new TransformationException(e);
         }

Modified: incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/test/java/org/apache/tuscany/databinding/impl/MediatorImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/test/java/org/apache/tuscany/databinding/impl/MediatorImplTestCase.java?rev=423143&r1=423142&r2=423143&view=diff
==============================================================================
--- incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/test/java/org/apache/tuscany/databinding/impl/MediatorImplTestCase.java
(original)
+++ incubator/tuscany/sandbox/chianti/sca/databinding/databinding-framework/src/test/java/org/apache/tuscany/databinding/impl/MediatorImplTestCase.java
Tue Jul 18 10:26:49 2006
@@ -67,22 +67,18 @@
     }
 
     public void testTransform1() {
-/*
         Object node = mediator.mediate(IPO_XML, String.class, Node.class, null);
         Assert.assertTrue(node instanceof Document);
         Element root = ((Document) node).getDocumentElement();
         Assert.assertEquals(root.getNamespaceURI(), "http://www.example.com/IPO");
         Assert.assertEquals(root.getLocalName(), "purchaseOrder");
-*/
     }
 
     public void testTransform2() {
-/*
         Writer writer = new StringWriter();
         mediator.mediate(IPO_XML, writer, String.class, Writer.class, null);
         String str = writer.toString();
         Assert.assertTrue(str != null && str.indexOf("<shipDate>1999-12-05</shipDate>")
!= -1);
-*/
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message