Package org.purl.sword.base

Examples of org.purl.sword.base.SwordValidationInfo


               generator = new Generator();
               generator.unmarshall(element);
            }
            else
            {
               SwordValidationInfo info = new SwordValidationInfo(new XmlName(element),
                       SwordValidationInfo.UNKNOWN_ELEMENT,
                       SwordValidationInfoType.INFO);
               info.setContentDescription(element.getValue());
               validationItems.add(info);
            }
         }
      }
      catch( Exception ex )
      {
         log.error("Unable to parse an element in Source: " + ex.getMessage());
         throw new UnmarshallException("Unable to parse an element in Source", ex);
      }

      SwordValidationInfo result = null;
      if( validationProperties != null )
      {
          result = validate(validationItems, attributeItems, validationProperties);
      }
      return result;
View Full Code Here


   public SwordValidationInfo validate(ArrayList<SwordValidationInfo> elements,
           ArrayList<SwordValidationInfo> attributes,
           Properties validationContext)
   {
       SwordValidationInfo result = new SwordValidationInfo(xmlName);
      
      
       result.addUnmarshallValidationInfo(elements, attributes);
       return result;
   }
View Full Code Here

                  attributes.add(createValidAttributeInfo(ATTRIBUTE_SRC, source));
               }
            }
            else
            {
               SwordValidationInfo info = new SwordValidationInfo(xmlName,
                       new XmlName(attribute),
                       SwordValidationInfo.UNKNOWN_ATTRIBUTE,
                       SwordValidationInfoType.INFO );
                info.setContentDescription(attribute.getValue());
                attributes.add(info);
            }
         }

         // check if there is any content. If there is, add a simple message to
         // say that there are sub elements that are not used in this profile
         if( content.getChildCount() > 0 )
         {
            elements.add(new SwordValidationInfo(xmlName,
                    "This element has child elements. These are not expected as part of the SWORD profile",
                    SwordValidationInfoType.INFO));
         }

      }
      catch( Exception ex )
      {
         log.error("Unable to parse an element in Content: " + ex.getMessage());
         throw new UnmarshallException("Error parsing Content", ex);
      }

      SwordValidationInfo result = null;
      if( validationProperties != null )
      {
          result = validate(elements, attributes, validationProperties);
      }
      return result;
View Full Code Here

    */
   protected SwordValidationInfo validate(ArrayList<SwordValidationInfo> elements,
           ArrayList<SwordValidationInfo> attributes,
           Properties validationContext)
   {
       SwordValidationInfo info = new SwordValidationInfo(xmlName);

       if( source == null )
       {
           XmlName attributeName = new XmlName(xmlName.getPrefix(),
                       ATTRIBUTE_SRC,
                       xmlName.getNamespace());

          SwordValidationInfo item = new SwordValidationInfo(xmlName, attributeName,
                  SwordValidationInfo.MISSING_ATTRIBUTE_WARNING,
                  SwordValidationInfoType.ERROR);
          info.addValidationInfo(item);
       }

View Full Code Here

            }
            else
            {
               XmlName attributeName = new XmlName(attribute);

               SwordValidationInfo unknown = new SwordValidationInfo(xmlName,
                       attributeName,
                       SwordValidationInfo.UNKNOWN_ATTRIBUTE,
                       SwordValidationInfoType.INFO);
               unknown.setContentDescription(attribute.getValue());
               attributeItems.add(unknown);
            }
         }

         if( link.getChildCount() > 0 )
         {
             SwordValidationInfo content = new SwordValidationInfo(xmlName,
                     "This element has content, but it is not used by SWORD",
                     SwordValidationInfoType.INFO);
             validationItems.add(content);
         }

      }
      catch( Exception ex )
      {
         log.error("Unable to parse an element in Link: " + ex.getMessage());
         throw new UnmarshallException("Unable to parse element in link", ex);
      }

      SwordValidationInfo result = null;
      if( validationProperties != null )
      {
          result = validate(validationItems, attributeItems, validationProperties);
      }
      return result;
View Full Code Here

           ArrayList<SwordValidationInfo> attributes,
           Properties validationContext)
   {
       boolean validateAll = (elements == null);

       SwordValidationInfo result = new SwordValidationInfo(xmlName);

       if( href == null )
       {
          XmlName attributeName = new XmlName(xmlName.getPrefix(),
                       ATTRIBUTE_HREF,
                       xmlName.getNamespace());

          SwordValidationInfo item = new SwordValidationInfo(xmlName, attributeName,
                  SwordValidationInfo.MISSING_ATTRIBUTE_WARNING,
                  SwordValidationInfoType.ERROR);
          result.addAttributeValidationInfo(item);
       }
View Full Code Here

            email = new Email();
            validationItems.add(email.unmarshall(element, validationProperties));
         }
         else if( validationProperties != null )
         {
            SwordValidationInfo info = new SwordValidationInfo(new XmlName(element),
                    SwordValidationInfo.UNKNOWN_ELEMENT,
                    SwordValidationInfoType.INFO);
            info.setContentDescription(element.getValue());
            validationItems.add(info);
         }

      } // for

      SwordValidationInfo result = null;
      if( validationProperties != null )
      {
          result = validate(validationItems, attributeItems, validationProperties);
      }
      return result;
View Full Code Here

   public SwordValidationInfo validate(ArrayList<SwordValidationInfo> elements,
           ArrayList<SwordValidationInfo> attributes,
           Properties validationContext)
   {
       SwordValidationInfo result = new SwordValidationInfo(xmlName);

       if( name == null )
       {
           SwordValidationInfo info = new SwordValidationInfo(Name.elementName(),
                   SwordValidationInfo.MISSING_ELEMENT_ERROR,
                   SwordValidationInfoType.ERROR);
           result.addValidationInfo(info);
       }
       else if( elements == null && name != null)
View Full Code Here

             type = ContentType.XHTML;
           }
           else
           {
             log.error("Unable to parse extract type in " + getQualifiedName() );
                       SwordValidationInfo info = new SwordValidationInfo(xmlName,
                                  new XmlName(attribute),
                                  "Invalid content type has been specified",
                                  SwordValidationInfoType.ERROR);
                       info.setContentDescription(value);
                       attributeItems.add(info);
                       success = false;
           }

                   if( success )
                   {
                       SwordValidationInfo info = new SwordValidationInfo(xmlName, new XmlName(attribute));
                       info.setContentDescription(type.toString());
                       attributeItems.add(info);
                   }
         }
               else
               {
                   SwordValidationInfo info = new SwordValidationInfo(xmlName,
                              new XmlName(attribute),
                              SwordValidationInfo.UNKNOWN_ATTRIBUTE,
                              SwordValidationInfoType.INFO);
                   info.setContentDescription(attribute.getValue());
                   attributeItems.add(info);
               }
       }

       // retrieve all of the sub-elements
       int length = text.getChildCount();
       if( length > 0 )
       {
         content = unmarshallString(text);
           }

     }
     catch( Exception ex )
     {
       log.error("Unable to parse an element in " + getQualifiedName() + ": " + ex.getMessage());
       throw new UnmarshallException("Unable to parse an element in " + getQualifiedName(), ex);
     }

       SwordValidationInfo result = null;
       if( validationProperties != null )
       {
           result = validate(validationItems, attributeItems, validationProperties);
       }
       return result;
View Full Code Here

           ArrayList<SwordValidationInfo> attributeItems,
           Properties validationContext)
   {
      boolean validateAll = (existing == null);

      SwordValidationInfo result = new SwordValidationInfo(xmlName);
      result.setContentDescription(content);
     
      // item specific rules
      if( content == null )
      {
          result.addValidationInfo(
                  new SwordValidationInfo(xmlName, "Missing content for element",
                                          SwordValidationInfoType.WARNING));
      }

      if( validateAll )
      {
          SwordValidationInfo info = new SwordValidationInfo(xmlName,
                  new XmlName(xmlName.getPrefix(), ATTRIBUTE_TYPE, xmlName.getNamespace()));
          info.setContentDescription(type.toString());
          result.addAttributeValidationInfo(info);

      }

      result.addUnmarshallValidationInfo(existing, attributeItems);
View Full Code Here

TOP

Related Classes of org.purl.sword.base.SwordValidationInfo

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.