Package com.caucho.xml

Examples of com.caucho.xml.QElement


    throws Exception
  {
    XslNode xslNode = null;

    if (child instanceof QElement) {
      QElement elt = (QElement) child;

      Class cl = _tagMap.get(elt.getQName());

      if (cl != null) {
        xslNode = (XslNode) cl.newInstance();
        xslNode.setGenerator(this);
        xslNode.setParent(_xslNode);

        xslNode.setStartLocation(((QAbstractNode) child).getBaseURI(),
                                 ((QAbstractNode) child).getFilename(),
                                 ((QAbstractNode) child).getLine());

        QAttr attr = (QAttr) elt.getFirstAttribute();
        for (; attr != null; attr = (QAttr) attr.getNextSibling()) {
          xslNode.addAttribute(attr.getQName(), attr.getNodeValue());
        }

        xslNode.endAttributes();

        XslNode oldNode = _xslNode;
        _xslNode = xslNode;

        Node node = elt.getFirstChild();
        for (; node != null; node = node.getNextSibling()) {
          XslNode xslChild = createChild(node);

          if (xslChild != null)
            xslNode.addChild(xslChild);
        }

        xslNode.endElement();

        _xslNode = oldNode;
      }
      /*
      else if (elt.getNodeName().equals("jsp:decl") ||
               elt.getNodeName().equals("jsp:declaration") ||
               elt.getNodeName().startsWith("jsp:directive")) {
      }
      */
      else if (child.getNodeName().startsWith("xsl:") &&
               ! XSLNS.equals(child.getNamespaceURI())) {
        throw error(child, L.l("<{0}> has an xsl: prefix, but is not in the {1} namespace.  XSL requires an xmlns:xsl=\"{1}\" namespace attribute.",
                               child.getNodeName(),
                               XSLNS));
      }
      else if (! XSLNS.equals(child.getNamespaceURI()) &&
               ! XTPNS.equals(child.getNamespaceURI())) {
        xslNode = new XslElementNode(elt.getQName());
        xslNode.setGenerator(this);
        xslNode.setParent(_xslNode);

        xslNode.setStartLocation(((QAbstractNode) child).getBaseURI(),
                                 ((QAbstractNode) child).getFilename(),
                                 ((QAbstractNode) child).getLine());

        QAttr attr = (QAttr) elt.getFirstAttribute();
        for (; attr != null; attr = (QAttr) attr.getNextSibling())
          xslNode.addAttribute(attr.getQName(), attr.getNodeValue());

        xslNode.endAttributes();

        XslNode oldNode = _xslNode;
        _xslNode = xslNode;

        Node node = elt.getFirstChild();
        for (; node != null; node = node.getNextSibling()) {
          XslNode xslChild = createChild(node);

          xslNode.addChild(xslChild);
        }
View Full Code Here


  }

  protected void printElement(Node node)
    throws Exception
  {
    QElement elt = (QElement) node;
    String name = node.getNodeName();

    if (name.equals("jsp:decl") || name.equals("jsp:declaration")) {
      println("if (out.isFlagFirst(" + _flagCount++ + ")) {");
      pushDepth();
    }
   
    String prefix = elt.getPrefix();
    String local = elt.getLocalName();
    String namespace = elt.getNamespaceURI();

    String []postPrefix = (String []) _namespaceAliases.get(namespace);
    if (postPrefix != null) {
      prefix = postPrefix[0];
      namespace = postPrefix[1];
View Full Code Here

    _doc = xsl;
    if (_doc instanceof CauchoDocument)
      _qDoc = (CauchoDocument) _doc;

    QElement qTop = null;
    if (top instanceof QElement)
      qTop = (QElement) top;

    /*
    if (qTop != null && qTop.getFilename() != null)
View Full Code Here

   * Start the top-level stylesheet generation.
   */
  private void generateStylesheet(Element elt, boolean isTop)
    throws Exception
  {
    QElement element = (QElement) elt;
    _isCauchoXsl = ! element.getAttribute("xsl-caucho").equals("");

    String systemId = element.getBaseURI();
    Path oldContext = _context;

    if (systemId != null)
      _context = _context.lookup(systemId);
   
View Full Code Here

    throws Exception
  {
    if (! (element instanceof QElement))
      return;
   
    QElement elt = (QElement) element;
    String excludeNamespace;
    excludeNamespace = element.getAttribute("exclude-result-prefixes");
    if (! excludeNamespace.equals("")) {
      for (String prefix : excludeNamespace.split("[,\\s]+")) {

        String ns = elt.getNamespace(prefix);
        if (ns == null)
          throw error(elt, L.l("`{0}' must be a namespace prefix",
                               prefix));
        _excludedNamespaces.put(ns, "");
      }
View Full Code Here

    Document xsl = readFile(href, path);
   
    if (xsl == null)
      throw new FileNotFoundException(href);

    QElement top = (QElement) xsl.getDocumentElement();
    if (top == null ||
        ! "stylesheet".equals(getXslLocal(top)) &&
        ! "transform".equals(getXslLocal(top))) {
      throw error("imported stylesheet `" + href +
                  "' missing xsl:stylesheet.");
    }

    int oldMinImportance = _minImportance;
    Path oldContext = _context;
    Path virtualPath = _context.getParent().lookup(href);
    _context = virtualPath;
    _minImportance = _importance;
    boolean oldTop = _isTop;
    boolean oldRaw = _isRawText;
    _isTop = false;
    _isRawText = false;
   
    String systemId = top.getBaseURI();

    if (systemId != null)
      _context = _context.lookup(systemId);
   
    XslStylesheet stylesheet = (XslStylesheet) createChild(top);
View Full Code Here

    throws Exception
  {
    if (! (element instanceof QElement))
      return;
   
    QElement elt = (QElement) element;
    String stylesheetPrefix;
    String resultPrefix;

    stylesheetPrefix = (String) element.getAttribute("stylesheet-prefix");
    resultPrefix = (String) element.getAttribute("result-prefix");
View Full Code Here

  }

  private void generateApplyTemplates(Node node)
    throws Exception
  {
    QElement element = (QElement) node;
    String select = element.getAttribute("select");
    String mode = element.getAttribute("mode");
    AbstractPattern selectPattern = null;
    if (! select.equals(""))
      selectPattern = parseSelect(select, node);

    Sort []sort = generateSort(node);
View Full Code Here

  }

  private void generateApplyImports(Node node)
    throws Exception
  {
    QElement element = (QElement) node;
    String mode = element.getAttribute("mode");

    if (element.getFirstChild() != null)
      throw error(L.l("xsl:apply-imports must be empty"));

    pushCall();
    generateArgs(element);
    printApplyImports(mode, _minImportance, _importance);
View Full Code Here

  }

  private void generateMacro(Element element)
    throws Exception
  {
    QElement elt = (QElement) element;

    String name = element.getNodeName();
    String mode = element.getAttribute("mode");

    pushCall();
    for (Node node = elt.getFirstAttribute();
         node != null;
         node = node.getNextSibling()) {
      String argName = node.getNodeName();
      String argValue = node.getNodeValue();
View Full Code Here

TOP

Related Classes of com.caucho.xml.QElement

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.