You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2007/10/22 16:28:09 UTC
svn commit: r587110 - in /incubator/cxf/trunk/rt/javascript: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/cxf/ src/main/java/org/apache/cxf/javascript/
src/main/java/org/apache/cxf/javascript/se...
Author: bimargulies
Date: Mon Oct 22 07:28:08 2007
New Revision: 587110
URL: http://svn.apache.org/viewvc?rev=587110&view=rev
Log:
Check in the first glimmer of the Javascript client generator. The
purpose of this checkin is to get setup.eclipse to cooperate.
--This line, and those below, will be ignored--
A javascript
A javascript/src
A javascript/src/test
A javascript/src/test/java
A javascript/src/test/resources
A javascript/src/main
A javascript/src/main/java
A javascript/src/main/java/org
A javascript/src/main/java/org/apache
A javascript/src/main/java/org/apache/cxf
A javascript/src/main/java/org/apache/cxf/javascript
A javascript/src/main/java/org/apache/cxf/javascript/service
AM javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
A javascript/src/main/java/org/apache/cxf/javascript/types
AM javascript/src/main/java/org/apache/cxf/javascript/types/package-info.html
AM javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
AM javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
AM javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java
A javascript/src/main/resources
AM javascript/pom.xml
Added:
incubator/cxf/trunk/rt/javascript/
incubator/cxf/trunk/rt/javascript/pom.xml (with props)
incubator/cxf/trunk/rt/javascript/src/
incubator/cxf/trunk/rt/javascript/src/main/
incubator/cxf/trunk/rt/javascript/src/main/java/
incubator/cxf/trunk/rt/javascript/src/main/java/org/
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java (with props)
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java (with props)
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java (with props)
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java (with props)
incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/package-info.html (with props)
incubator/cxf/trunk/rt/javascript/src/main/resources/
incubator/cxf/trunk/rt/javascript/src/test/
incubator/cxf/trunk/rt/javascript/src/test/java/
incubator/cxf/trunk/rt/javascript/src/test/resources/
Added: incubator/cxf/trunk/rt/javascript/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/pom.xml?rev=587110&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/pom.xml (added)
+++ incubator/cxf/trunk/rt/javascript/pom.xml Mon Oct 22 07:28:08 2007
@@ -0,0 +1,154 @@
+<?xml version="1.0"?>
+<!--
+ 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 xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cxf-rt-javascript</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache CXF Runtime JavaScript Client Generator</name>
+ <url>http://cwiki.apache.org/confluence/display/CXF/Index</url>
+
+
+ <parent>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-parent</artifactId>
+ <version>2.1-incubator-SNAPSHOT</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-simple</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-local</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http-jetty</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>net.java.dev.stax-utils</groupId>
+ <artifactId>stax-utils</artifactId>
+ <version>20060502</version>
+ <exclusions>
+ <exclusion>
+ <groupId>com.bea.xml</groupId>
+ <artifactId>jsr173-ri</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ <version>1.1</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>dom4j</artifactId>
+ <groupId>dom4j</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>xmlParserAPIs</artifactId>
+ <groupId>xerces</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>xercesImpl</artifactId>
+ <groupId>xerces</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>xom</artifactId>
+ <groupId>xom</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${basedir}/src/main/generated</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Propchange: incubator/cxf/trunk/rt/javascript/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/javascript/pom.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/javascript/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/rt/javascript/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java?rev=587110&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java Mon Oct 22 07:28:08 2007
@@ -0,0 +1,96 @@
+/**
+ * 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.cxf.javascript;
+
+import java.util.Stack;
+
+/**
+ *
+ */
+public class JavascriptUtils {
+ private static final String NL = "\n";
+ private StringBuffer code;
+ private Stack<String> prefixStack;
+ private String xmlStringAccumulatorVariable;
+
+ public JavascriptUtils(StringBuffer code) {
+ this.code = code;
+ prefixStack = new Stack<String>();
+ prefixStack.push("");
+ }
+
+ public void startXmlStringAccumulator(String variableName) {
+ xmlStringAccumulatorVariable = variableName;
+ code.append(prefix());
+ code.append("var ");
+ code.append(variableName);
+ code.append(";" + NL);
+ }
+
+ public static String protectSingleQuotes(String value) {
+ return value.replaceAll("'", "\\'");
+ }
+
+ /**
+ * emit javascript to append a value to the accumulator.
+ * @param value
+ */
+ public void appendAppend(String value) {
+ code.append(prefix());
+ code.append(xmlStringAccumulatorVariable + " = " + xmlStringAccumulatorVariable + " + ");
+ code.append(value);
+ code.append(";" + NL);
+ }
+
+ private String prefix() {
+ return prefixStack.peek();
+ }
+
+ public void appendLine(String line) {
+ code.append(prefix());
+ code.append(line);
+ code.append(NL);
+ }
+
+ public void startIf(String test) {
+ code.append(prefix());
+ code.append("if (" + test + ") {" + NL);
+ prefixStack.push(prefix() + " ");
+ }
+
+ public void appendElse() {
+ prefixStack.pop();
+ code.append(prefix());
+ code.append("} else {" + NL);
+ prefixStack.push(prefix() + " ");
+ }
+
+ public void endBlock() {
+ prefixStack.pop();
+ code.append(prefix());
+ code.append("}" + NL);
+ }
+
+ public void startFor(String start, String test, String increment) {
+ code.append(prefix());
+ code.append("for (" + start + ";" + test + ";" + increment + ") {" + NL);
+ prefixStack.push(prefix() + " ");
+ }
+}
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java?rev=587110&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java Mon Oct 22 07:28:08 2007
@@ -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.
+ */
+package org.apache.cxf.javascript;
+
+/**
+ * This exception is thrown when the Javascript client generator hits a schema
+ * construct that it cannot handle.
+ */
+public class UnsupportedSchemaConstruct extends RuntimeException {
+
+ public UnsupportedSchemaConstruct() {
+ }
+
+ public UnsupportedSchemaConstruct(String explanation) {
+ super(explanation);
+ }
+
+ public UnsupportedSchemaConstruct(Throwable cause) {
+ super(cause);
+ }
+
+ public UnsupportedSchemaConstruct(String explanation, Throwable cause) {
+ super(explanation, cause);
+ }
+
+}
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java?rev=587110&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java Mon Oct 22 07:28:08 2007
@@ -0,0 +1,24 @@
+/**
+ * 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.cxf.javascript.service;
+
+public class ServiceJavascriptBuilder {
+
+}
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java?rev=587110&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java Mon Oct 22 07:28:08 2007
@@ -0,0 +1,161 @@
+/**
+ * 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.cxf.javascript.types;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.javascript.JavascriptUtils;
+import org.apache.cxf.javascript.UnsupportedSchemaConstruct;
+import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.wsdl.WSDLConstants;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaForm;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaType;
+
+/**
+ * Generate Javascript for a schema, and provide information needed for the service builder.
+ * As of this pass, there is no support for non-sequence types or for attribute mappings.
+ * @author bimargulies
+ */
+public class SchemaJavascriptBuilder {
+ private static final XmlSchemaForm QUALIFIED = new XmlSchemaForm(XmlSchemaForm.QUALIFIED);
+ private static final String XSI_NS_ATTR = WSDLConstants.NP_XMLNS + ":"
+ + WSDLConstants.NP_SCHEMA_XSI + "=" + WSDLConstants.NU_SCHEMA_XSI;
+ private static final String NIL_ATTRIBUTES = XSI_NS_ATTR + " xsi:nil='true'";
+ // The schema that we are operating upon.
+ private SchemaInfo schemaInfo;
+
+ public SchemaJavascriptBuilder(SchemaInfo schemaInfo) {
+ this.schemaInfo = schemaInfo;
+ }
+
+ public static boolean isParticleArray(XmlSchemaParticle particle) {
+ return particle.getMaxOccurs() > 1;
+ }
+
+ public static boolean isParticleOptional(XmlSchemaParticle particle) {
+ return particle.getMinOccurs() == 0 && particle.getMaxOccurs() == 1;
+ }
+
+ private String xmlElementString(XmlSchemaElement element) {
+ return getQNameString(element.getQName());
+ }
+
+ private String getQNameString(QName name) {
+ if (schemaInfo.getSchema().getElementFormDefault().equals(QUALIFIED)) {
+ return getPrefix(name.getNamespaceURI()) + ":" + name.getLocalPart();
+ } else {
+ return name.getLocalPart();
+ }
+
+ }
+
+ private String getPrefix(String string) {
+ return schemaInfo.getSchema().getNamespaceContext().getPrefix(string);
+ }
+
+ /**
+ * Build the serialization code for a complex type. At the top level, this operates on single items,
+ * so it does not pay attention to minOccurs and maxOccurs. However, as it works through the sequence,
+ * it manages optional elements and arrays.
+ * @param type
+ * @param elementPrefix
+ * @return
+ */
+ public void complexTypeSerializerBody(XmlSchemaComplexType type,
+ String elementPrefix,
+ StringBuffer code) {
+ JavascriptUtils utils = new JavascriptUtils(code);
+ XmlSchemaParticle particle = type.getParticle();
+ XmlSchemaSequence sequence = null;
+ try {
+ sequence = (XmlSchemaSequence) particle;
+ } catch (ClassCastException cce) {
+ throw new UnsupportedSchemaConstruct("Cannot build serializer for " + particle.toString());
+ }
+
+ utils.startXmlStringAccumulator("xml");
+
+ // XML Schema, please meet Iterable (not).
+ for (int i = 0; i < sequence.getItems().getCount(); i++) {
+ XmlSchemaElement elChild = (XmlSchemaElement)sequence.getItems().getItem(i);
+ XmlSchemaType elType = elChild.getSchemaType();
+ boolean nillable = elChild.isNillable();
+ if (elChild.isAbstract()) {
+ throw new UnsupportedSchemaConstruct("Abstract element " + elChild.toString());
+ }
+
+ // assume that no lunatic has created multiple elements that differ only by namespace.
+ // or, perhaps, detect that when generating the parser?
+ String elementName = elementPrefix + elChild.getName();
+ String elementXmlRef = xmlElementString(elChild);
+
+ // first question: optional?
+ if (isParticleOptional(elChild)) {
+ utils.startIf(elementName + " != null");
+ }
+
+ // nillable and optional would be very strange together.
+ // and nillable in the array case can't be right, can it?
+ if (nillable && !isParticleArray(elChild)) {
+ utils.startIf(elementName + " == null");
+ utils.appendAppend("<" + elementXmlRef + " " + NIL_ATTRIBUTES + "/>");
+ utils.appendElse();
+ }
+
+ if (isParticleArray(elChild)) {
+ utils.startFor("var ax = 0", "ax < " + elementName + ".length", "ax ++");
+ elementName = elementName + "[ax]";
+ // we need an extra level of 'nil' testing here. Or do we, depending on the type structure?
+ // Recode and fiddle appropriately.
+ utils.startIf(elementName + " == null");
+ utils.appendAppend("<" + elementXmlRef + " " + NIL_ATTRIBUTES + "/>");
+ utils.appendElse();
+ }
+
+ // now for the thing itself.
+ utils.appendAppend("<" + elementXmlRef + ">");
+ if (elType instanceof XmlSchemaComplexType) {
+ utils.appendAppend(elementName + ".serialize()");
+ } else {
+ // warning: this assumes that ordinary Javascript serialization is all we need.
+ // except for > ad all of that.
+ utils.appendAppend("cxf_xml_serialize_string(" + elementName + ")");
+ }
+ utils.appendAppend("</" + elementXmlRef + ">");
+
+ if (isParticleArray(elChild)) {
+ utils.endBlock(); // for the extra level of nil checking, which might be wrong.
+ utils.endBlock(); // for the for loop.
+ }
+
+ if (nillable && !isParticleArray(elChild)) {
+ utils.endBlock();
+ }
+
+ if (isParticleOptional(elChild)) {
+ utils.endBlock();
+ }
+ }
+ }
+}
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/package-info.html
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/package-info.html?rev=587110&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/package-info.html (added)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/package-info.html Mon Oct 22 07:28:08 2007
@@ -0,0 +1,10 @@
+<html>
+<body>
+<p>
+This package contains generators for Javascript related to XML schema types. For each complex type,
+the code generates a Javascript object and functions to serialize it to XML and to parse it from
+XML. This code operates on an entire schema at once. It does not build a separate object model
+at the type level.
+</p>
+</body>
+</html>
\ No newline at end of file
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/package-info.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/package-info.html
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/package-info.html
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/package-info.html
------------------------------------------------------------------------------
svn:mime-type = text/html