OASIS Open Document Format for Office Applications (OpenDocument) TC

 View Only
  • 1.  May automatic styles defined in styles.xml be referenced from content.xml?

    Posted 03-05-2011 10:25
    Hi all, I've been working on some software to check style names and style references in ODF documents. During this work, the question arose: May automatic styles defined in styles.xml be referenced from content.xml? I've been digging through the specification versions to find an answer and strictly speaking it seems to be allowed since 1.2. For font-face-declarations a similar question can be asked. Here are statements on the topic that I could find: ODF 1.0 and 1.1 "<office:document-styles> Styles used in the document content and automatic styles used in the styles themselves. styles.xml" It does not say "only within the styles themselves", but "<office:document-content> Document content and automatic styles used in the content. content.xml" and "The <office:document-content> root contains only the document content, along with the automatic styles needed for the document content" implies that content.xml content does not look outside of content.xml for automatic styles. "The <office:document-styles> root contains all named styles of a document, along with the automatic styles needed for the named styles" ODF 1.2 public review draft 3 "The <office:document-content> root element contains document content and automatic styles used in a document. The file within the package for the <office:document-content> element is content.xml." "The <office:document-styles> root element contains styles used in document content and automatic styles used in styles. The file within the package for the <office:document-styles> element is styles.xml." "Styles and font face declarations are referenced by their style:name attribute. A referenced style or font face declaration should be defined in the same file as the reference, or in styles.xml." "For automatic styles, the name may be generated by OpenDocument producers. For each style family or style element, producers should generate distinct sets of names for automatic styles stored in the content.xml 3.1.3.2 and styles.xml 3.1.3.3 files. The names should also be distinct from the names used in the <office:styles> element inside the styles.xml files." Does this mean that a name for an automatic style of a certain family in content.xml must be distinct from the name of an automatic style of the same family in styles.xml? From the 1.0 and 1.1 specification, it appears that it is not allowed for automatic styles defined in styles.xml to be referenced from content.xml. But the 1.2 specification is less clear to me on this subject. Cheers, Jos


  • 2.  documenting and checking style names and references

    Posted 03-16-2011 09:45
    The styles in ODF are pretty complex. There are many different groups of style names and many places from which these keys can be referenced. For example, a style:style element can define a style, but depending on which of the twelve allowed values are in the style:family attribute and in which parent element (office:styles/style:style, office:document-styles/office:automatic- styles/style:style or office:document-content/office:automatic- styles/style:style). That gives 3 times 12 is 36 different groups of style names already, part of which overlap. In an attempt to make this situation more insightful for beginner and expert and have a tool for validating these names and references easily, I've written an xml file that lists the groups of style names and the places where they entries are defined and referenced. Here are two excerpts: The common style definitions for the text family are defined in office:styles and referenced by descendant styles. <key name="common-text-style"> <def>$officestyles/style:style[@style:family='text']/@style:name</def> <ref>$officestyles/style:style[@style:family='text']/@style:parent-style- name</ref> <ref>$stylesautostyles/style:style[@style:family='text']/@style:parent- style-name</ref> <ref>$contentautostyles/style:style[@style:family='text']/@style:parent- style-name</ref> </key> The styles that can be referenced in the body of the ODF are a combination of the styles defined in style:styles and style:automatic-styles in the current xml file. <key name="content-text-style" extends="common-text-style"> <def>$contentautostyles/style:style[@style:family='text']/@style:name</def> <ref>$body//text:span/@text:style-name</ref> <!--....--> </key> The <def> elements contain xpath expressions that form a list of strings. These are the defined names. No name should appear more than once. The <ref> elements contain xpath expressions that result in a list of references. Each entry in this list should occur in the list resulted from the <def>. The variables like $officestyles are filled in depending on ODF serialization. It can be /office:document/office:styles or /office:document-styles/office:styles depending on whether the ODF is flat or zip. The XML format makes it easy to test particular documents. The complete file is available in the WebODF project: http://gitorious.org/odfkit/webodf/trees/master/webodf/tools/refcheck It comes with an XSLT that forms a tool for checking. In two steps , one can run a check. I'm using xsltproc here, but any xslt software should work. xsltproc bootstrap.xsl odfkeys.xml > checkkeys.xsl xsltproc checkkeys.xsl content.xml Instead of content.xml, one can also test on styles.xml or on a flat xml ODF. I hope this approach can help make the use of styles in ODF more insightful. Cheers, Jos


  • 3.  Re: [office] May automatic styles defined in styles.xml be referencedfrom content.xml?

    Posted 03-18-2011 15:22
    Hi Jos, On 05.03.2011 11:24, Jos van den Oever wrote: 201103051124.50794.jos@vandenoever.info type= cite > Hi all, I've been working on some software to check style names and style references in ODF documents. During this work, the question arose: May automatic styles defined in styles.xml be referenced from content.xml? I've been digging through the specification versions to find an answer and strictly speaking it seems to be allowed since 1.2. Well, at least the intention was that automatic styles in styles.xml cannot be referenced from content.xml. Why? Document styles are stored in a separate file because it is a common tasks to replace them with a different set of styles. That's much easier and much faster (from the perspective of I/O and CPU cycles) if they are separate from the content, because the content has not to be touched for this purpose. However, exchanging styles in styles.xml is only a simple task if the automatic styles that are used in styles.xml are not referenced in content.xml. If they are referenced in content.xml, one would either has to analyze which automatic styles are referenced outside styles.xml, or would have to keep all of them. 201103051124.50794.jos@vandenoever.info type= cite > For font-face-declarations a similar question can be asked. Right. See below. 201103051124.50794.jos@vandenoever.info type= cite > ODF 1.2 public review draft 3 The <office:document-content> root element contains document content and automatic styles used in a document. The file within the package for the <office:document-content> element is content.xml. The <office:document-styles> root element contains styles used in document content and automatic styles used in styles. The file within the package for the <office:document-styles> element is styles.xml. Styles and font face declarations are referenced by their style:name attribute. A referenced style or font face declaration should be defined in the same file as the reference, or in styles.xml. This means that content.xml may reference fonts in styles.xml, doesn't it? 201103051124.50794.jos@vandenoever.info type= cite > For automatic styles, the name may be generated by OpenDocument producers. For each style family or style element, producers should generate distinct sets of names for automatic styles stored in the content.xml 3.1.3.2 and styles.xml 3.1.3.3 files. The names should also be distinct from the names used in the <office:styles> element inside the styles.xml files. Does this mean that a name for an automatic style of a certain family in content.xml must be distinct from the name of an automatic style of the same family in styles.xml? Its a should rather than a shall or must . So, yes the names should be distinct, but they don't have to. 201103051124.50794.jos@vandenoever.info type= cite > From the 1.0 and 1.1 specification, it appears that it is not allowed for automatic styles defined in styles.xml to be referenced from content.xml. But the 1.2 specification is less clear to me on this subject. Do you have a suggestion where we should be clearer? If so, please don't hesitate to enter an ODF 1.3 JIRA issue for this. Best regards Michael -- Michael Brauer Oracle Office Development Phone: +49 40 23646 500 Oracle Office Global Business Unit ORACLE Deutschland B.V. & Co. KG Nagelsweg 55 20097 Hamburg ORACLE Deutschland B.V. & Co. KG Hauptverwaltung: Riesstr. 25, D-80992 München Registergericht: Amtsgericht München, HRA 95603 Komplementärin: ORACLE Deutschland Verwaltung B.V. Rijnzathe 6, 3454PV De Meern, Niederlande Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697 Geschäftsführer: Jürgen Kunz, Marcel van de Molen, Alexander van der Ven Oracle is committed to developing practices and products that help protect the environment


  • 4.  Re: [office] May automatic styles defined in styles.xml be referenced from content.xml?

    Posted 03-21-2011 13:11
    On Friday, March 18, 2011 16:21:55 pm MICHAEL BRAUER wrote: > Hi Jos, > > On 05.03.2011 11:24, Jos van den Oever wrote: > > Hi all, > > > > I've been working on some software to check style names and style > > references in ODF documents. During this work, the question arose: May > > automatic styles defined in styles.xml be referenced from content.xml? > > I've been digging through the specification versions to find an answer > > and strictly speaking it seems to be allowed since 1.2. > > Well, at least the intention was that automatic styles in styles.xml > cannot be referenced from content.xml. > > Why? Document styles are stored in a separate file because it is a > common tasks to replace them with a different set of styles. That's much > easier and much faster (from the perspective of I/O and CPU cycles) if > they are separate from the content, because the content has not to be > touched for this purpose. However, exchanging styles in styles.xml is > only a simple task if the automatic styles that are used in styles.xml > are not referenced in content.xml. If they are referenced in > content.xml, one would either has to analyze which automatic styles are > referenced outside styles.xml, or would have to keep all of them. > > > For font-face-declarations a similar question can be asked. > > Right. See below. > > > ODF 1.2 public review draft 3 > > > > "The<office:document-content> root element contains document content and > > automatic styles used in a document. The file within the package for the > > <office:document-content> element is content.xml." > > > > "The<office:document-styles> root element contains styles used in > > document content and automatic styles used in styles. The file within > > the package for the<office:document-styles> element is styles.xml." > > > > "Styles and font face declarations are referenced by their style:name > > attribute. A referenced style or font face declaration should be defined > > in the same file as the reference, or in styles.xml." > > This means that content.xml may reference fonts in styles.xml, doesn't it? Yes, it does. The latest stable version of LibreOffice that I use saves the same font face declarations under the same name in both content.xml and styles.xml. Given the above sentence, this should not be allowed. If it would be allowed, the document should state in what order the styles of a given name are to be used, i.e. should the definition in content.xml or the one in styles.xml be used. I think it would be best to simply say that the names must be distinct. > > "For automatic styles, the name may be generated by OpenDocument > > producers. For each style family or style element, producers should > > generate distinct sets of names for automatic styles stored in the > > content.xml 3.1.3.2 and styles.xml 3.1.3.3 files. The names should also > > be distinct from the names used in the<office:styles> element inside > > the styles.xml files." > > > > Does this mean that a name for an automatic style of a certain family in > > content.xml must be distinct from the name of an automatic style of the > > same family in styles.xml? > > Its a "should" rather than a "shall" or "must". So, yes the names should > be distinct, but they don't have to. Since these are separate groups of style names, it does no harm to have the same name re-used. > > From the 1.0 and 1.1 specification, it appears that it is not allowed > > for > > > > automatic styles defined in styles.xml to be referenced from content.xml. > > But the 1.2 specification is less clear to me on this subject. > > Do you have a suggestion where we should be clearer? If so, please don't > hesitate to enter an ODF 1.3 JIRA issue for this. Would this be 1.3 or a 1.2 errata? Cheers, Jos