Skip to content

Commit 0327558

Browse files
author
Steve Canny
committed
oxml: convert CT_Style to xmlchemy
1 parent d622225 commit 0327558

2 files changed

Lines changed: 21 additions & 39 deletions

File tree

‎docs/dev/analysis/schema/ct_styles.rst‎

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#############
1+
22
``CT_Styles``
3-
#############
3+
=============
44

55
.. highlight:: xml
66

@@ -17,7 +17,7 @@
1717

1818

1919
Analysis
20-
========
20+
--------
2121

2222
Only styles with an explicit ``<w:style>`` definition affect the formatting
2323
of paragraphs that are assigned that style.
@@ -34,26 +34,8 @@ is no longer used by any paragraphs. The definition of each of the styles
3434
ever used in a document are accumulated in ``styles.xml``.
3535

3636

37-
attributes
38-
^^^^^^^^^^
39-
40-
None.
41-
42-
43-
child elements
44-
^^^^^^^^^^^^^^
45-
46-
============ ==== ================
47-
name # type
48-
============ ==== ================
49-
docDefaults ? CT_DocDefaults
50-
latentStyles ? CT_LatentStyles
51-
style \* CT_TextParagraph
52-
============ ==== ================
53-
54-
5537
Spec text
56-
^^^^^^^^^
38+
---------
5739

5840
This element specifies all of the style information stored in the
5941
WordprocessingML document: style definitions as well as latent style
@@ -66,14 +48,14 @@ Spec text
6648

6749

6850
Schema excerpt
69-
^^^^^^^^^^^^^^
51+
--------------
7052

7153
::
7254

7355
<xsd:complexType name="CT_Styles">
7456
<xsd:sequence>
7557
<xsd:element name="docDefaults" type="CT_DocDefaults" minOccurs="0"/>
76-
<xsd:element name="latentStyles" type="CT_LatentStyles" minOccurs="0" maxOccurs="1"/>
58+
<xsd:element name="latentStyles" type="CT_LatentStyles" minOccurs="0"/>
7759
<xsd:element name="style" type="CT_Style" minOccurs="0" maxOccurs="unbounded"/>
7860
</xsd:sequence>
7961
</xsd:complexType>
@@ -99,7 +81,7 @@ Schema excerpt
9981

10082
<xsd:complexType name="CT_Style">
10183
<xsd:sequence>
102-
<xsd:element name="name" type="CT_String" minOccurs="0" maxOccurs="1"/>
84+
<xsd:element name="name" type="CT_String" minOccurs="0"/>
10385
<xsd:element name="aliases" type="CT_String" minOccurs="0"/>
10486
<xsd:element name="basedOn" type="CT_String" minOccurs="0"/>
10587
<xsd:element name="next" type="CT_String" minOccurs="0"/>
@@ -115,21 +97,21 @@ Schema excerpt
11597
<xsd:element name="personalCompose" type="CT_OnOff" minOccurs="0"/>
11698
<xsd:element name="personalReply" type="CT_OnOff" minOccurs="0"/>
11799
<xsd:element name="rsid" type="CT_LongHexNumber" minOccurs="0"/>
118-
<xsd:element name="pPr" type="CT_PPrGeneral" minOccurs="0" maxOccurs="1"/>
119-
<xsd:element name="rPr" type="CT_RPr" minOccurs="0" maxOccurs="1"/>
120-
<xsd:element name="tblPr" type="CT_TblPrBase" minOccurs="0" maxOccurs="1"/>
121-
<xsd:element name="trPr" type="CT_TrPr" minOccurs="0" maxOccurs="1"/>
122-
<xsd:element name="tcPr" type="CT_TcPr" minOccurs="0" maxOccurs="1"/>
100+
<xsd:element name="pPr" type="CT_PPrGeneral" minOccurs="0"/>
101+
<xsd:element name="rPr" type="CT_RPr" minOccurs="0"/>
102+
<xsd:element name="tblPr" type="CT_TblPrBase" minOccurs="0"/>
103+
<xsd:element name="trPr" type="CT_TrPr" minOccurs="0"/>
104+
<xsd:element name="tcPr" type="CT_TcPr" minOccurs="0"/>
123105
<xsd:element name="tblStylePr" type="CT_TblStylePr" minOccurs="0" maxOccurs="unbounded"/>
124106
</xsd:sequence>
125-
<xsd:attribute name="type" type="ST_StyleType" use="optional"/>
126-
<xsd:attribute name="styleId" type="s:ST_String" use="optional"/>
127-
<xsd:attribute name="default" type="s:ST_OnOff" use="optional"/>
128-
<xsd:attribute name="customStyle" type="s:ST_OnOff" use="optional"/>
107+
<xsd:attribute name="type" type="ST_StyleType"/>
108+
<xsd:attribute name="styleId" type="s:ST_String"/>
109+
<xsd:attribute name="default" type="s:ST_OnOff"/>
110+
<xsd:attribute name="customStyle" type="s:ST_OnOff"/>
129111
</xsd:complexType>
130112

131113
<xsd:complexType name="CT_LsdException">
132-
<xsd:attribute name="name" type="s:ST_String" use="required"/>
114+
<xsd:attribute name="name" type="s:ST_String" use="required"/>
133115
<xsd:attribute name="locked" type="s:ST_OnOff"/>
134116
<xsd:attribute name="uiPriority" type="ST_DecimalNumber"/>
135117
<xsd:attribute name="semiHidden" type="s:ST_OnOff"/>

‎docx/oxml/parts/styles.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
"""
66

77
from ..ns import qn
8-
from ..xmlchemy import BaseOxmlElement
8+
from ..xmlchemy import BaseOxmlElement, ZeroOrOne
99

1010

1111
class CT_Style(BaseOxmlElement):
1212
"""
1313
A ``<w:style>`` element, representing a style definition
1414
"""
15-
@property
16-
def pPr(self):
17-
return self.find(qn('w:pPr'))
15+
pPr = ZeroOrOne('w:pPr', successors=(
16+
'w:rPr', 'w:tblPr', 'w:trPr', 'w:tcPr', 'w:tblStylePr'
17+
))
1818

1919

2020
class CT_Styles(BaseOxmlElement):

0 commit comments

Comments
 (0)