Package org.thymeleaf.dom

Examples of org.thymeleaf.dom.Document


    if (!(element.getParent() instanceof Document) &&
      !arguments.getTemplateResolution().getTemplateMode().equals(TEMPLATE_MODE_LEGACYHTML5)) {
      logger.error("layout:decorator attribute must appear in the root element of your content page");
      throw new IllegalArgumentException("layout:decorator attribute must appear in the root element of your content page");
    }
    Document document = arguments.getDocument();

    // Locate the decorator page
    StandardFragment fragment = StandardFragmentProcessor.computeStandardFragmentSpec(
        arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName),
        DIALECT_PREFIX_LAYOUT, PROCESSOR_NAME_FRAGMENT);
    Template decoratortemplate = arguments.getTemplateRepository().getTemplate(new TemplateProcessingParameters(
        arguments.getConfiguration(), fragment.getTemplateName(), arguments.getContext()));
    element.removeAttribute(attributeName);

    Document decoratordocument = decoratortemplate.getDocument();
    Element decoratorrootelement = decoratordocument.getFirstElementChild();

    // Gather all fragment parts from this page
    Map<String,Object> fragments = findFragments(document.getElementChildren());

    // Decide which kind of decorator to apply, given the decorator page root element
View Full Code Here


    headdecorator.decorate(decoratorhtml, findElement(contenthtml, HTML_ELEMENT_HEAD));
    bodydecorator.decorate(decoratorhtml, findElement(contenthtml, HTML_ELEMENT_BODY));

    // Set the doctype from the decorator if missing from the content page
    Document decoratordocument = (Document)decoratorhtml.getParent();
    Document pagedocument = (Document)contenthtml.getParent();
    if (decoratordocument.hasDocType() && !pagedocument.hasDocType()) {
      pagedocument.setDocType(decoratordocument.getDocType());
    }

    super.decorate(decoratorhtml, contenthtml);
  }
View Full Code Here

     
      return "";
    }
   
    public static final Document getOwnerDocument(Node node) {
      Document doc = null;
     
      if(node instanceof Document) {
        doc = (Document) node;
      } else {
       
View Full Code Here

      this.preprocessor = new ThymesheetPreprocessor(urlFactory, thymesheetLocator, postProcessors);
    }

  public Document parseTemplate(Configuration configuration,
      String documentName, Reader source) {
    Document doc = decoratedParser.parseTemplate(configuration, documentName, source);
    try {
      preprocessor.preProcess(documentName, doc);
    } catch (IOException e) {
      throw new UnsupportedOperationException(e.getMessage(), e);
    }
View Full Code Here

   

    public final List<Node> parseFragment(final Configuration configuration, final String fragment) {
        final String wrappedFragment = wrapFragment(fragment);
        final Document document =
                parseTemplateUsingPool(
                        configuration,
                        null, // documentName
                        new StringReader(wrappedFragment),
                        getNonValidatingPool());
View Full Code Here

        }
      }

      String result = myProfileTemplateEngine.process(name, context);
      String trim = result.trim();
      Document dom = getXhtmlDOMFor(new StringReader(trim));

      Element firstChild = (Element) dom.getFirstChild();
      for (int i = 0; i < firstChild.getChildren().size(); i++) {
        Node next = firstChild.getChildren().get(i);
        if (i == 0 && firstChild.getChildren().size() == 1) {
          if (next instanceof org.thymeleaf.dom.Text) {
            org.thymeleaf.dom.Text nextText = (org.thymeleaf.dom.Text) next;
View Full Code Here

        }
      }

      String result = myProfileTemplateEngine.process(name, context);
      String trim = result.trim();
      Document dom = getXhtmlDOMFor(new StringReader(trim));

      Element firstChild = (Element) dom.getFirstChild();
      for (int i = 0; i < firstChild.getChildren().size(); i++) {
        Node next = firstChild.getChildren().get(i);
        if (i == 0 && firstChild.getChildren().size() == 1) {
          if (next instanceof org.thymeleaf.dom.Text) {
            org.thymeleaf.dom.Text nextText = (org.thymeleaf.dom.Text) next;
View Full Code Here

          throw new DataFormatException("No narrative template for class " + value.getClass());
        }
      }

      String result = myProfileTemplateEngine.process(name, context);
      Document dom = DOMUtils.getXhtmlDOMFor(new StringReader(result));

      Element firstChild = (Element) dom.getFirstChild();
      for (Node next : firstChild.getChildren()) {
        theElement.addChild(next);
      }

      return ProcessorResult.ok();
View Full Code Here

          throw new DataFormatException("No narrative template for class " + value.getClass());
        }
      }

      String result = myProfileTemplateEngine.process(name, context);
      Document dom = DOMUtils.getXhtmlDOMFor(new StringReader(result));

      Element firstChild = (Element) dom.getFirstChild();
      for (Node next : firstChild.getChildren()) {
        theElement.addChild(next);
      }

      return ProcessorResult.ok();
View Full Code Here

  private HtmlElements convertResultIntoDom(final String path, final String htmlString) {
    List<Node> nodes;
    if(isFragment(htmlString)) {
      nodes = parser.parseFragment(this.getConfiguration(), htmlString)
    } else {
      Document doc = parser.parseTemplate(this.getConfiguration(), path, new StringReader(htmlString));
      nodes = doc.getChildren();
    }

    Element root = new Element("#document");
    root.setChildren(nodes);
View Full Code Here

TOP

Related Classes of org.thymeleaf.dom.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.