예제 #1
0
 private void doInclude(final URL url, final XsdAtom xsdAtom, final XsltX xsltX)
     throws IOException {
   final Collection<Element> children = ElementU.getChildren(xsdAtom.getElement(), XsdU.INCLUDE);
   for (final Element child : children) {
     final String schemaLocation = ElementU.getAttribute(child, XsdU.SCHEMA_LOCATION);
     final URL urlInclude = URLCodec.resolve(url, schemaLocation);
     add(null, urlInclude, xsltX);
   }
 }
예제 #2
0
 private void doImport(final URL url, final XsdAtom xsdAtom, final XsltX xsltX)
     throws IOException {
   final Collection<Element> children = ElementU.getChildren(xsdAtom.getElement(), XsdU.IMPORT);
   for (final Element child : children) {
     final String namespace = ElementU.getAttribute(child, XsdU.NAMESPACE);
     final String schemaLocation = ElementU.getAttribute(child, XsdU.SCHEMA_LOCATION);
     final URL urlImport = URLCodec.resolve(url, schemaLocation);
     add(namespace, urlImport, xsltX);
   }
 }
예제 #3
0
파일: XedNavNode.java 프로젝트: greyp9/arwo
 public final XedCursor findTypeInstanceChild(final String name, final XedCursor cursor) {
   final Element element = cursor.getElement();
   final XedCursor cursorType = findTypeInstance(name, cursor);
   XedCursor cursorChild = null;
   final TypeInstance typeInstance = cursorType.getTypeInstance();
   final TypeInstance.NodeType nodeType =
       (typeInstance == null) ? null : typeInstance.getNodeType();
   if (TypeInstance.NodeType.attribute.equals(nodeType)) {
     cursorChild = findChildAttr(ElementU.getAttributeNode(element, name), cursor, cursorType);
   } else if (TypeInstance.NodeType.element.equals(nodeType)) {
     cursorChild =
         findChildElement(ElementU.getChild(element, typeInstance.getQName()), cursor, cursorType);
   }
   return cursorChild;
 }
예제 #4
0
파일: XedNavNode.java 프로젝트: greyp9/arwo
 private XedCursor findChildAttr(
     final Attr attr, final XedCursor cursorParent, final XedCursor cursorType) {
   final Xed xed = cursorParent.getXed();
   final Element elementParent = cursorParent.getElement();
   final TypeInstance typeInstance = cursorType.getTypeInstance();
   final Attr attrIt =
       (elementParent == null) ? null : ElementU.getAttributeNode(elementParent, attr.getName());
   return ((attrIt == null) ? null : new XedCursor(xed, cursorType, attrIt, 0, typeInstance));
 }
예제 #5
0
 private Element fabricateElement(final CronJob cronJob) throws IOException {
   final String command = cronJob.getCommand();
   final String[] tokens = command.split(StringU.Const.WHITESPACE);
   final NameTypeValues arguments = HttpArguments.toArguments(tokens[1]);
   final Element element =
       DocumentU.createDocument(tokens[0], XMLConstants.NULL_NS_URI).getDocumentElement();
   for (final NameTypeValue argument : arguments) {
     ElementU.setAttribute(element, argument.getName(), argument.getValueS());
   }
   return element;
 }
예제 #6
0
 private SchemaAtom add(final String targetNamespaceIn, final URL url, final XsltX xsltX)
     throws IOException {
   SchemaAtom schemaAtom = null;
   logger.finest(url.toExternalForm());
   final String catalogURL = URLCodec.toExternalForm(urlCatalog);
   final String initialURL = URLCodec.toExternalForm(url);
   final String uri = ((catalogURL == null) ? initialURL : initialURL.replace(catalogURL, ""));
   final String protocol = url.getProtocol();
   final boolean isLocal =
       (("file".equals(protocol)) || ("jar".equals(protocol))); // i18n internal
   final boolean isLoaded = schemaAtoms.containsKey(uri);
   if (isLocal && (!isLoaded)) {
     // get schema content
     byte[] bytesXsd = StreamU.read(url);
     // optional transform
     if (xsltX != null) {
       bytesXsd = xsltX.transform(bytesXsd);
     }
     logger.finest(UTF8Codec.toString(bytesXsd));
     // default XSLT for XSD
     final URL urlAugmentXSLT = new URL(initialURL.replace(".xsd", ".xslt"));
     final byte[] xslt = StreamU.readSafe(urlAugmentXSLT);
     if (xslt != null) {
       final XsltX xsltAugment = new XsltX(xslt);
       bytesXsd = xsltAugment.transform(bytesXsd);
     }
     // load into DOM
     final Document document = DocumentU.toDocument(bytesXsd);
     final Element element = document.getDocumentElement();
     final String targetNamespace =
         ElementU.getAttribute(element, XsdU.TARGET_NAMESPACE, XsdU.NS_URI_NULL);
     if ((targetNamespaceIn != null) && (!targetNamespaceIn.equals(targetNamespace))) {
       logger.warning(String.format("%s != %s", targetNamespaceIn, targetNamespace));
     }
     // register content
     final XsdAtom xsdAtom = atomFactory.create(element, null);
     final QName name = QNameU.getQName(targetNamespace, element.getLocalName(), null);
     schemaAtom = new SchemaAtom(url, name, xsdAtom);
     schemaAtoms.put(uri, schemaAtom);
     // schemaAtoms.put(targetNamespace, schemaAtom);  // why this? (duplicate)
     // import dependencies
     doImport(url, xsdAtom, xsltX);
     doInclude(url, xsdAtom, xsltX);
   }
   return schemaAtom;
 }
예제 #7
0
파일: XedNavNode.java 프로젝트: greyp9/arwo
 @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
 private XedCursor findChildElement(
     final Element child, final XedCursor cursorParent, final XedCursor cursorType) {
   final Xed xed = cursorParent.getXed();
   final Element elementParent = cursorParent.getElement();
   final TypeInstance typeInstance = cursorType.getTypeInstance();
   XedCursor cursor = new XedCursor(xed, cursorType, null, null, typeInstance);
   final Collection<Element> children =
       ElementU.getChildren(elementParent, typeInstance.getName());
   int ordinal = -1;
   for (final Element childIt : children) {
     ++ordinal;
     if (childIt.equals(child)) {
       cursor = new XedCursor(xed, cursorType, childIt, ordinal, typeInstance);
       break;
     }
   }
   return cursor;
 }