OPC part names and referenes

MURATA Makoto eb2m-mrt at asahi-net.or.jp
Tue Jan 7 02:19:53 CET 2014


I did some more experiments using MS Office 2007 and .Net.

Here is my understanding.

- MS Office 2007 converts %HH to characters at
  least when %HH represents ASCII characters.

- MS Office 2007 resolves absolute-path references (
  which begins with "/") correctly.

- MS Office 2007 resolves relative-path references (
  which does not begin with "/") correctly.

- .Net (Package.GetPart) recognizes neither relative-path
  references nor %HH

I think that we should limit our concern to MS Office.  The .Net
implementation of OPC does not implement Annex A of Part 2
at all.

Regards,
Makoto

2013/12/28 MURATA Makoto <eb2m-mrt at asahi-net.or.jp>:
> 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



-- 

Praying for the victims of the Japan Tohoku earthquake

Makoto


More information about the sc34wg4 mailing list