5 namespace Beagle
.Util
{
6 public class XmpFile
: SemWeb
.StatementSource
, SemWeb
.StatementSink
10 public MetadataStore Store
{
14 public XmpFile (System
.IO
.Stream stream
) : this ()
21 store
= new MetadataStore ();
24 public void Load (System
.IO
.Stream stream
)
27 store
.Import (new SemWeb
.RdfXmlReader (stream
));
29 } catch (System
.Exception e
) {
30 System
.Console
.WriteLine (e
.ToString ());
34 public void Save (System
.IO
.Stream stream
)
40 text
= new XmlTextWriter (stream
, System
.Text
.Encoding
.UTF8
);
41 using (writer
= new RdfXmlWriter (text
, MetadataStore
.Namespaces
)) {
42 text
.WriteProcessingInstruction ("xpacket", "begin=\"\ufeff\" id=\"testing\"");
43 text
.WriteStartElement ("x:xmpmeta");
44 text
.WriteAttributeString ("xmlns", "x", null, "adobe:ns:meta/");
45 store
.Select (writer
);
48 text
.WriteEndElement ();
49 text
.WriteProcessingInstruction ("xpacket", "end=\"r\"");
52 } catch (System
.Exception e
) {
53 System
.Console
.WriteLine (e
);
57 public bool Add (Statement stmt
)
59 return ((SemWeb
.StatementSink
)store
).Add (stmt
);
62 public void Select (SemWeb
.StatementSink sink
)
69 foreach (SemWeb
.Statement stmt
in store
) {
70 System
.Console
.WriteLine(stmt
);
75 static void Main (string [] args
)
77 XmpFile xmp
= new XmpFile (System
.IO
.File
.OpenRead (args
[0]));
80 System
.IO
.StreamReader stream
= new System
.IO
.StreamReader (System
.IO
.File
.OpenRead (args
[0]));
82 while (stream
.BaseStream
.Position
< stream
.BaseStream
.Length
) {
83 System
.Console
.WriteLine (stream
.ReadLine ());