Package org.infoset.xml.filter

Examples of org.infoset.xml.filter.ItemFilter


      URL adminXSD = AdminXML.class.getResource("admin.xsd");
      if (adminXSD==null) {
         throw new RuntimeException("Cannot find admin.xsd relative to class path.");
      }
      validate.addNamespaceMap(AdminXML.NAMESPACE,adminXSD);
      ItemFilter checkValidity = new ItemFilter() {
         ItemDestination output;
         int level = -1;
         public void send(Item item)
            throws XMLException
         {
            switch (item.getType()) {
               case DocumentItem:
                  level = -1;
                  break;
               case ElementItem:
                  level++;
                  break;
               case ElementEndItem:
                  level--;
                  ElementEnd end = (ElementEnd)item;
                  if (level<0) {
                     if (end.getValidity()!=Validity.VALID) {
                        StringBuilder builder = new StringBuilder();
                        Iterator errors = validate.getErrors();
                        while (errors.hasNext()) {
                           builder.append("\n");
                           builder.append(errors.next().toString());
                        }
                        throw new XMLException("Element "+end.getName()+" is not valid:"+builder.toString());
                     }
                     Name name = end.getName();
                     boolean found = false;
                     for (int i=0; !found && i<names.length; i++) {
                        if (names[i].equals(name)) {
                           found = true;
                        }
                     }
                     if (!found) {
                        throw new XMLException("Unexpected document element "+name);
                     }
                  }
                  break;
            }
            output.send(item);
         }
         public void attach(ItemDestination output) {
            this.output = output;
         }
      };
      validate.attach(checkValidity);
      checkValidity.attach(end);
      return validate;
   }
View Full Code Here


      if (schemaMap!=null) {
         for (URI namespace : schemaMap.keySet()) {
            validate.addNamespaceMap(namespace,schemaMap.get(namespace));
         }
      }
      ItemFilter checkValidity = new ItemFilter() {
         ItemDestination output;
         int level = -1;
         public void send(Item item)
            throws XMLException
         {
            switch (item.getType()) {
               case DocumentItem:
                  level = -1;
                  break;
               case ElementItem:
                  level++;
                  break;
               case ElementEndItem:
                  level--;
                  ElementEnd end = (ElementEnd)item;
                  if (level<0) {
                     if (end.getValidity()!=Validity.VALID) {
                        StringBuilder builder = new StringBuilder();
                        Iterator errors = validate.getErrors();
                        while (errors.hasNext()) {
                           builder.append("\n");
                           builder.append(errors.next().toString());
                        }
                        throw new XMLException("Element "+end.getName()+" is not valid:"+builder.toString());
                     }
                     if (topLevelElements!=null) {
                        Name name = end.getName();
                        if (!topLevelElements.contains(name)) {
                           throw new XMLException("Unexpected document element "+name);
                        }
                     }
                  }
                  break;
            }
            output.send(item);
         }
         public void attach(ItemDestination output) {
            this.output = output;
         }
      };
      validate.attach(checkValidity);
      checkValidity.attach(end);
      return validate;
   }
View Full Code Here

                        File file = new File(dir,"."+entry.getUUID()+".atom");
                        try {
                           dest.send(constructor.createCharacters("\n"));
                           loader.generate(file.toURI(),
                              new RemoveDocumentFilter(
                                 new ItemFilter() {
                                    boolean started = false;
                                    public void send(Item item)
                                       throws XMLException
                                    {
                                       if (!started && item.getType()==Item.ItemType.ElementItem) {
View Full Code Here

                        if (response.getStatus().isSuccess()) {
                           try {
                              Reader r = response.getEntity().getReader();
                              loader.generate(r,
                                 new RemoveDocumentFilter(
                                    new ItemFilter() {
                                       boolean started = false;
                                       public void send(Item item)
                                          throws XMLException
                                       {
                                          /*
 
View Full Code Here

TOP

Related Classes of org.infoset.xml.filter.ItemFilter

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.