Package com.caucho.relaxng.program

Examples of com.caucho.relaxng.program.Item


     
      QName name = new QName(qName, uri);
      _name = name;
      _eltLocation = getLocation();

      Item newItem = getStartElement(_item, name);

      if (newItem == null) {
  Item parentItem = _itemStack.get(_itemStack.size() - 1);
 
        if (parent.getName().equals("#top"))
          throw new RelaxException(L.l("<{0}> is an unexpected top-level tag.{1}",
                                       errorNodeName(name, _item, parentItem),
               errorMessageDetail(_item, parentItem, null, name)));
        else
          throw new RelaxException(L.l("<{0}> is an unexpected tag (parent <{1}> starts at {2}).{3}",
                                       errorNodeName(name, _item, parentItem),
               parent.getName(), parentLocation,
                                       errorMessageDetail(_item, parentItem, parent.getName(), name)));
      }

      _item = newItem;
      _itemStack.add(newItem);

      Item parentItem = newItem;

      int len = attrs.getLength();
      for (int i = 0; i < len; i++) {
        String attrUri = attrs.getURI(i);
        String attrQName = attrs.getQName(i);
View Full Code Here


  private Item getStartElement(Item item, QName name)
    throws RelaxException
  {
    _startKey.init(item, name);

    Item newItem = null;//_programCache.get(_startKey);

    if (newItem != null) {
      return newItem;
    }
   
View Full Code Here

      return;

    _hasText = false;

    try {
      Item newItem = _item.text(_text);
     
      if (newItem == null) {
        String string = _text.toString();

  Item parentItem = _itemStack.get(_itemStack.size() - 1);
 
        throw new RelaxException(L.l("The following text is not allowed in this context.\n{0}\n{1}", string,
             errorMessageDetail(_item, parentItem,
              _name.getName(), null)));
      }
View Full Code Here

    QName name = _name;
    QName parent = _nameStack.remove(_nameStack.size() - 1);
    _name = parent;

    Item parentItem = _itemStack.remove(_itemStack.size() - 1);

    String eltOpen = _eltLocation;
    _eltLocation = _eltLocationStack.remove(_eltLocationStack.size() - 1);
   
    try {
      Item nextItem = getEndElement(_item);
     
      if (nextItem == null)
        throw new RelaxException(L.l("<{0}> closed while expecting more elements (open at {1}).{2}",
                                     qName, eltOpen,
             requiredMessageDetail(_item, parentItem,
View Full Code Here

  private Item getEndElement(Item item)
    throws RelaxException
  {
    _endElementKey.init(item);

    Item newItem = null;//_programCache.get(_endElementKey);

    if (newItem != null) {
      return newItem;
    }
   
View Full Code Here

  /**
   * Returns a string containing the allowed values.
   */
  private String errorNodeName(QName name, Item item, Item parentItem)
  {
    Item currentItem = item;
   
    if (currentItem == null)
      currentItem = parentItem;

    if (currentItem == null)
      return name.toString();

    HashSet<QName> values = new LinkedHashSet<QName>();
    currentItem.firstSet(values);

    for (QName value : values) {
      if (! name.getLocalName().equals(value.getLocalName())) {
      }
      else if (name.getPrefix() == null || name.getPrefix().equals("")) {
View Full Code Here

   * Returns a string containing the allowed values.
   */
  private String errorMessageDetail(Item item, Item parentItem,
            String parentName, QName qName)
  {
    Item currentItem = item;
   
    if (currentItem == null)
      currentItem = parentItem;

    HashSet<QName> values = new LinkedHashSet<QName>();
    currentItem.firstSet(values);

    String expected = null;
    if (values.size() <= 5)
      expected = namesToString(values, parentName, qName,
             currentItem.allowEmpty());
   
    return (getLineContext(getFileName(), getLine())
      + syntaxMessage(item, parentItem, parentName, qName, expected));
  }
View Full Code Here

   * Returns a string containing the allowed values.
   */
  private String requiredMessageDetail(Item item, Item parentItem,
               String parentName, QName qName)
  {
    Item currentItem = item;

    if (currentItem == null)
      currentItem = parentItem;

    HashSet<QName> values = new LinkedHashSet<QName>();
    currentItem.requiredFirstSet(values);
     
    String expected = null;
   
    if (values.size() <= 5) {
      expected = namesToString(values, parentName, qName,
             currentItem.allowEmpty());
    }
   
    return (getLineContext(getFileName(), getLine())
      + syntaxMessage(item, parentItem, parentName, qName, expected));
  }
View Full Code Here

   * Returns a string containing the allowed values.
   */
  private String attributeMessageDetail(Item item, Item parentItem,
          String parentName, QName qName)
  {
    Item currentItem = item;

    if (currentItem == null)
      currentItem = parentItem;
   
    String allowed = allowedAttributes(currentItem, qName);
View Full Code Here

    else
      syntaxPrefix = "<" + parentName + "> syntax: ";
   
    String msg = "";

    Item topParent = null;
    for (Item parent = item;
   parent != null;
   parent = null) { // parent.getParent()) {
      if (qName != null && parent.allowsElement(qName)) {
  msg = "\n Check for duplicate and out-of-order tags.";

  if (expected != null)
    msg += expected + "\n";
 
  msg += "\n";

  String prefix = "Syntax: ";
  if (parent == parentItem)
    prefix = syntaxPrefix;
 
  msg += prefix + parent.toSyntaxDescription(prefix.length());
  break;
      }
     
      // topParent = parent;
    }

    if (topParent == null || topParent instanceof EmptyItem) {
      topParent = parentItem;

      if (qName != null && topParent.allowsElement(qName)) {
  msg = "\n Check for duplicate and out-of-order tags.";

  if (expected != null)
    msg += expected + "\n";
 
  msg += "\n";

  String prefix = syntaxPrefix;
  msg += prefix + topParent.toSyntaxDescription(prefix.length());
      }
    }

    if (msg.equals("")) {
      msg = "";

      if (expected != null)
  msg += expected + "\n";
     
      msg += "\n";

      String prefix = syntaxPrefix;
      msg += prefix + topParent.toSyntaxDescription(prefix.length());
    }

    return msg;
  }
View Full Code Here

TOP

Related Classes of com.caucho.relaxng.program.Item

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.