Author: gnodet
Date: Wed Sep 27 04:56:28 2006
New Revision: 450410
URL: http://svn.apache.org/viewvc?view=rev&rev=450410
Log:
SM-601: Xslt / XQuery SE
Added:
incubator/servicemix/trunk/servicemix-saxon/ (with props)
incubator/servicemix/trunk/servicemix-saxon/pom.xml
incubator/servicemix/trunk/servicemix-saxon/src/
incubator/servicemix/trunk/servicemix-saxon/src/main/
incubator/servicemix/trunk/servicemix-saxon/src/main/java/
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonBootstrap.java
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonComponent.java
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonEndpoint.java
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/XQueryEndpoint.java
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/XsltEndpoint.java
incubator/servicemix/trunk/servicemix-saxon/src/test/
incubator/servicemix/trunk/servicemix-saxon/src/test/java/
incubator/servicemix/trunk/servicemix-saxon/src/test/java/org/
incubator/servicemix/trunk/servicemix-saxon/src/test/java/org/apache/
incubator/servicemix/trunk/servicemix-saxon/src/test/java/org/apache/servicemix/
incubator/servicemix/trunk/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/
incubator/servicemix/trunk/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/SaxonComponentTest.java
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/books.xml
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/log4j-tests.properties
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/log4j.properties
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/query.xq
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/spring.xml
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/transform.xsl
Propchange: incubator/servicemix/trunk/servicemix-saxon/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Sep 27 04:56:28 2006
@@ -0,0 +1,3 @@
+.classpath
+.project
+target
Added: incubator/servicemix/trunk/servicemix-saxon/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/pom.xml?view=auto&rev=450410
==============================================================================
--- incubator/servicemix/trunk/servicemix-saxon/pom.xml (added)
+++ incubator/servicemix/trunk/servicemix-saxon/pom.xml Wed Sep 27 04:56:28 2006
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix</artifactId>
+ <version>3.1-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>servicemix-saxon</artifactId>
+ <packaging>jbi-component</packaging>
+ <name>ServiceMix :: Saxon Service Engine</name>
+ <description>An XSLT 2.0 / XQuery Service Engine</description>
+
+ <properties>
+ <saxon-version>8.7</saxon-version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-shared</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix</groupId>
+ <artifactId>servicemix-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon</artifactId>
+ <version>${saxon-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon-dom</artifactId>
+ <version>${saxon-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.saxon</groupId>
+ <artifactId>saxon-sql</artifactId>
+ <version>${saxon-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>jbi-maven-plugin</artifactId>
+ <version>${servicemix-version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <type>service-engine</type>
+ <bootstrap>org.apache.servicemix.saxon.SaxonBootstrap</bootstrap>
+ <component>org.apache.servicemix.saxon.SaxonComponent</component>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>maven-xbean-plugin</artifactId>
+ <version>${xbean-version}</version>
+ <executions>
+ <execution>
+ <configuration>
+ <namespace>http://org.apache.servicemix/saxon/1.0</namespace>
+ </configuration>
+ <goals>
+ <goal>mapping</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added:
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonBootstrap.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonBootstrap.java?view=auto&rev=450410
==============================================================================
---
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonBootstrap.java
(added)
+++
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonBootstrap.java
Wed Sep 27 04:56:28 2006
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.servicemix.saxon;
+
+import javax.jbi.JBIException;
+import javax.jbi.component.Bootstrap;
+import javax.jbi.component.InstallationContext;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * Bootstrap class.
+ * This class is usefull to perform tasks at installation / uninstallation
time
+ */
+public class SaxonBootstrap implements Bootstrap
+{
+
+ protected InstallationContext context;
+ protected ObjectName mbeanName;
+
+ public SaxonBootstrap() {
+ }
+
+ public ObjectName getExtensionMBeanName() {
+ return mbeanName;
+ }
+
+ protected Object getExtensionMBean() throws Exception {
+ return null;
+ }
+
+ protected ObjectName createExtensionMBeanName() throws Exception {
+ return
this.context.getContext().getMBeanNames().createCustomComponentMBeanName("bootstrap");
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.jbi.component.Bootstrap#init(javax.jbi.component.InstallationContext)
+ */
+ public void init(InstallationContext installContext) throws JBIException {
+ try {
+ this.context = installContext;
+ doInit();
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling init", e);
+ }
+ }
+
+ protected void doInit() throws Exception {
+ Object mbean = getExtensionMBean();
+ if (mbean != null) {
+ this.mbeanName = createExtensionMBeanName();
+ MBeanServer server = this.context.getContext().getMBeanServer();
+ if (server == null) {
+ throw new JBIException("null mBeanServer");
+ }
+ if (server.isRegistered(this.mbeanName)) {
+ server.unregisterMBean(this.mbeanName);
+ }
+ server.registerMBean(mbean, this.mbeanName);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#cleanUp()
+ */
+ public void cleanUp() throws JBIException {
+ try {
+ doCleanUp();
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling cleanUp", e);
+ }
+ }
+
+ protected void doCleanUp() throws Exception {
+ if (this.mbeanName != null) {
+ MBeanServer server = this.context.getContext().getMBeanServer();
+ if (server == null) {
+ throw new JBIException("null mBeanServer");
+ }
+ if (server.isRegistered(this.mbeanName)) {
+ server.unregisterMBean(this.mbeanName);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#onInstall()
+ */
+ public void onInstall() throws JBIException {
+ try {
+ doOnInstall();
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling onInstall", e);
+ }
+ }
+
+ protected void doOnInstall() throws Exception {
+ }
+
+ /* (non-Javadoc)
+ * @see javax.jbi.component.Bootstrap#onUninstall()
+ */
+ public void onUninstall() throws JBIException {
+ try {
+ doOnUninstall();
+ } catch (JBIException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JBIException("Error calling onUninstall", e);
+ }
+ }
+
+ protected void doOnUninstall() throws Exception {
+ }
+
+}
Added:
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonComponent.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonComponent.java?view=auto&rev=450410
==============================================================================
---
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonComponent.java
(added)
+++
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonComponent.java
Wed Sep 27 04:56:28 2006
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.servicemix.saxon;
+
+import org.apache.servicemix.common.BaseComponent;
+import org.apache.servicemix.common.BaseLifeCycle;
+import org.apache.servicemix.common.BaseServiceUnitManager;
+import org.apache.servicemix.common.Deployer;
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.common.xbean.BaseXBeanDeployer;
+import org.apache.servicemix.common.xbean.XBeanServiceUnit;
+
+/**
+ *
+ * @org.apache.xbean.XBean element="component"
+ * description="XSLT component"
+ * @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
+ */
+public class SaxonComponent extends BaseComponent {
+
+ private SaxonEndpoint[] endpoints;
+
+ /**
+ * @return Returns the endpoints.
+ */
+ public SaxonEndpoint[] getEndpoints() {
+ return endpoints;
+ }
+
+ /**
+ * @param endpoints The endpoints to set.
+ */
+ public void setEndpoints(SaxonEndpoint[] endpoints) {
+ this.endpoints = endpoints;
+ }
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseComponent#createLifeCycle()
+ */
+ protected BaseLifeCycle createLifeCycle() {
+ return new LifeCycle();
+ }
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseComponent#createServiceUnitManager()
+ */
+ public BaseServiceUnitManager createServiceUnitManager() {
+ Class[] classes = new Class[] { SaxonEndpoint.class };
+ Deployer[] deployers = new Deployer[] { new BaseXBeanDeployer(this,
classes) };
+ return new BaseServiceUnitManager(this, deployers);
+ }
+
+ /**
+ * @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
+ */
+ public class LifeCycle extends BaseLifeCycle {
+
+ protected ServiceUnit su;
+
+ public LifeCycle() {
+ super(SaxonComponent.this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseLifeCycle#doInit()
+ */
+ protected void doInit() throws Exception {
+ super.doInit();
+ if (endpoints != null && endpoints.length > 0) {
+ su = new XBeanServiceUnit();
+ su.setComponent(SaxonComponent.this);
+ for (int i = 0; i < endpoints.length; i++) {
+ endpoints[i].setServiceUnit(su);
+ endpoints[i].validate();
+ su.addEndpoint(endpoints[i]);
+ }
+ getRegistry().registerServiceUnit(su);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseLifeCycle#doStart()
+ */
+ protected void doStart() throws Exception {
+ super.doStart();
+ if (su != null) {
+ su.start();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseLifeCycle#doStop()
+ */
+ protected void doStop() throws Exception {
+ if (su != null) {
+ su.stop();
+ }
+ super.doStop();
+ }
+
+ /* (non-Javadoc)
+ * @see org.servicemix.common.BaseLifeCycle#doShutDown()
+ */
+ protected void doShutDown() throws Exception {
+ if (su != null) {
+ su.shutDown();
+ }
+ super.doShutDown();
+ }
+ }
+
+}
Added:
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonEndpoint.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonEndpoint.java?view=auto&rev=450410
==============================================================================
---
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonEndpoint.java
(added)
+++
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/SaxonEndpoint.java
Wed Sep 27 04:56:28 2006
@@ -0,0 +1,163 @@
+package org.apache.servicemix.saxon;
+
+import java.util.Iterator;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+
+import net.sf.saxon.Configuration;
+
+import org.apache.servicemix.common.ProviderEndpoint;
+
+public abstract class SaxonEndpoint extends ProviderEndpoint {
+
+ public static String RESULT_BYTES = "bytes";
+ public static String RESULT_STRING = "string";
+ public static String RESULT_DOM = "dom";
+
+ private Configuration configuration;
+ private boolean copyProperties = true;
+ private boolean copyAttachments = true;
+ private boolean copySubject = true;
+ private String result = RESULT_DOM;
+
+ /**
+ * @return the result
+ */
+ public String getResult() {
+ return result;
+ }
+
+ /**
+ * @param result the result to set
+ */
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+ /**
+ * @return the configuration
+ */
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ /**
+ * @param configuration the configuration to set
+ */
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ /**
+ * @return the copyAttachments
+ */
+ public boolean isCopyAttachments() {
+ return copyAttachments;
+ }
+
+ /**
+ * @param copyAttachments the copyAttachments to set
+ */
+ public void setCopyAttachments(boolean copyAttachments) {
+ this.copyAttachments = copyAttachments;
+ }
+
+ /**
+ * @return the copyProperties
+ */
+ public boolean isCopyProperties() {
+ return copyProperties;
+ }
+
+ /**
+ * @param copyProperties the copyProperties to set
+ */
+ public void setCopyProperties(boolean copyProperties) {
+ this.copyProperties = copyProperties;
+ }
+
+ /**
+ * @return the copySubject
+ */
+ public boolean isCopySubject() {
+ return copySubject;
+ }
+
+ /**
+ * @param copySubject the copySubject to set
+ */
+ public void setCopySubject(boolean copySubject) {
+ this.copySubject = copySubject;
+ }
+
+ // Interface methods
+ //
-------------------------------------------------------------------------
+
+ public void process(MessageExchange exchange) throws Exception {
+ // The component acts as a provider, this means that another component
has requested our service
+ // As this exchange is active, this is either an in or a fault (out
are send by this component)
+ if (exchange.getRole() == MessageExchange.Role.PROVIDER) {
+ // Exchange is finished
+ if (exchange.getStatus() == ExchangeStatus.DONE) {
+ return;
+ // Exchange has been aborted with an exception
+ } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
+ return;
+ // Exchange is active
+ } else {
+ // Check here if the mep is supported by this component
+ if (exchange instanceof InOut == false) {
+ throw new UnsupportedOperationException("Unsupported MEP: "
+ exchange.getPattern());
+ }
+ // In message
+ if (exchange.getMessage("in") != null) {
+ NormalizedMessage in = exchange.getMessage("in");
+ // Transform the content and send it back
+ NormalizedMessage out = exchange.createMessage();
+ copyPropertiesAndAttachments(in, out);
+ transform(exchange, in, out);
+ exchange.setMessage(out, "out");
+ send(exchange);
+ // Fault message
+ } else if (exchange.getFault() != null) {
+ done(exchange);
+ // This is not compliant with the default MEPs
+ } else {
+ throw new IllegalStateException("Provider exchange is
ACTIVE, but no in or fault is provided");
+ }
+ }
+ // Unsupported role: this should never happen has we never create
exchanges
+ } else {
+ throw new IllegalStateException("Unsupported role: " +
exchange.getRole());
+ }
+ }
+
+ // Implementation methods
+ //
-------------------------------------------------------------------------
+ /**
+ * If enabled the properties and attachments are copied to the destination
message
+ */
+ protected void copyPropertiesAndAttachments(NormalizedMessage source,
NormalizedMessage dest) throws Exception {
+ if (isCopyProperties()) {
+ for (Iterator it = source.getPropertyNames().iterator();
it.hasNext();) {
+ String name = (String) it.next();
+ dest.setProperty(name, source.getProperty(name));
+ }
+ }
+ if (isCopyAttachments()) {
+ for (Iterator it = source.getAttachmentNames().iterator();
it.hasNext();) {
+ String name = (String) it.next();
+ dest.addAttachment(name, source.getAttachment(name));
+ }
+ }
+ if (isCopySubject()) {
+ dest.setSecuritySubject(source.getSecuritySubject());
+ }
+ }
+
+ protected abstract void transform(MessageExchange exchange,
NormalizedMessage in, NormalizedMessage out) throws Exception;
+
+}
Added:
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/XQueryEndpoint.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/XQueryEndpoint.java?view=auto&rev=450410
==============================================================================
---
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/XQueryEndpoint.java
(added)
+++
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/XQueryEndpoint.java
Wed Sep 27 04:56:28 2006
@@ -0,0 +1,160 @@
+package org.apache.servicemix.saxon;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringWriter;
+import java.util.Iterator;
+import java.util.Properties;
+
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.Result;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import net.sf.saxon.Configuration;
+import net.sf.saxon.om.DocumentInfo;
+import net.sf.saxon.query.DynamicQueryContext;
+import net.sf.saxon.query.StaticQueryContext;
+import net.sf.saxon.query.XQueryExpression;
+
+import org.apache.servicemix.jbi.jaxp.BytesSource;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.springframework.core.io.Resource;
+
+/**
+ * @org.apache.xbean.XBean element="xquery"
+ */
+public class XQueryEndpoint extends SaxonEndpoint {
+
+ private Resource resource;
+ private String query;
+ private XQueryExpression exp;
+ private StaticQueryContext staticEnv;
+ private Properties outputProperties;
+
+ // Properties
+ //
-------------------------------------------------------------------------
+
+ /**
+ * @return the outputProperties
+ */
+ public Properties getOutputProperties() {
+ return outputProperties;
+ }
+
+ /**
+ * @param outputProperties the outputProperties to set
+ */
+ public void setOutputProperties(Properties outputProperties) {
+ this.outputProperties = outputProperties;
+ }
+
+ /**
+ * @return the query
+ */
+ public String getQuery() {
+ return query;
+ }
+
+ /**
+ * @param query the query to set
+ * @org.apache.xbean.Flat
+ */
+ public void setQuery(String query) {
+ this.query = query;
+ }
+
+ /**
+ * @return the resource
+ */
+ public Resource getResource() {
+ return resource;
+ }
+
+ /**
+ * @param resource the resource to set
+ */
+ public void setResource(Resource resource) {
+ this.resource = resource;
+ }
+
+ // Interface methods
+ //
-------------------------------------------------------------------------
+
+ public void start() throws Exception {
+ Configuration config = getConfiguration();
+ if (config == null) {
+ config = new Configuration();
+ }
+ config.setHostLanguage(Configuration.XQUERY);
+ setConfiguration(config);
+ staticEnv = new StaticQueryContext(config);
+ if (query == null || query.trim().length() == 0) {
+ exp = staticEnv.compileQuery(resource.getInputStream(), null);
+ } else {
+ exp = staticEnv.compileQuery(query);
+ }
+ staticEnv = exp.getStaticContext();
+ }
+
+ public void validate() throws DeploymentException {
+ if ((query == null || query.trim().length() == 0) && resource == null)
{
+ throw new DeploymentException("query or resource should be
specified");
+ }
+ }
+
+ // Implementation methods
+ //
-------------------------------------------------------------------------
+
+ protected void transform(MessageExchange exchange, NormalizedMessage in,
NormalizedMessage out) throws Exception {
+ XQueryExpression expression = createQuery(exchange, in);
+ queryContent(expression, exchange, in, out);
+ }
+
+ protected void queryContent(XQueryExpression expression, MessageExchange
exchange, NormalizedMessage in, NormalizedMessage out) throws Exception {
+ Configuration config = getConfiguration();
+ DynamicQueryContext dynamicEnv = new DynamicQueryContext(config);
+ DocumentInfo doc = staticEnv.buildDocument(in.getContent());
+ dynamicEnv.setContextItem(doc);
+ configureQuery(dynamicEnv, exchange, in);
+ if (RESULT_BYTES.equalsIgnoreCase(getResult())) {
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ Result result = new StreamResult(buffer);
+ expression.run(dynamicEnv, result, outputProperties);
+ out.setContent(new BytesSource(buffer.toByteArray()));
+ }
+ else if (RESULT_STRING.equalsIgnoreCase(getResult())) {
+ StringWriter buffer = new StringWriter();
+ Result result = new StreamResult(buffer);
+ expression.run(dynamicEnv, result, outputProperties);
+ out.setContent(new StringSource(buffer.toString()));
+ } else {
+ DOMResult result = new DOMResult();
+ expression.run(dynamicEnv, result, outputProperties);
+ out.setContent(new DOMSource(result.getNode()));
+ }
+ }
+
+ protected void configureQuery(DynamicQueryContext dynamicEnv,
MessageExchange exchange, NormalizedMessage in) throws Exception {
+ for (Iterator iter = exchange.getPropertyNames().iterator();
iter.hasNext();) {
+ String name = (String) iter.next();
+ Object value = exchange.getProperty(name);
+ dynamicEnv.setParameter(name, value);
+ }
+ for (Iterator iter = in.getPropertyNames().iterator();
iter.hasNext();) {
+ String name = (String) iter.next();
+ Object value = in.getProperty(name);
+ dynamicEnv.setParameter(name, value);
+ }
+ dynamicEnv.setParameter("exchange", exchange);
+ dynamicEnv.setParameter("in", in);
+ dynamicEnv.setParameter("component", this);
+ }
+
+ protected XQueryExpression createQuery(MessageExchange exchange,
NormalizedMessage in) throws Exception {
+ return exp;
+ }
+
+}
Added:
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/XsltEndpoint.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/XsltEndpoint.java?view=auto&rev=450410
==============================================================================
---
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/XsltEndpoint.java
(added)
+++
incubator/servicemix/trunk/servicemix-saxon/src/main/java/org/apache/servicemix/saxon/XsltEndpoint.java
Wed Sep 27 04:56:28 2006
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.servicemix.saxon;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.Iterator;
+
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import net.sf.saxon.TransformerFactoryImpl;
+
+import org.apache.servicemix.jbi.jaxp.BytesSource;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.springframework.core.io.Resource;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * @org.apache.xbean.XBean element="xslt"
+ */
+public class XsltEndpoint extends SaxonEndpoint {
+
+ private TransformerFactory transformerFactory;
+ private Source xsltSource;
+ private Resource resource;
+ private Templates templates;
+ public TransformerFactory getTransformerFactory() {
+ if (transformerFactory == null) {
+ transformerFactory = createTransformerFactory();
+ }
+ return transformerFactory;
+ }
+
+ public void setTransformerFactory(TransformerFactory transformerFactory) {
+ this.transformerFactory = transformerFactory;
+ }
+
+ public Resource getResource() {
+ return resource;
+ }
+
+ public void setResource(Resource xsltResource) {
+ this.resource = xsltResource;
+ }
+
+ public void validate() throws DeploymentException {
+ if (xsltSource == null && resource == null) {
+ throw new DeploymentException("xsltSrouce or resource must be
specified");
+ }
+ }
+
+ // Implementation methods
+ //
-------------------------------------------------------------------------
+
+ protected void transform(MessageExchange exchange, NormalizedMessage in,
NormalizedMessage out) throws Exception {
+ Transformer transformer = createTransformer(exchange, in);
+ configureTransformer(transformer, exchange, in);
+ transformContent(transformer, exchange, in, out);
+ }
+
+ protected void transformContent(Transformer transformer, MessageExchange
exchange, NormalizedMessage in, NormalizedMessage out) throws Exception {
+ Source src = in.getContent();
+ if (src instanceof DOMSource ||
RESULT_DOM.equalsIgnoreCase(getResult())) {
+ Node n = ((DOMSource) src).getNode();
+ if (n instanceof Document == false) {
+ Document doc =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ doc.appendChild(doc.importNode(n, true));
+ src = new DOMSource(doc);
+ }
+ }
+ if (RESULT_BYTES.equalsIgnoreCase(getResult())) {
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ Result result = new StreamResult(buffer);
+ transformer.transform(src, result);
+ out.setContent(new BytesSource(buffer.toByteArray()));
+ }
+ else if (RESULT_STRING.equalsIgnoreCase(getResult())) {
+ StringWriter buffer = new StringWriter();
+ Result result = new StreamResult(buffer);
+ transformer.transform(src, result);
+ out.setContent(new StringSource(buffer.toString()));
+ } else {
+ DOMResult result = new DOMResult();
+ transformer.transform(src, result);
+ out.setContent(new DOMSource(result.getNode()));
+ }
+ }
+
+ protected Source getXsltSource() throws Exception {
+ if (xsltSource == null) {
+ xsltSource = createXsltSource();
+ }
+ return xsltSource;
+ }
+
+ protected Source createXsltSource() throws Exception {
+ if (resource != null) {
+ URL url = resource.getURL();
+ DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(resource.getInputStream(), url !=
null ? url.toExternalForm() : null);
+ return new DOMSource(doc);
+ }
+ return null;
+ }
+
+ public Templates getTemplates() throws Exception {
+ if (templates == null) {
+ templates = createTemplates();
+ }
+ return templates;
+ }
+
+ /**
+ * Factory method to create a new transformer instance
+ */
+ protected Templates createTemplates() throws Exception {
+ Source source = getXsltSource();
+ return getTransformerFactory().newTemplates(source);
+ }
+
+ /**
+ * Factory method to create a new transformer instance
+ */
+ protected Transformer createTransformer(MessageExchange exchange,
NormalizedMessage in) throws Exception {
+ Source source = getXsltSource();
+ if (source == null) {
+ return getTransformerFactory().newTransformer();
+ }
+ else {
+ return getTemplates().newTransformer();
+ }
+ }
+
+ protected TransformerFactory createTransformerFactory() {
+ if (getConfiguration() != null) {
+ return new TransformerFactoryImpl(getConfiguration());
+ } else {
+ return new TransformerFactoryImpl();
+ }
+ }
+
+ /**
+ * A hook to allow the transformer to be configured from the current
+ * exchange and inbound message
+ */
+ protected void configureTransformer(Transformer transformer,
MessageExchange exchange, NormalizedMessage in) {
+ for (Iterator iter = exchange.getPropertyNames().iterator();
iter.hasNext();) {
+ String name = (String) iter.next();
+ Object value = exchange.getProperty(name);
+ transformer.setParameter(name, value);
+ }
+ for (Iterator iter = in.getPropertyNames().iterator();
iter.hasNext();) {
+ String name = (String) iter.next();
+ Object value = in.getProperty(name);
+ transformer.setParameter(name, value);
+ }
+ transformer.setParameter("exchange", exchange);
+ transformer.setParameter("in", in);
+ transformer.setParameter("component", this);
+ }
+
+}
Added:
incubator/servicemix/trunk/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/SaxonComponentTest.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/SaxonComponentTest.java?view=auto&rev=450410
==============================================================================
---
incubator/servicemix/trunk/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/SaxonComponentTest.java
(added)
+++
incubator/servicemix/trunk/servicemix-saxon/src/test/java/org/apache/servicemix/saxon/SaxonComponentTest.java
Wed Sep 27 04:56:28 2006
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.servicemix.saxon;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.util.DOMUtil;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.w3c.dom.Element;
+
+public class SaxonComponentTest extends SpringTestSupport {
+
+
+
+ public void testXslt() throws Exception {
+ DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("urn:test", "xslt"));
+ me.getInMessage().setContent(new
StreamSource(getClass().getResourceAsStream("/books.xml")));
+ client.sendSync(me);
+ if (me.getStatus() == ExchangeStatus.ERROR) {
+ if (me.getError() != null) {
+ throw me.getError();
+ } else {
+ fail("Received ERROR status");
+ }
+ } else if (me.getFault() != null) {
+ fail("Received fault: " + new
SourceTransformer().toString(me.getFault().getContent()));
+ }
+
System.err.println(transformer.toString(me.getOutMessage().getContent()));
+ Element el = transformer.toDOMElement(me.getOutMessage());
+ assertEquals("2005", textValueOfXPath(el,
"/transformed/bookstore/book[1]/year"));
+ client.done(me);
+ }
+
+ public void testXsltWithElement() throws Exception {
+ DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("urn:test", "xslt"));
+ Element e = transformer.toDOMElement(new
StreamSource(getClass().getResourceAsStream("/books.xml")));
+ e = DOMUtil.getFirstChildElement(e);
+ me.getInMessage().setContent(new DOMSource(e));
+ client.sendSync(me);
+ if (me.getStatus() == ExchangeStatus.ERROR) {
+ if (me.getError() != null) {
+ throw me.getError();
+ } else {
+ fail("Received ERROR status");
+ }
+ } else if (me.getFault() != null) {
+ fail("Received fault: " + new
SourceTransformer().toString(me.getFault().getContent()));
+ }
+
System.err.println(transformer.toString(me.getOutMessage().getContent()));
+ Element el = transformer.toDOMElement(me.getOutMessage());
+ assertEquals("2005", textValueOfXPath(el, "/transformed/book/year"));
+ client.done(me);
+ }
+
+ public void testXQuery() throws Exception {
+ DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("urn:test", "xquery"));
+ me.getInMessage().setContent(new
StreamSource(getClass().getResourceAsStream("/books.xml")));
+ client.sendSync(me);
+ if (me.getStatus() == ExchangeStatus.ERROR) {
+ if (me.getError() != null) {
+ throw me.getError();
+ } else {
+ fail("Received ERROR status");
+ }
+ } else if (me.getFault() != null) {
+ fail("Received fault: " + new
SourceTransformer().toString(me.getFault().getContent()));
+ }
+
System.err.println(transformer.toString(me.getOutMessage().getContent()));
+ Element el = transformer.toDOMElement(me.getOutMessage());
+ assertEquals("XQuery Kick Start", textValueOfXPath(el,
"/titles/title[1]"));
+ client.done(me);
+ }
+
+ public void testXQueryInline() throws Exception {
+ DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("urn:test", "xquery-inline"));
+ me.getInMessage().setContent(new
StreamSource(getClass().getResourceAsStream("/books.xml")));
+ client.sendSync(me);
+ if (me.getStatus() == ExchangeStatus.ERROR) {
+ if (me.getError() != null) {
+ throw me.getError();
+ } else {
+ fail("Received ERROR status");
+ }
+ } else if (me.getFault() != null) {
+ fail("Received fault: " + new
SourceTransformer().toString(me.getFault().getContent()));
+ }
+
System.err.println(transformer.toString(me.getOutMessage().getContent()));
+ Element el = transformer.toDOMElement(me.getOutMessage());
+ assertEquals("XQuery Kick Start", textValueOfXPath(el,
"/titles/title[1]"));
+ client.done(me);
+ }
+
+ protected AbstractXmlApplicationContext createBeanFactory() {
+ return new ClassPathXmlApplicationContext("spring.xml");
+ }
+
+}
Added: incubator/servicemix/trunk/servicemix-saxon/src/test/resources/books.xml
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/test/resources/books.xml?view=auto&rev=450410
==============================================================================
--- incubator/servicemix/trunk/servicemix-saxon/src/test/resources/books.xml
(added)
+++ incubator/servicemix/trunk/servicemix-saxon/src/test/resources/books.xml
Wed Sep 27 04:56:28 2006
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<bookstore>
+
+ <book category="COOKING">
+ <title lang="en">Everyday Italian</title>
+ <author>Giada De Laurentiis</author>
+ <year>2005</year>
+ <price>30.00</price>
+ </book>
+
+ <book category="CHILDREN">
+ <title lang="en">Harry Potter</title>
+ <author>J K. Rowling</author>
+ <year>2005</year>
+ <price>29.99</price>
+ </book>
+
+ <book category="WEB">
+ <title lang="en">XQuery Kick Start</title>
+ <author>James McGovern</author>
+ <author>Per Bothner</author>
+ <author>Kurt Cagle</author>
+ <author>James Linn</author>
+ <author>Vaidyanathan Nagarajan</author>
+ <year>2003</year>
+ <price>49.99</price>
+ </book>
+
+ <book category="WEB">
+ <title lang="en">Learning XML</title>
+ <author>Erik T. Ray</author>
+ <year>2003</year>
+ <price>39.95</price>
+ </book>
+
+</bookstore>
Added:
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/log4j-tests.properties
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/test/resources/log4j-tests.properties?view=auto&rev=450410
==============================================================================
---
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/log4j-tests.properties
(added)
+++
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/log4j-tests.properties
Wed Sep 27 04:56:28 2006
@@ -0,0 +1,41 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+#
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, out
+
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+log4j.logger.org.apache.activemq.store.journal=INFO
+log4j.logger.org.activeio.journal=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1}
- %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} -
%m%n
+log4j.appender.out.file=target/servicemix-test.log
+log4j.appender.out.append=true
Added:
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/log4j.properties
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/test/resources/log4j.properties?view=auto&rev=450410
==============================================================================
---
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/log4j.properties
(added)
+++
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/log4j.properties
Wed Sep 27 04:56:28 2006
@@ -0,0 +1,42 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+#
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=DEBUG, stdout
+
+log4j.logger.org.springframework=INFO
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+log4j.logger.org.apache.activemq.store.journal=INFO
+log4j.logger.org.activeio.journal=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1}
- %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} -
%m%n
+log4j.appender.out.file=target/servicemix-test.log
+log4j.appender.out.append=true
Added: incubator/servicemix/trunk/servicemix-saxon/src/test/resources/query.xq
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/test/resources/query.xq?view=auto&rev=450410
==============================================================================
--- incubator/servicemix/trunk/servicemix-saxon/src/test/resources/query.xq
(added)
+++ incubator/servicemix/trunk/servicemix-saxon/src/test/resources/query.xq Wed
Sep 27 04:56:28 2006
@@ -0,0 +1,7 @@
+<titles>
+{
+ for $x in /bookstore/book
+ where $x/price > 30
+ return $x/title
+}
+</titles>
Added: incubator/servicemix/trunk/servicemix-saxon/src/test/resources/spring.xml
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/test/resources/spring.xml?view=auto&rev=450410
==============================================================================
--- incubator/servicemix/trunk/servicemix-saxon/src/test/resources/spring.xml
(added)
+++ incubator/servicemix/trunk/servicemix-saxon/src/test/resources/spring.xml
Wed Sep 27 04:56:28 2006
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+ xmlns:saxon="http://org.apache.servicemix/saxon/1.0"
+ xmlns:test="urn:test">
+
+ <sm:container id="jbi" embedded="true" createMBeanServer="false">
+
+ <sm:activationSpecs>
+
+ <sm:activationSpec>
+ <sm:component>
+ <saxon:component>
+ <saxon:endpoints>
+
+ <saxon:xslt service="test:xslt" endpoint="endpoint"
+ resource="classpath:transform.xsl" />
+
+ <saxon:xquery service="test:xquery" endpoint="endpoint"
+ resource="classpath:query.xq" />
+
+ <saxon:xquery service="test:xquery-inline" endpoint="endpoint">
+ <!-- CDATA are not supported currently -->
+ <saxon:query>
+ <titles>
+ {
+ for $x in /bookstore/book
+ where $x/price > 30
+ return $x/title
+ }
+ </titles>
+ </saxon:query>
+ </saxon:xquery>
+
+ </saxon:endpoints>
+ </saxon:component>
+ </sm:component>
+ </sm:activationSpec>
+
+ </sm:activationSpecs>
+ </sm:container>
+
+</beans>
Added:
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/transform.xsl
URL:
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-saxon/src/test/resources/transform.xsl?view=auto&rev=450410
==============================================================================
---
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/transform.xsl
(added)
+++
incubator/servicemix/trunk/servicemix-saxon/src/test/resources/transform.xsl
Wed Sep 27 04:56:28 2006
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+
+-->
+<xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
+ version='1.0'>
+
+ <xsl:output method="xml" indent="yes" encoding="ISO-8859-1"/>
+
+ <xsl:template match="/">
+ <transformed>
+ <xsl:copy>
+ <xsl:copy-of select="attribute::*"/>
+ <xsl:apply-templates/>
+ </xsl:copy>
+ </transformed>
+ </xsl:template>
+
+ <xsl:template match="node() | @*">
+ <xsl:copy>
+ <xsl:apply-templates select="node() | @*"/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>