DTDValidatingReader.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. using System;
  2. using System.Collections.Specialized;
  3. using System.Collections;
  4. using System.Text;
  5. using System.Xml;
  6. using System.Xml.Schema;
  7. namespace Mono.Xml
  8. {
  9. public class DTDValidatingReader : /*XmlValidatingReader*/XmlReader, IXmlLineInfo
  10. {
  11. public DTDValidatingReader (XmlReader reader)
  12. : this (reader, null)
  13. {
  14. }
  15. public DTDValidatingReader (XmlReader reader,
  16. XmlValidatingReader validatingReader)
  17. // : base (reader)
  18. {
  19. this.reader = reader;
  20. this.sourceTextReader = reader as XmlTextReader;
  21. elementStack = new Stack ();
  22. automataStack = new Stack ();
  23. attributes = new StringCollection ();
  24. attributeValues = new NameValueCollection ();
  25. this.validatingReader = validatingReader;
  26. valueBuilder = new StringBuilder ();
  27. idList = new ArrayList ();
  28. missingIDReferences = new ArrayList ();
  29. }
  30. XmlReader reader;
  31. XmlTextReader sourceTextReader;
  32. DTDObjectModel dtd;
  33. Stack elementStack;
  34. Stack automataStack;
  35. string currentElement;
  36. string currentAttribute;
  37. bool consumedAttribute;
  38. bool insideContent;
  39. // bool insideAttributeValue;
  40. DTDAutomata currentAutomata;
  41. DTDAutomata previousAutomata;
  42. bool isStandalone;
  43. StringCollection attributes;
  44. NameValueCollection attributeValues;
  45. StringBuilder valueBuilder;
  46. ArrayList idList;
  47. ArrayList missingIDReferences;
  48. XmlValidatingReader validatingReader;
  49. // ValidationEventHandler handler;
  50. public DTDObjectModel DTD {
  51. get { return dtd; }
  52. }
  53. public override void Close ()
  54. {
  55. reader.Close ();
  56. }
  57. // We had already done attribute validation, so can ignore name.
  58. public override string GetAttribute (int i)
  59. {
  60. if (dtd == null)
  61. return reader.GetAttribute (i);
  62. if (attributes.Count <= i)
  63. throw new IndexOutOfRangeException ("Specified index is out of range: " + i);
  64. return FilterNormalization (attributeValues [i]);
  65. }
  66. public override string GetAttribute (string name)
  67. {
  68. if (dtd == null)
  69. return reader.GetAttribute (name);
  70. return FilterNormalization (attributeValues [name]);
  71. }
  72. public override string GetAttribute (string name, string ns)
  73. {
  74. if (dtd == null)
  75. return reader.GetAttribute (name, ns);
  76. // FIXME: check whether this way is correct.
  77. if (ns == String.Empty)
  78. return GetAttribute (name);
  79. else
  80. return FilterNormalization (reader.GetAttribute (name, ns));
  81. }
  82. bool IXmlLineInfo.HasLineInfo ()
  83. {
  84. IXmlLineInfo ixli = reader as IXmlLineInfo;
  85. if (ixli != null)
  86. return ixli.HasLineInfo ();
  87. else
  88. return false;
  89. }
  90. public override string LookupNamespace (string prefix)
  91. {
  92. // Does it mean anything with DTD?
  93. return reader.LookupNamespace (prefix);
  94. }
  95. public override void MoveToAttribute (int i)
  96. {
  97. if (dtd == null) {
  98. reader.MoveToAttribute (i);
  99. currentAttribute = reader.Name;
  100. consumedAttribute = false;
  101. return;
  102. }
  103. if (currentElement == null)
  104. return;
  105. if (attributes.Count > i) {
  106. currentAttribute = attributes [i];
  107. consumedAttribute = false;
  108. return;
  109. } else
  110. throw new IndexOutOfRangeException ("The index is out of range.");
  111. }
  112. public override bool MoveToAttribute (string name)
  113. {
  114. if (dtd == null) {
  115. bool b = reader.MoveToAttribute (name);
  116. if (b) {
  117. currentAttribute = reader.Name;
  118. consumedAttribute = false;
  119. }
  120. return b;
  121. }
  122. if (currentElement == null)
  123. return false;
  124. int idx = attributes.IndexOf (name);
  125. if (idx >= 0) {
  126. currentAttribute = name;
  127. consumedAttribute = false;
  128. return true;
  129. }
  130. return false;
  131. }
  132. public override bool MoveToAttribute (string name, string ns)
  133. {
  134. if (dtd == null) {
  135. bool b = reader.MoveToAttribute (name, ns);
  136. if (b) {
  137. currentAttribute = reader.Name;
  138. consumedAttribute = false;
  139. }
  140. return b;
  141. }
  142. if (reader.MoveToAttribute (name, ns)) {
  143. currentAttribute = reader.Name;
  144. consumedAttribute = false;
  145. return true;
  146. }
  147. if (ns != String.Empty)
  148. throw new InvalidOperationException ("DTD validating reader does not support namespace.");
  149. return MoveToAttribute (name);
  150. }
  151. public override bool MoveToElement ()
  152. {
  153. bool b = reader.MoveToElement ();
  154. if (!b)
  155. return false;
  156. currentAttribute = null;
  157. consumedAttribute = false;
  158. return true;
  159. }
  160. public override bool MoveToFirstAttribute ()
  161. {
  162. if (dtd == null) {
  163. bool b = reader.MoveToFirstAttribute ();
  164. if (b) {
  165. currentAttribute = reader.Name;
  166. consumedAttribute = false;
  167. }
  168. return b;
  169. }
  170. // It should access attributes by *defined* order.
  171. if (NodeType != XmlNodeType.Element)
  172. return false;
  173. if (attributes.Count == 0)
  174. return false;
  175. reader.MoveToFirstAttribute ();
  176. currentAttribute = attributes [0];
  177. consumedAttribute = false;
  178. return true;
  179. }
  180. public override bool MoveToNextAttribute ()
  181. {
  182. if (dtd == null) {
  183. bool b = reader.MoveToNextAttribute ();
  184. if (b) {
  185. currentAttribute = reader.Name;
  186. consumedAttribute = false;
  187. }
  188. return b;
  189. }
  190. if (currentAttribute == null)
  191. return MoveToFirstAttribute ();
  192. int idx = attributes.IndexOf (currentAttribute);
  193. if (idx + 1 < attributes.Count) {
  194. reader.MoveToNextAttribute ();
  195. currentAttribute = attributes [idx + 1];
  196. consumedAttribute = false;
  197. return true;
  198. } else
  199. return false;
  200. }
  201. [MonoTODO]
  202. public override bool Read ()
  203. {
  204. MoveToElement ();
  205. bool b = reader.Read ();
  206. currentElement = null;
  207. currentAttribute = null;
  208. consumedAttribute = false;
  209. attributes.Clear ();
  210. attributeValues.Clear ();
  211. if (!insideContent && reader.NodeType == XmlNodeType.Element) {
  212. insideContent = true;
  213. if (dtd == null)
  214. currentAutomata = null;
  215. else
  216. currentAutomata = dtd.RootAutomata;
  217. }
  218. if (!b) {
  219. if (elementStack.Count != 0)
  220. throw new InvalidOperationException ("Unexpected end of XmlReader.");
  221. return false;
  222. }
  223. switch (reader.NodeType) {
  224. case XmlNodeType.XmlDeclaration:
  225. if (GetAttribute ("standalone") == "yes")
  226. isStandalone = true;
  227. break;
  228. case XmlNodeType.DocumentType:
  229. XmlTextReader xmlTextReader = reader as XmlTextReader;
  230. if (xmlTextReader == null) {
  231. xmlTextReader = new XmlTextReader ("", XmlNodeType.Document, null);
  232. xmlTextReader.GenerateDTDObjectModel (reader.Name,
  233. reader ["PUBLIC"], reader ["SYSTEM"], reader.Value);
  234. }
  235. this.dtd = xmlTextReader.DTD;
  236. break;
  237. case XmlNodeType.Element: // startElementDeriv
  238. // If no schema specification, then skip validation.
  239. if (currentAutomata == null) {
  240. SetupValidityIgnorantAttributes ();
  241. break;
  242. }
  243. previousAutomata = currentAutomata;
  244. currentAutomata = currentAutomata.TryStartElement (reader.Name);
  245. if (currentAutomata == DTD.Invalid) {
  246. HandleError (String.Format ("Invalid start element found: {0}", reader.Name),
  247. XmlSeverityType.Error);
  248. // FIXME: validation recovery code here.
  249. currentAutomata = previousAutomata;
  250. }
  251. DTDElementDeclaration decl = DTD.ElementDecls [reader.Name];
  252. if (decl == null) {
  253. HandleError (String.Format ("Element {0} is not declared.", reader.Name),
  254. XmlSeverityType.Error);
  255. // FIXME: validation recovery code here.
  256. currentAutomata = previousAutomata;
  257. }
  258. currentElement = Name;
  259. elementStack.Push (reader.Name);
  260. automataStack.Push (currentAutomata);
  261. if (decl != null) // i.e. not invalid
  262. currentAutomata = decl.ContentModel.GetAutomata ();
  263. DTDAttListDeclaration attList = dtd.AttListDecls [currentElement];
  264. if (attList != null) {
  265. // check attributes
  266. ValidateAttributes (attList);
  267. } else {
  268. if (reader.HasAttributes) {
  269. HandleError (String.Format (
  270. "Attributes are found on element {0} while it has no attribute definitions.", currentElement),
  271. XmlSeverityType.Error);
  272. // FIXME: validation recovery code here.
  273. }
  274. SetupValidityIgnorantAttributes ();
  275. }
  276. // If it is empty element then directly check end element.
  277. if (reader.IsEmptyElement)
  278. goto case XmlNodeType.EndElement;
  279. break;
  280. case XmlNodeType.EndElement: // endElementDeriv
  281. // If no schema specification, then skip validation.
  282. if (currentAutomata == null)
  283. break;
  284. decl = DTD.ElementDecls [reader.Name];
  285. if (decl == null) {
  286. HandleError (String.Format ("Element {0} is not declared.", reader.Name),
  287. XmlSeverityType.Error);
  288. // FIXME: validation recovery code here.
  289. }
  290. previousAutomata = currentAutomata;
  291. // Don't let currentAutomata
  292. DTDAutomata tmpAutomata = currentAutomata.TryEndElement ();
  293. if (tmpAutomata == DTD.Invalid) {
  294. HandleError (String.Format ("Invalid end element found: {0}", reader.Name),
  295. XmlSeverityType.Error);
  296. // FIXME: validation recovery code here.
  297. currentAutomata = previousAutomata;
  298. }
  299. elementStack.Pop ();
  300. currentAutomata = automataStack.Pop () as DTDAutomata;
  301. break;
  302. case XmlNodeType.CDATA:
  303. case XmlNodeType.SignificantWhitespace:
  304. case XmlNodeType.Text:
  305. // If no schema specification, then skip validation.
  306. if (currentAutomata == null)
  307. break;
  308. DTDElementDeclaration elem = dtd.ElementDecls [elementStack.Peek () as string];
  309. // Here element should have been already validated, so
  310. // if no matching declaration is found, simply ignore.
  311. if (elem != null && !elem.IsMixedContent) {
  312. HandleError (String.Format ("Current element {0} does not allow character data content.", elementStack.Peek () as string),
  313. XmlSeverityType.Error);
  314. // FIXME: validation recovery code here.
  315. currentAutomata = previousAutomata;
  316. }
  317. break;
  318. }
  319. return true;
  320. }
  321. private void SetupValidityIgnorantAttributes ()
  322. {
  323. if (reader.MoveToFirstAttribute ()) {
  324. // If it was invalid, simply add specified attributes.
  325. do {
  326. attributes.Add (reader.Name);
  327. attributeValues.Add (reader.Name, reader.Value);
  328. } while (reader.MoveToNextAttribute ());
  329. reader.MoveToElement ();
  330. }
  331. }
  332. private void HandleError (string message, XmlSeverityType severity)
  333. {
  334. if (validatingReader != null &&
  335. validatingReader.ValidationType == ValidationType.None)
  336. return;
  337. IXmlLineInfo info = this as IXmlLineInfo;
  338. bool hasLine = info.HasLineInfo ();
  339. XmlSchemaException ex = new XmlSchemaException (
  340. message,
  341. hasLine ? info.LineNumber : 0,
  342. hasLine ? info.LinePosition : 0,
  343. null,
  344. BaseURI,
  345. null);
  346. if (validatingReader != null)
  347. this.validatingReader.OnValidationEvent (this,
  348. new ValidationEventArgs (ex, message, severity));
  349. else
  350. throw ex;
  351. }
  352. private void ValidateAttributes (DTDAttListDeclaration decl)
  353. {
  354. while (reader.MoveToNextAttribute ()) {
  355. string attrName = reader.Name;
  356. attributes.Add (attrName);
  357. bool hasError = false;
  358. while (reader.ReadAttributeValue ()) {
  359. if (reader.NodeType == XmlNodeType.EntityReference) {
  360. DTDEntityDeclaration edecl = DTD.EntityDecls [reader.Name];
  361. if (edecl == null) {
  362. HandleError (String.Format ("Referenced entity {0} is not declared.", reader.Name),
  363. XmlSeverityType.Error);
  364. hasError = true;
  365. }
  366. else
  367. valueBuilder.Append (edecl.EntityValue);
  368. }
  369. else
  370. valueBuilder.Append (reader.Value);
  371. }
  372. reader.MoveToElement ();
  373. reader.MoveToAttribute (attrName);
  374. string attrValue = valueBuilder.ToString ();
  375. valueBuilder.Length = 0;
  376. attributeValues.Add (attrName, attrValue);
  377. DTDAttributeDefinition def = decl [reader.Name];
  378. if (def == null) {
  379. HandleError (String.Format ("Attribute {0} is not declared.", reader.Name),
  380. XmlSeverityType.Error);
  381. // FIXME: validation recovery code here.
  382. } else {
  383. // check identity constraint
  384. switch (def.Datatype.TokenizedType) {
  385. case XmlTokenizedType.ID:
  386. if (this.idList.Contains (attrValue)) {
  387. HandleError (String.Format ("Node with ID {0} was already appeared.", attrValue),
  388. XmlSeverityType.Error);
  389. // FIXME: validation recovery code here.
  390. } else {
  391. if (missingIDReferences.Contains (attrValue))
  392. missingIDReferences.Remove (attrValue);
  393. idList.Add (attrValue);
  394. }
  395. break;
  396. case XmlTokenizedType.IDREF:
  397. if (!idList.Contains (attrValue))
  398. missingIDReferences.Add (attrValue);
  399. break;
  400. case XmlTokenizedType.IDREFS:
  401. string [] idrefs = def.Datatype.ParseValue (attrValue, NameTable, null) as string [];
  402. foreach (string idref in idrefs)
  403. if (!idList.Contains (attrValue))
  404. missingIDReferences.Add (attrValue);
  405. break;
  406. }
  407. switch (def.OccurenceType) {
  408. case DTDAttributeOccurenceType.Required:
  409. if (attrValue == String.Empty) {
  410. HandleError (String.Format ("Required attribute {0} in element {1} not found .",
  411. def.Name, decl.Name),
  412. XmlSeverityType.Error);
  413. // FIXME: validation recovery code here.
  414. }
  415. break;
  416. case DTDAttributeOccurenceType.Fixed:
  417. if (attrValue != def.DefaultValue) {
  418. HandleError (String.Format ("Fixed attribute {0} in element {1} has invalid value {2}.",
  419. def.Name, decl.Name, attrValue),
  420. XmlSeverityType.Error);
  421. // FIXME: validation recovery code here.
  422. }
  423. break;
  424. }
  425. }
  426. }
  427. // Check if all required attributes exist, and/or
  428. // if there is default values, then add them.
  429. foreach (DTDAttributeDefinition def in decl.Definitions)
  430. if (!attributes.Contains (def.Name)) {
  431. if (def.OccurenceType == DTDAttributeOccurenceType.Required) {
  432. HandleError (String.Format ("Required attribute {0} was not found.", decl.Name),
  433. XmlSeverityType.Error);
  434. // FIXME: validation recovery code here.
  435. }
  436. else if (def.DefaultValue != null) {
  437. attributes.Add (def.Name);
  438. attributeValues.Add (def.Name, def.DefaultValue);
  439. }
  440. }
  441. reader.MoveToElement ();
  442. }
  443. public override bool ReadAttributeValue ()
  444. {
  445. if (consumedAttribute)
  446. return false;
  447. if (NodeType == XmlNodeType.Attribute &&
  448. validatingReader.EntityHandling == EntityHandling.ExpandEntities) {
  449. consumedAttribute = true;
  450. return true;
  451. }
  452. else if (IsDefault) {
  453. consumedAttribute = true;
  454. return true;
  455. }
  456. else
  457. return reader.ReadAttributeValue ();
  458. }
  459. public override string ReadInnerXml ()
  460. {
  461. // MS.NET 1.0 has a serious bug here. It skips validation.
  462. return reader.ReadInnerXml ();
  463. }
  464. public override string ReadOuterXml ()
  465. {
  466. // MS.NET 1.0 has a serious bug here. It skips validation.
  467. return reader.ReadOuterXml ();
  468. }
  469. public override string ReadString ()
  470. {
  471. // It seems to be the same as ReadInnerXml().
  472. return reader.ReadString ();
  473. }
  474. [MonoTODO]
  475. public override void ResolveEntity ()
  476. {
  477. throw new NotImplementedException ();
  478. }
  479. public override int AttributeCount {
  480. get {
  481. if (dtd == null || !insideContent)
  482. return reader.AttributeCount;
  483. return attributes.Count;
  484. }
  485. }
  486. [MonoTODO ("Should consider general entities.")]
  487. public override string BaseURI {
  488. get {
  489. return reader.BaseURI;
  490. }
  491. }
  492. public override bool CanResolveEntity {
  493. get { return true; }
  494. }
  495. [MonoTODO ("Should consider general entities' depth")]
  496. public override int Depth {
  497. get { return IsDefault ? reader.Depth + 1 : reader.Depth; }
  498. }
  499. [MonoTODO]
  500. public override bool EOF {
  501. get { return reader.EOF; }
  502. }
  503. public override bool HasValue {
  504. get { return IsDefault ? true : reader.HasValue; }
  505. }
  506. public override bool IsDefault {
  507. get {
  508. if (currentAttribute == null)
  509. return false;
  510. return reader.GetAttribute (currentAttribute) == null;
  511. }
  512. }
  513. public override bool IsEmptyElement {
  514. get { return reader.IsEmptyElement; }
  515. }
  516. public override string this [int i] {
  517. get { return GetAttribute (i); }
  518. }
  519. public override string this [string name] {
  520. get { return GetAttribute (name); }
  521. }
  522. public override string this [string name, string ns] {
  523. get { return GetAttribute (name, ns); }
  524. }
  525. public int LineNumber {
  526. get {
  527. IXmlLineInfo info = reader as IXmlLineInfo;
  528. return (info != null) ? info.LineNumber : 0;
  529. }
  530. }
  531. public int LinePosition {
  532. get {
  533. IXmlLineInfo info = reader as IXmlLineInfo;
  534. return (info != null) ? info.LinePosition : 0;
  535. }
  536. }
  537. public override string LocalName {
  538. get {
  539. return IsDefault ?
  540. consumedAttribute ? String.Empty : currentAttribute :
  541. reader.LocalName;
  542. }
  543. }
  544. public override string Name {
  545. get {
  546. return IsDefault ?
  547. consumedAttribute ? String.Empty : currentAttribute :
  548. reader.Name;
  549. }
  550. }
  551. public override string NamespaceURI {
  552. get {
  553. return IsDefault ?
  554. consumedAttribute ? String.Empty : String.Empty :
  555. reader.NamespaceURI;
  556. }
  557. }
  558. public override XmlNameTable NameTable {
  559. get { return reader.NameTable; }
  560. }
  561. public override XmlNodeType NodeType {
  562. get {
  563. // If consumedAttribute is true, then entities must be resolved.
  564. return consumedAttribute ? XmlNodeType.Text :
  565. IsDefault ? XmlNodeType.Attribute :
  566. reader.NodeType;
  567. }
  568. }
  569. public override string Prefix {
  570. get {
  571. if (currentAttribute != null && NodeType != XmlNodeType.Attribute)
  572. return String.Empty;
  573. return IsDefault ? String.Empty : reader.Prefix;
  574. }
  575. }
  576. public override char QuoteChar {
  577. get {
  578. // If it is not actually on an attribute, then it returns
  579. // undefined value or '"'.
  580. return reader.QuoteChar;
  581. }
  582. }
  583. public override ReadState ReadState {
  584. get {
  585. return reader.ReadState;
  586. }
  587. }
  588. char [] whitespaceChars = new char [] {' '};
  589. private string FilterNormalization (string rawValue)
  590. {
  591. if (DTD != null &&
  592. NodeType == XmlNodeType.Attribute &&
  593. sourceTextReader != null &&
  594. sourceTextReader.Normalization) {
  595. DTDAttributeDefinition def =
  596. dtd.AttListDecls [currentElement] [currentAttribute] as DTDAttributeDefinition;
  597. valueBuilder.Append (rawValue);
  598. valueBuilder.Replace ('\r', ' ');
  599. valueBuilder.Replace ('\n', ' ');
  600. valueBuilder.Replace ('\t', ' ');
  601. try {
  602. if (def.Datatype.TokenizedType != XmlTokenizedType.CDATA) {
  603. for (int i=0; i < valueBuilder.Length; i++) {
  604. if (valueBuilder [i] == ' ') {
  605. while (++i < valueBuilder.Length && valueBuilder [i] == ' ')
  606. valueBuilder.Remove (i, 1);
  607. }
  608. }
  609. return valueBuilder.ToString ().Trim (whitespaceChars);
  610. }
  611. else
  612. return valueBuilder.ToString ();
  613. } finally {
  614. valueBuilder.Length = 0;
  615. }
  616. }
  617. else
  618. return rawValue;
  619. }
  620. public override string Value {
  621. get {
  622. // This check also covers value node of default attributes.
  623. if (IsDefault) {
  624. DTDAttributeDefinition def =
  625. dtd.AttListDecls [currentElement] [currentAttribute] as DTDAttributeDefinition;
  626. return sourceTextReader != null && sourceTextReader.Normalization ?
  627. def.NormalizedDefaultValue : def.DefaultValue;
  628. }
  629. // As to this property, MS.NET seems ignorant of EntityHandling...
  630. else if (NodeType == XmlNodeType.Attribute)// &&
  631. // validatingReader.EntityHandling == EntityHandling.ExpandEntities)
  632. return FilterNormalization (attributeValues [currentAttribute]);
  633. else if (consumedAttribute)
  634. return FilterNormalization (attributeValues [this.currentAttribute]);
  635. else
  636. return FilterNormalization (reader.Value);
  637. }
  638. }
  639. [MonoTODO ("Should consider default xml:lang values.")]
  640. public override string XmlLang {
  641. get { return reader.XmlLang; }
  642. }
  643. [MonoTODO ("Should consider default xml:space values.")]
  644. public override XmlSpace XmlSpace {
  645. get { return reader.XmlSpace; }
  646. }
  647. }
  648. }