%context --ctx=t-openoffice BoldAndItalicContent.xml

\startenvironment t-openoffice.tex

  \startxmlsetups office
    \xmlsetsetup{main}{text:p|text:span}{*}
  \stopxmlsetups
  \xmlregistersetup{office}

  \startxmlsetups text:p
    \xmlflush{#1}\endgraf
  \stopxmlsetups

  \startxmlsetups text:span
    \bgroup
      \xmlfilter{main}{office:automatic-styles/style:style[@style:name='\xmlatt{#1}{style-name}']/style:text-properties/command(do:style:text-properties)}
      \xmlflush{#1}
    \egroup
  \stopxmlsetups

  \startxmlsetups do:style:text-properties
    \xmlval{fo:font-weight}{\xmlatt{#1}{font-weight}}{}% todo: namespaces in attributes
    \xmlval{fo:font-style}{\xmlatt{#1}{font-style}}{}
    \xmlval{fo:color}{\xmlatt{#1}{color}}{}
    \xmlval{style:text-position}{\xmlatt{#1}{text-position}}{}
    %\xmlval{style:text-underline-style}{\xmlatt{#1}{text-underline-style}}{}
  \stopxmlsetups

  \xmlmapvalue{fo:font-weight}{bold}{\bf}
  \xmlmapvalue{fo:font-style}{italic}{\it}
  \xmlmapvalue{fo:color}{#ff0000}{\color[ff0000]}
  
%  \xmlmapvalue{style:text-position}{sub 58\%}{\subscript}
%  \xmlmapvalue{style:text-position}{super*}{\superscript}
  %\xmlmapvalue{style:text-underline-style}{solid}{\startunderline}{\stopunderline}

  \starttext
    \setupcolors[state=start]
    %\xmlprocess{main}{zip:///\inputfilename.odt?name=content.xml}{}
    \usezipfile[\inputfilename.odt]
    \xmlprocess{main}{*/content.xml}{}
  \stoptext
  
\stopenvironment


