Package com.google.gxp.compiler.schema

Examples of com.google.gxp.compiler.schema.ElementValidator


    }

    @Override
    public Expression visitOutputElement(OutputElement element) {
      List<Expression> values = Lists.newArrayList();
      ElementValidator elementValidator = element.getValidator();
      Schema elementSchema = element.getSchema();
      String tagPrefix = elementSchema.getTagPrefix();
      DocType docType = element.getDocType();
      if (docType != null) {
        values.add(flattenDocType(element, docType));
      }
      values.add(new StringConstant(element, elementSchema, "<"));
      if (tagPrefix != null) {
        values.add(new StringConstant(element, elementSchema, tagPrefix + ":"));
      }
      values.add(new StringConstant(element, elementSchema,
                                    element.getLocalName()));

      if (docType != null) {
        values.add(flattenXmlns(element));
      }

      for (final Attribute attr : element.getAttributes()) {
        AttributeValidator attrValidator = elementValidator.getAttributeValidator(attr.getName());
        Expression empty = new StringConstant(attr, elementSchema, "");
        if (attrValidator.isFlagSet(AttributeValidator.Flag.BOOLEAN)) {
          Expression attrValue = attr.getValue().acceptVisitor(this);
          if (attrValue.hasStaticString()) {
            values.add(buildBooleanAttrExpression(attr, element));
          } else {
            if (attrValue instanceof ConvertibleToContent) {
              ConvertibleToContent ctc = (ConvertibleToContent)attrValue;
              attrValue = ctc.getSubexpression();
            }
            values.add(new Conditional(element, elementSchema,
                                       attrValue,
                                       buildBooleanAttrExpression(attr, element),
                                       empty));
          }
        } else {
          Expression condition = attr.getCondition();
          if (condition != null) {
            values.add(new Conditional(element, elementSchema, condition,
                                       buildAttrExpression(attr, element), empty));
          } else {
            values.add(buildAttrExpression(attr, element));
          }
        }
      }

      for (String attrBundle : element.getAttrBundles()) {
        values.add(new EscapeExpression(elementSchema,
                                        new AttrBundleReference(element, attrBundle)));
      }

      if (elementValidator.isFlagSet(ElementValidator.Flag.NOENDTAG)) {
        values.add(new Conditional(
            element, elementSchema,
            new IsXmlExpression(element, elementSchema),
            new StringConstant(element, elementSchema, " /"),
            new StringConstant(element, elementSchema, "")));
      }
      values.add(new StringConstant(element, elementSchema, ">"));
      values.add(element.getContent().acceptVisitor(this));
      if (!elementValidator.isFlagSet(ElementValidator.Flag.NOENDTAG)) {
        values.add(new StringConstant(element, elementSchema, "</"));
        if (tagPrefix != null) {
          values.add(new StringConstant(element, elementSchema,
                                        tagPrefix + ":"));
        }
View Full Code Here


      return null;
    }

    // OutputNamespace elements
    public Void visitParsedOutputElement(OutputNamespace.ParsedOutputElement node) {
      ElementValidator validator = node.getValidator();
      AttributeMap attrMap = nodeParts.getAttributes();

      String docTypeName = attrMap.getOptional(GxpNamespace.INSTANCE, "doctype", null);
      DocType docType;
      if (docTypeName == null) {
        docType = null;
      } else {
        docType = validator.getDocType(docTypeName);
        if (docType == null) {
          alertSink.add(new InvalidDoctypeError(node, docTypeName));
        }
      }

      // if an output element has a gxp:ph attribute we surrount the element
      // tags (but NOT the element content) with placeholders
      String phName = attrMap.getOptional(GxpNamespace.INSTANCE, "ph", null);

      // TODO(laurence): always collect content here, and check against
      // NOENDTAG in Validator phase.
      Expression content;
      if (validator.isFlagSet(ElementValidator.Flag.NOENDTAG)) {
        // Ignore supplied children. EditableParts will generate alerts about
        // them if necessary.
        content = new StringConstant(node, null, "");
      } else {
        content = getCollapsableContent(attrMap);
      }

      String innerContentTypeString = validator.getInnerContentType();
      Schema innerSchema = (innerContentTypeString == null)
          ? null
          : schemaFactory.fromContentTypeName(innerContentTypeString);

      List<String> bundles = getBundles(attrMap);

      List<Attribute> attrs = attrMap.getUnusedAttributes();
      output.accumulate(
          new OutputElement(node.getSourcePosition(),
                            node.getDisplayName(),
                            node.getSchema(),
                            innerSchema,
                            validator.getTagName(),
                            validator,
                            docType,
                            checkAttributes(node, validator, attrs),
                            bundles,
                            phName,
View Full Code Here

    @Override
    public Expression visitOutputElement(OutputElement element) {
      boolean oldUseSpecialAttrCollapsing = useSpecialAttrCollapsing;
      useSpecialAttrCollapsing = true;
      ElementValidator validator = element.getValidator();
      SearchingVisitor contentVisitor =
          validator.isFlagSet(ElementValidator.Flag.PRESERVESPACES)
            ? this.with(PRESERVING_SPACE_OPERATORS)
            : this;
      Expression result = element.withAttributesAndContent(
          Util.map(element.getAttributes(), getAttributeFunction()),
          element.getContent().acceptVisitor(contentVisitor));
View Full Code Here

                                     SourcePosition sourcePosition,
                                     String displayName,
                                     String tagName,
                                     List<ParsedAttribute> attrs,
                                     List<ParsedElement> children) {
    ElementValidator validator = schema.getElementValidator(tagName);
    if (validator == null) {
      alertSink.add(new UnknownElementError(sourcePosition, this,
                                            displayName));
      return null;
    } else {
View Full Code Here

    }

    @Override
    public Expression visitOutputElement(OutputElement element) {
      boolean oldVisible = visible;
      ElementValidator elementValidator = element.getValidator();
      boolean oldInsideMsg = insideMsg;
      insideMsg = false;
      for (Attribute attr : element.getAttributes()) {
        AttributeValidator attrValidator =
            elementValidator.getAttributeValidator(attr.getName());
        visible = attrValidator.isFlagSet(AttributeValidator.Flag.VISIBLETEXT);
        visitAttribute(attr);
        visible = oldVisible;
      }
      insideMsg = oldInsideMsg;
      visible &= !elementValidator.isFlagSet(ElementValidator.Flag.INVISIBLEBODY);
      apply(element.getContent());
      visible = oldVisible;
      return element;
    }
View Full Code Here

      return null;
    }

    // OutputNamespace elements
    public Void visitParsedOutputElement(OutputNamespace.ParsedOutputElement node) {
      ElementValidator validator = node.getValidator();
      AttributeMap attrMap = nodeParts.getAttributes();

      String docTypeName = attrMap.getOptional(GxpNamespace.INSTANCE, "doctype", null);
      DocType docType;
      if (docTypeName == null) {
        docType = null;
      } else {
        docType = validator.getDocType(docTypeName);
        if (docType == null) {
          alertSink.add(new InvalidDoctypeError(node, docTypeName));
        }
      }

      // if an output element has a gxp:ph attribute we surrount the element
      // tags (but NOT the element content) with placeholders
      String phName = attrMap.getOptional(GxpNamespace.INSTANCE, "ph", null);

      // TODO(laurence): always collect content here, and check against
      // NOENDTAG in Validator phase.
      Expression content;
      if (validator.isFlagSet(ElementValidator.Flag.NOENDTAG)) {
        // Ignore supplied children. EditableParts will generate alerts about
        // them if necessary.
        content = new StringConstant(node, null, "");
      } else {
        content = getCollapsableContent(attrMap);
      }

      String innerContentTypeString = validator.getInnerContentType();
      Schema innerSchema = (innerContentTypeString == null)
          ? null
          : schemaFactory.fromContentTypeName(innerContentTypeString);

      List<String> bundles = getBundles(attrMap);

      List<Attribute> attrs = attrMap.getUnusedAttributes();
      output.accumulate(
          new OutputElement(node.getSourcePosition(),
                            node.getDisplayName(),
                            node.getSchema(),
                            innerSchema,
                            validator.getTagName(),
                            validator,
                            docType,
                            checkAttributes(node, validator, attrs),
                            bundles,
                            phName,
View Full Code Here

TOP

Related Classes of com.google.gxp.compiler.schema.ElementValidator

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.