OPC part names and referenes
MURATA Makoto
eb2m-mrt at asahi-net.or.jp
Sat Dec 28 15:25:26 CET 2013
The more I think about OPC, the more confused I am.
I have thought that references to OPC parts ("Unicode string"
in Annex A of OPC) can contain non-ASCII characaters and
that such non-ASCII characters are percent-encoded before
referenced OPC parts are located. I have also thought that
references to OPC parts are resolved relative to containing
OPC parts when they do not begin with "/".
However, my experiment with .Net in F# appears to
show I am mistaken. It reports errors if references to
OPC parts contain non-ASCII characters. Ir also
reports errors if references to OPC parts do not begin
with "/".
I plan to manually edit OOXML documents and XPS
documents and handle them by MS-Office and XPS
viewers.
Here is my F# program.
open System.IO.Packaging
open System
let readOPC() =
let package = Package.Open("f:test.opc", IO.FileMode.Open)
let uri = new Uri(Uri.EscapeUriString "/fあ/f1", UriKind.Relative)
let part = package.GetPart(uri)
let enum = part.GetRelationships().GetEnumerator()
while (enum.MoveNext()) do
let relship = enum.Current
let targetURI = relship.TargetUri
try
let targetPart = package.GetPart(targetURI)
let s = targetPart.GetStream()
System.Console.WriteLine("Success: {0} {1}", targetURI,
s.ReadByte())
with
| :? System.ArgumentException ->
System.Console.WriteLine("Error: {0}", targetURI)
package.Close()
readOPC()
Regards,
Makoto
More information about the sc34wg4
mailing list