/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* $Id$ */

package xmp;

import java.net.URL;

import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamResult;

import org.apache.xmlgraphics.xmp.Metadata;
import org.apache.xmlgraphics.xmp.XMPArray;
import org.apache.xmlgraphics.xmp.XMPConstants;
import org.apache.xmlgraphics.xmp.XMPParser;
import org.apache.xmlgraphics.xmp.XMPProperty;
import org.apache.xmlgraphics.xmp.XMPSerializer;
import org.xml.sax.SAXException;

/**
 * This example shows how to parse an XMP metadata file.
 */
public class ParseMetadata {

    private static void parseMetadata() throws TransformerException, SAXException {
        URL url = ParseMetadata.class.getResource("pdf-example.xmp");
        Metadata meta = XMPParser.parseXMP(url);
        XMPProperty prop;
        prop = meta.getProperty(XMPConstants.DUBLIN_CORE_NAMESPACE, "creator");
        XMPArray array;
        array = prop.getArrayValue();
        for (int i = 0, c = array.getSize(); i < c; i++) {
            System.out.println("Creator: " + array.getValue(i));
        }
        prop = meta.getProperty(XMPConstants.DUBLIN_CORE_NAMESPACE, "title");
        System.out.println("Title: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.XMP_BASIC_NAMESPACE, "CreateDate");
        System.out.println("Creation Date: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.XMP_BASIC_NAMESPACE, "CreatorTool");
        System.out.println("Creator Tool: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.ADOBE_PDF_NAMESPACE, "Producer");
        System.out.println("Producer: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.ADOBE_PDF_NAMESPACE, "PDFVersion");
        System.out.println("PDF version: " + prop.getValue());
        
        StreamResult res = new StreamResult(System.out);
        XMPSerializer.writeXML(meta, res);
    }

    /**
     * Command-line interface.
     * @param args the command-line arguments
     */
    public static void main(String[] args) {
        try {
            parseMetadata();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

@@ -943,16 +943,50 @@
 esult;%0A%0A
+import org.xml.sax.SAXException;%0A%0A
 import o
@@ -1021,16 +1021,16 @@
 tadata;%0A
-
 import o
@@ -1265,36 +1265,124 @@
 ort org.
-xml.sax.SAXException
+apache.xmlgraphics.xmp.schemas.DublinCoreAdapter;%0Aimport org.apache.xmlgraphics.xmp.schemas.DublinCoreSchema
 ;%0A%0A/**%0A 
@@ -2050,24 +2050,62 @@
 , %22title%22);%0A
+        array = prop.getArrayValue();%0A
         Syst
@@ -2120,16 +2120,24 @@
 rintln(%22
+Default 
 Title: %22
@@ -2135,38 +2135,118 @@
  Title: %22 + 
-prop.get
+array.getSimpleValue());%0A        System.out.println(%22German Title: %22 + array.getLang
 Value(
+%22de%22
 ));%0A        
@@ -2745,24 +2745,24 @@
 FVersion%22);%0A
-
         Syst
@@ -2821,16 +2821,220 @@
        %0A
+        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);%0A        System.out.println(%22Default title: %22 + dc.getTitle());%0A        System.out.println(%22German title: %22 + dc.getTitle(%22de%22));%0A        %0A
         

Make example a bit more interesting.