예제 #1
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;
 }
예제 #2
0
 public void testName() throws Exception {
   // load model
   final URL urlInitial = ResourceU.resolve(App.Actions.XSD);
   final XsdTypes xsdTypes = new XsdTypes(urlInitial);
   final DocumentFactory documentFactory =
       new DocumentFactory(xsdTypes.getTypeDefinitions(), false);
   final Document document = documentFactory.generateEmpty(App.Actions.QNAME_LOCALE);
   logger.finest(DocumentU.toString(document));
   // validate
   final XsdBundle xsdBundle = new XsdBundle(new XsdBundles(xsdTypes, new Locale("ru")));
   final Xed xed = new Xed(document, xsdTypes, xsdBundle);
   final XedCursor cursor = new XedNav(xed).getRoot();
   final String pageText =
       new PropertyPageTextView(new XedPropertyPageView(null, cursor)).render();
   logger.finest(pageText);
   Assert.assertEquals("0e07d15d", CRCU.crc32String(UTF8Codec.toBytes(pageText)));
 }
예제 #3
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;
 }