Package com.adactus.mpeg21.didl.xml

Examples of com.adactus.mpeg21.didl.xml.DigitalItemDeclarationsFactory


  private DigitalItemDeclarationsManagerLocal digitalItemDeclarationsManager;

  @PostConstruct
  public void init() {
    try {
      digitalItemDeclarationsDocumentSource = new DigitalItemDeclarationsDocumentSource("schema/didmodel.xsd", "schema/didl.xsd");
    } catch (Exception e) {
      throw new RuntimeException("Initialization failed", e);
    }
  }
View Full Code Here


 
  public D unmarshal(String encoding, InputStream in) throws XMLStreamException, IOException {
   
    if(in == null) throw new RuntimeException();
   
    NamespaceXMLBinding mBinding = getDIDLBinding();
     
    Reader reader;
    if(encoding == null) {
      reader = new InputStreamReader(in);
    } else {
View Full Code Here

        objectReader.close();
      }
  }

  private NamespaceXMLBinding getDIDLBinding() {
    NamespaceXMLBinding binding = new NamespaceXMLBinding();

    binding.setAlias(DIDLType.class,DIDLType.DIDLNS,"DIDL");
    binding.setAlias(AnchorType.class,DIDLType.DIDLNS,"Anchor");
    binding.setAlias(AnnotationType.class,DIDLType.DIDLNS,"Annotation");
    binding.setAlias(AssertionType.class,DIDLType.DIDLNS,"Assertion");
    binding.setAlias(ChoiceType.class,DIDLType.DIDLNS,"Choice");
    binding.setAlias(ComponentType.class,DIDLType.DIDLNS,"Component");
    binding.setAlias(ConditionType.class,DIDLType.DIDLNS,"Condition");
    binding.setAlias(ContainerType.class,DIDLType.DIDLNS,"Container");
    binding.setAlias(DescriptorType.class,DIDLType.DIDLNS,"Descriptor");
    binding.setAlias(FragmentType.class,DIDLType.DIDLNS,"Fragment");
    binding.setAlias(ItemType.class,DIDLType.DIDLNS,"Item");
    binding.setAlias(ResourceType.class,DIDLType.DIDLNS,"Resource");
    binding.setAlias(SelectionType.class,DIDLType.DIDLNS,"Selection");
    binding.setAlias(StatementType.class,DIDLType.DIDLNS,"Statement");
    binding.setAlias(DeclarationsType.class,DIDLType.DIDLNS,"Declarations");
 
    // want more objects? Fork this factory and write your own!
   
    return binding;
  }
View Full Code Here

   * @param xml
   * @throws Exception
   */
 
  public void validateDigitalItemDeclaration(byte[] xml, String encoding) throws Exception {
    ValidatingDocumentSource validatingDocumentSource = new ValidatingDocumentSource(true);
   
    validatingDocumentSource.setSchema(new String[]{"src/main/resources/schema/didmodel.xsd", "src/main/resources/schema/didl.xsd"});
     
    validatingDocumentSource.initFactory();
    validatingDocumentSource.initBuilder();

    Schema schema = validatingDocumentSource.getSchema();
    Validator v = schema.newValidator();
    if(encoding == null) {
      v.validate(new SAXSource(new InputSource(new ByteArrayInputStream(xml))) );
    } else {
      v.validate(new SAXSource(new InputSource(new InputStreamReader(new ByteArrayInputStream(xml), encoding))) );
    }
    assertTrue(!validatingDocumentSource.wasError());
    assertTrue(!validatingDocumentSource.wasFatalError());
    assertTrue(!validatingDocumentSource.wasWaring());
  }
View Full Code Here

TOP

Related Classes of com.adactus.mpeg21.didl.xml.DigitalItemDeclarationsFactory

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.