xsddoc/src/net/sf/xframe/xsddoc Main.java,1.20,1.21 Processor.java,1.25,1.26
Kurt Riede <[email protected]>
| Newsgroups | gmane.text.xml.xframe.xsddoc.devel |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3194/src/net/sf/xframe/xsddoc
Modified Files:
Main.java Processor.java
Log Message:
improved support for nested components: use seperate pages for nested element declarations
Index: Main.java
===================================================================
RCS file: /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc/Main.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** Main.java 30 Aug 2004 07:03:54 -0000 1.20
--- Main.java 3 Sep 2004 08:04:24 -0000 1.21
***************
*** 126,137 ****
} catch (Error e) {
System.out.println(e.getLocalizedMessage());
! if (processor.isDebug()) {
! System.out.println(ExceptionUtil.printStackTrace(e));
! }
} catch (RuntimeException e) {
System.out.println(e.getLocalizedMessage());
! if (processor.isDebug()) {
! System.out.println(ExceptionUtil.printStackTrace(e));
! }
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
--- 126,133 ----
} catch (Error e) {
System.out.println(e.getLocalizedMessage());
! System.out.println(ExceptionUtil.printStackTrace(e));
} catch (RuntimeException e) {
System.out.println(e.getLocalizedMessage());
! System.out.println(ExceptionUtil.printStackTrace(e));
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
Index: Processor.java
===================================================================
RCS file: /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc/Processor.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** Processor.java 30 Aug 2004 07:16:10 -0000 1.25
--- Processor.java 3 Sep 2004 08:04:24 -0000 1.26
***************
*** 69,74 ****
////////////////////////////////////////////////
/** Namespace-URI of namespace of W3C-XML-Namespace. */
! public static final String HTTP_WWW_W3_ORG_2000_XMLNS = "http://www.w3.org/2000/xmlns/";
/** Attribute name: targetNamespace. */
--- 69,83 ----
////////////////////////////////////////////////
+ /** Name of xsddoc-id attribute to indicate a nested component. */
+ private static final String XSDDOCID_ATTR = "xsddocid";
+
+ /** Unique prefix for xsddoc attributes. */
+ public static final String XSDDOC_PREFIX = "net.sf.xframe.xsddoc";
+
/** Namespace-URI of namespace of W3C-XML-Namespace. */
! public static final String NAMESPACE_NAMESPACE = "http://www.w3.org/2000/xmlns/";
!
! /** Namespace-URI of namespace of xsddoc. */
! public static final String XSDDOC_NAMESPACE = "http://xframe.sf.net/xsddoc/doc";
/** Attribute name: targetNamespace. */
***************
*** 547,551 ****
final Node component = components.item(i);
if (component.getNodeType() == Node.ELEMENT_NODE) {
! processComponent(schema, schemaLocation, component, "");
}
}
--- 556,560 ----
final Node component = components.item(i);
if (component.getNodeType() == Node.ELEMENT_NODE) {
! processComponent(schema, schemaLocation, component, component, "");
}
}
***************
*** 557,560 ****
--- 566,571 ----
* @param schema root Node of DOM tree of current schema
* @param schemaLocation location of current schema
+ * @param rootComponent root component (must be equal to component argument for top level
+ * components; for nested components: the corresponding top level component)
* @param component component to process
* @param parentName name of parent component
***************
*** 569,576 ****
private void processComponent(final Document schema,
final String schemaLocation,
final Node component,
final String parentName)
throws TransformerException, SAXException, IOException, SchemaException {
! final String componentType = component.getLocalName();
final String namespaceURI = getTargetNamespace(schema);
final String subfolder = out + FILE_SEP + getFolderFromURI(namespaceURI.equals("") ? NO_NAMESPACE : namespaceURI);
--- 580,588 ----
private void processComponent(final Document schema,
final String schemaLocation,
+ final Node rootComponent,
final Node component,
final String parentName)
throws TransformerException, SAXException, IOException, SchemaException {
! final String componentType = rootComponent.getLocalName();
final String namespaceURI = getTargetNamespace(schema);
final String subfolder = out + FILE_SEP + getFolderFromURI(namespaceURI.equals("") ? NO_NAMESPACE : namespaceURI);
***************
*** 601,605 ****
new File(subfolder + FILE_SEP + componentType).mkdir();
final Source source = getSource(schema, getSystemId(schemaLocation));
! ((Element) component).setAttribute("xsddocid", "a");
if (xml) {
transform(source, tComponent, component,
--- 613,620 ----
new File(subfolder + FILE_SEP + componentType).mkdir();
final Source source = getSource(schema, getSystemId(schemaLocation));
! if (!"".equals(parentName)) {
! ((Element) component).setAttributeNS(NAMESPACE_NAMESPACE, "xmlns:" + XSDDOC_PREFIX, XSDDOC_NAMESPACE);
! ((Element) component).setAttributeNS(XSDDOC_NAMESPACE, XSDDOC_PREFIX + ":" + XSDDOCID_ATTR, "a");
! }
if (xml) {
transform(source, tComponent, component,
***************
*** 611,617 ****
subfolder + FILE_SEP + componentType + FILE_SEP + name + getExtension());
}
! ((Element) component).removeAttribute("xsddocid");
if ("element".equals(componentType) || "complexType".equals(componentType)) {
! searchLocalElementDeclarations(schema, schemaLocation, component, name);
}
}
--- 626,634 ----
subfolder + FILE_SEP + componentType + FILE_SEP + name + getExtension());
}
! if (!"".equals(parentName)) {
! ((Element) component).removeAttributeNS(XSDDOC_NAMESPACE, XSDDOCID_ATTR);
! }
if ("element".equals(componentType) || "complexType".equals(componentType)) {
! searchLocalElementDeclarations(schema, schemaLocation, rootComponent, component, name);
}
}
***************
*** 624,627 ****
--- 641,646 ----
* @param schema root Node of DOM tree of current schema
* @param schemaLocation location of current schema
+ * @param rootComponent root component (must be equal to component argument for top level
+ * components; for nested components: the corresponding top level component)
* @param component component to search in
* @param parentName name of parent component
***************
*** 636,639 ****
--- 655,659 ----
private void searchLocalElementDeclarations(final Document schema,
final String schemaLocation,
+ final Node rootComponent,
final Node component,
final String parentName)
***************
*** 648,655 ****
final String type = DomUtil.getAttributeValue(nestedComponent, "type");
if (ref == null && type == null) {
! processComponent(schema, schemaLocation, nestedComponent, parentName);
}
} else {
! searchLocalElementDeclarations(schema, schemaLocation, nestedComponent, parentName);
}
}
--- 668,675 ----
final String type = DomUtil.getAttributeValue(nestedComponent, "type");
if (ref == null && type == null) {
! processComponent(schema, schemaLocation, rootComponent, nestedComponent, parentName);
}
} else {
! searchLocalElementDeclarations(schema, schemaLocation, rootComponent, nestedComponent, parentName);
}
}
***************
*** 698,702 ****
final Node redefinedComponent = components.item(i);
if (redefinedComponent.getNodeType() == Node.ELEMENT_NODE) {
! processComponent(schema, schemaLocation, redefinedComponent, "");
}
}
--- 718,722 ----
final Node redefinedComponent = components.item(i);
if (redefinedComponent.getNodeType() == Node.ELEMENT_NODE) {
! processComponent(schema, schemaLocation, redefinedComponent, redefinedComponent, "");
}
}
***************
*** 934,939 ****
private void setTargetNamespace(final Document schema, final String namespace) {
final Element schemaElement = (Element) DomUtil.getFirstElementChild(schema);
schemaElement.setAttribute(TARGETNAMESPACE, namespace == null ? "noNamespace" : namespace);
- schemaElement.setAttributeNS(HTTP_WWW_W3_ORG_2000_XMLNS, "xmlns", namespace);
}
--- 954,959 ----
private void setTargetNamespace(final Document schema, final String namespace) {
final Element schemaElement = (Element) DomUtil.getFirstElementChild(schema);
+ schemaElement.setAttributeNS(NAMESPACE_NAMESPACE, "xmlns", namespace);
schemaElement.setAttribute(TARGETNAMESPACE, namespace == null ? "noNamespace" : namespace);
}
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click