PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/test/lib/xbrlware/xml_parser_test.rb

https://code.google.com/p/xbrlware/
Ruby | 223 lines | 213 code | 10 blank | 0 comment | 10 complexity | 384e7ab3fbdae52708a5ae9334c257b7 MD5 | raw file
Possible License(s): Apache-2.0
  1. require File.dirname(__FILE__) + '/../../test_helper.rb'
  2. class TestXmlParser < Test::Unit::TestCase
  3. def test_namespace_and_nsprefix_are_partof_attributes
  4. xml_content= %{
  5. <?xml version="1.0" encoding="US-ASCII"?>
  6. <xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:dei="http://xbrl.us/dei/2009-01-31"
  7. xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:kr="http://www.kroger.com/20090815"
  8. xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:us-gaap="http://xbrl.us/us-gaap/2009-01-31"
  9. xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:xlink="http://www.w3.org/1999/xlink"
  10. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  11. <link:schemaRef xlink:href="kr-20090815.xsd" xlink:type="simple"/>
  12. <xbrli:context id="I2007_CommonStockMember">
  13. <xbrli:entity>
  14. <xbrli:identifier scheme="http://www.sec.gov/CIK">0000056873</xbrli:identifier>
  15. <xbrli:segment>
  16. <xbrldi:explicitMember dimension="us-gaap:StatementEquityComponentsAxis">us-gaap:CommonStockMember
  17. </xbrldi:explicitMember>
  18. </xbrli:segment>
  19. </xbrli:entity>
  20. <xbrli:period>
  21. <xbrli:instant>2008-02-02</xbrli:instant>
  22. </xbrli:period>
  23. </xbrli:context>
  24. <xbrli:context id="I2007_AdditionalPaidInCapitalMember">
  25. <xbrli:entity>
  26. <xbrli:identifier scheme="http://www.sec.gov/CIK">0000056873</xbrli:identifier>
  27. <xbrli:segment>
  28. <xbrldi:explicitMember dimension="us-gaap:StatementEquityComponentsAxis">
  29. us-gaap:AdditionalPaidInCapitalMember
  30. </xbrldi:explicitMember>
  31. </xbrli:segment>
  32. </xbrli:entity>
  33. <xbrli:period>
  34. <xbrli:instant>2008-02-02</xbrli:instant>
  35. </xbrli:period>
  36. </xbrli:context>
  37. <xbrli:context id="D2009Q2YTD">
  38. <xbrli:entity>
  39. <xbrli:identifier scheme="http://www.sec.gov/CIK">0000056873</xbrli:identifier>
  40. </xbrli:entity>
  41. <xbrli:period>
  42. <xbrli:startDate>2009-02-01</xbrli:startDate>
  43. <xbrli:endDate>2009-08-15</xbrli:endDate>
  44. </xbrli:period>
  45. </xbrli:context>
  46. <xbrli:unit id="USD">
  47. <xbrli:measure>iso4217:USD</xbrli:measure>
  48. </xbrli:unit>
  49. <xbrli:unit id="shares">
  50. <xbrli:measure>xbrli:shares</xbrli:measure>
  51. </xbrli:unit>
  52. <xbrli:unit id="USDPerShare">
  53. <xbrli:divide>
  54. <xbrli:unitNumerator>
  55. <xbrli:measure>iso4217:USD</xbrli:measure>
  56. </xbrli:unitNumerator>
  57. <xbrli:unitDenominator>
  58. <xbrli:measure>xbrli:shares</xbrli:measure>
  59. </xbrli:unitDenominator>
  60. </xbrli:divide>
  61. </xbrli:unit>
  62. <dei:EntityRegistrantName contextRef="D2009Q2YTD">THE KROGER CO.</dei:EntityRegistrantName>
  63. <dei:EntityCentralIndexKey contextRef="D2009Q2YTD">0000056873</dei:EntityCentralIndexKey>
  64. <us-gaap:StockholdersEquityIncludingPortionAttributableToNoncontrollingInterest contextRef="I2007_CommonStockMember"
  65. decimals="-6" unitRef="USD">
  66. 947000000
  67. </us-gaap:StockholdersEquityIncludingPortionAttributableToNoncontrollingInterest>
  68. <us-gaap:StockholdersEquityIncludingPortionAttributableToNoncontrollingInterest
  69. contextRef="I2007_AdditionalPaidInCapitalMember" decimals="-6" unitRef="USD">3031000000
  70. </us-gaap:StockholdersEquityIncludingPortionAttributableToNoncontrollingInterest>
  71. <us-gaap:SharesIssued contextRef="I2007_CommonStockMember" decimals="-6" unitRef="shares">947000000
  72. </us-gaap:SharesIssued>
  73. </xbrli:xbrl>
  74. }
  75. _hash=Xbrlware::XmlParser.xml_in(xml_content, {'ForceContent' => true})
  76. assert("http://xbrl.us/us-gaap/2009-01-31", _hash["SharesIssued"][0]["nspace"]);
  77. assert("us-gaap", _hash["SharesIssued"][0]["nspace_prefix"]);
  78. end
  79. def test_xmslparser_is_faster_than_xmlsimple
  80. xml_content= %{
  81. <?xml version="1.0" encoding="us-ascii"?>
  82. <xbrl>
  83. <SeasonalityOfBusinessTextBlock contextRef="NineMonthsEnded_05Sep2009">
  84. &lt;!--DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" --&gt;
  85. &lt;!-- Begin Block Tagged Note 2 - bgllc:SeasonalityOfBusinessTextBlock--&gt;
  86. &lt;div style="font-family: 'Times New Roman',Times,serif"&gt;
  87. &lt;div align="left" style="font-size: 10pt; margin-top: 12pt"&gt;&lt;b&gt;Note 2&amp;#8212;Seasonality of Business&lt;/b&gt;
  88. &lt;/div&gt;
  89. &lt;div align="left" style="font-size: 10pt; margin-top: 6pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;The results for the third quarter are not necessarily indicative of the results that may be
  90. expected for the full year because sales of our products are seasonal. The seasonality of our
  91. operating results arises from higher sales in the second and third quarters versus the first and
  92. fourth quarters of the year, combined with the impact of fixed costs, such as depreciation and
  93. interest, which are not significantly impacted by business seasonality. From a cash flow
  94. perspective, the majority of our cash flow from operations is generated in the third and fourth
  95. quarters.
  96. &lt;/div&gt;
  97. &lt;/div&gt;
  98. </SeasonalityOfBusinessTextBlock>
  99. <AccountingChangesAndErrorCorrectionsTextBlock contextRef="NineMonthsEnded_05Sep2009">
  100. &lt;!--DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" --&gt;
  101. &lt;!-- Begin Block Tagged Note 3 - us-gaap:AccountingChangesAndErrorCorrectionsTextBlock--&gt;
  102. &lt;div style="font-family: 'Times New Roman',Times,serif"&gt;
  103. &lt;div align="left" style="font-size: 10pt; margin-top: 12pt"&gt;&lt;b&gt;Note 3&amp;#8212;New Accounting Standards&lt;/b&gt;
  104. &lt;/div&gt;
  105. &lt;div align="left" style="font-size: 10pt; margin-top: 6pt"&gt;&lt;i&gt;SFAS No.&amp;#160;141(R) as amended&lt;/i&gt;
  106. &lt;/div&gt;
  107. &lt;div align="left" style="font-size: 10pt; margin-top: 6pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;In December&amp;#160;2007, the Financial Accounting Standards Board (&amp;#8220;FASB&amp;#8221;) issued Statement of
  108. Financial Accounting Standards (&amp;#8220;SFAS&amp;#8221;) No.&amp;#160;141(revised 2007), &amp;#8220;Business Combinations&amp;#8221; (&amp;#8220;SFAS
  109. 141(R)&amp;#8221;), which addresses the accounting and disclosure for identifiable assets acquired,
  110. liabilities assumed, and noncontrolling interests in a business combination. In April&amp;#160;2009, the
  111. FASB issued FASB Staff Position No.&amp;#160;FAS 141(R)-1, &amp;#8220;Accounting for Assets Acquired and Liabilities
  112. Assumed in a Business Combination That Arise from Contingencies&amp;#8221; (&amp;#8220;FSP FAS 141(R)-1&amp;#8221;), which
  113. amended certain provisions of SFAS 141(R) related to the recognition, measurement, and disclosure
  114. of assets acquired and liabilities assumed in a business combination that arise from contingencies.
  115. SFAS 141(R) and FSP FAS 141(R)-1 became effective in 2009, and did not have a material impact on
  116. our Condensed Consolidated Financial Statements, but will continue to be evaluated on the outcome
  117. of future matters.
  118. &lt;/div&gt;
  119. &lt;div align="left" style="font-size: 10pt; margin-top: 12pt"&gt;&lt;i&gt;SFAS No.&amp;#160;160&lt;/i&gt;
  120. &lt;/div&gt;
  121. &lt;div align="left" style="font-size: 10pt; margin-top: 6pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;In December&amp;#160;2007, the FASB issued SFAS No.&amp;#160;160, &amp;#8220;Noncontrolling Interests in Consolidated
  122. Financial Statements, an amendment of ARB No.&amp;#160;51&amp;#8221; (&amp;#8220;SFAS 160&amp;#8221;), which addresses the accounting and
  123. reporting framework for noncontrolling interests by a parent company. SFAS 160 also addresses
  124. disclosure requirements to distinguish between interests of the parent and interests of the
  125. noncontrolling owners of a subsidiary. SFAS 160 became effective in the first quarter of 2009.
  126. The provisions of SFAS 160 require that minority interest be renamed noncontrolling interests and
  127. that a company present a consolidated net income measure that includes the amount attributable to
  128. such noncontrolling interests for all periods presented. In addition, SFAS 160 requires reporting
  129. noncontrolling interests as a component of equity in our Condensed Consolidated Balance Sheets and
  130. below income tax expense in our Condensed Consolidated Statements of Operations. As required by
  131. SFAS 160, we have retrospectively applied the presentation to our prior year balances in our
  132. Condensed Consolidated Financial Statements.
  133. &lt;/div&gt;
  134. &lt;div align="left" style="font-size: 10pt; margin-top: 12pt"&gt;&lt;i&gt;SFAS No.&amp;#160;161&lt;/i&gt;
  135. &lt;/div&gt;
  136. &lt;div align="left" style="font-size: 10pt; margin-top: 6pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;In March&amp;#160;2008, the FASB issued SFAS No.&amp;#160;161, &amp;#8220;Disclosures about Derivative Instruments and
  137. Hedging Activities, an amendment of FASB Statement No.&amp;#160;133&amp;#8221; (&amp;#8220;SFAS 161&amp;#8221;), which requires enhanced
  138. disclosures for derivative and hedging activities. SFAS 161 became effective in the first quarter
  139. of 2009. See Note 8 for required disclosure.
  140. &lt;/div&gt;
  141. &lt;div align="left" style="font-size: 10pt; margin-top: 12pt"&gt;&lt;i&gt;FSP FAS 132(R)-1&lt;/i&gt;
  142. &lt;/div&gt;
  143. &lt;div align="left" style="font-size: 10pt; margin-top: 6pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;In December&amp;#160;2008, the FASB issued FASB Staff Position No.&amp;#160;SFAS 132(revised 2003)-1,
  144. &amp;#8220;Employers&amp;#8217; Disclosures about Postretirement Benefit Plan Assets&amp;#8221; (&amp;#8220;FSP FAS 132(R)-1&amp;#8221;), which
  145. requires employers to disclose information about fair value measurements of plan assets that are
  146. similar to the disclosures about fair value measurements required by SFAS No.&amp;#160;157, &amp;#8220;Fair Value
  147. Measurements&amp;#8221; (&amp;#8220;SFAS 157&amp;#8221;). FSP FAS 132(R)-1 will become effective for our annual financial
  148. statements for 2009. We are currently evaluating the impact of this standard on our Consolidated
  149. Financial Statements.
  150. &lt;/div&gt;
  151. &lt;!-- Folio --&gt;
  152. &lt;!-- /Folio --&gt;
  153. &lt;/div&gt;
  154. &lt;!-- PAGEBREAK --&gt;
  155. &lt;div style="font-family: 'Times New Roman',Times,serif"&gt;
  156. &lt;div align="left" style="font-size: 10pt; margin-top: 12pt"&gt;&lt;i&gt;FSP FAS 107-1 and APB 28-1&lt;/i&gt;
  157. &lt;/div&gt;
  158. &lt;div align="left" style="font-size: 10pt; margin-top: 6pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;In April&amp;#160;2009, the FASB issued FASB Staff Position No.&amp;#160;SFAS 107-1 and APB No.&amp;#160;28-1, &amp;#8220;Interim
  159. Disclosures about Fair Value of Financial Instruments&amp;#8221; (&amp;#8220;FSP FAS 107-1 and APB 28-1&amp;#8221;), which
  160. requires quarterly disclosure of information about the fair value of financial instruments within
  161. the scope of FASB Statement No.&amp;#160;107, &amp;#8220;Disclosures about Fair Value of Financial Instruments.&amp;#8221; FSP
  162. FAS 107-1 and APB 28-1 has an effective date requiring adoption by the third quarter of 2009 with
  163. early adoption permitted. We adopted the provisions of FSP FAS 107-1 and APB 28-1 in the first
  164. quarter of 2009. See Note 7 for required disclosures.
  165. &lt;/div&gt;
  166. &lt;div align="left" style="font-size: 10pt; margin-top: 12pt"&gt;&lt;i&gt;SFAS No.&amp;#160;165&lt;/i&gt;
  167. &lt;/div&gt;
  168. &lt;div align="left" style="font-size: 10pt; margin-top: 6pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;In May&amp;#160;2009, the FASB issued SFAS No.&amp;#160;165, &amp;#8220;Subsequent Events&amp;#8221; (&amp;#8220;SFAS 165&amp;#8221;), which sets forth
  169. general standards of accounting for and disclosure of events that occur after the balance sheet
  170. date but before financial statements are issued or are available to be issued. SFAS 165 became
  171. effective in the third quarter of 2009 and did not have a material impact on our Consolidated
  172. Financial Statements.
  173. &lt;/div&gt;
  174. &lt;div align="left" style="font-size: 10pt; margin-top: 12pt"&gt;&lt;i&gt;SFAS No.&amp;#160;167&lt;/i&gt;
  175. &lt;/div&gt;
  176. &lt;div align="left" style="font-size: 10pt; margin-top: 6pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;In June&amp;#160;2009, the FASB issued SFAS No.&amp;#160;167, &amp;#8220;Amendments to FASB Interpretation No.&amp;#160;46(R)&amp;#8221;
  177. (&amp;#8220;SFAS 167&amp;#8221;), which amends FASB Interpretation No.&amp;#160;46(revised December&amp;#160;2003) to address the
  178. elimination of the concept of a qualifying special purpose entity. SFAS 167 also replaces the
  179. quantitative-based risks and rewards calculation for determining which enterprise has a controlling
  180. financial interest in a variable interest entity with an approach focused on identifying which
  181. enterprise has the power to direct the activities of a variable interest entity and the obligation
  182. to absorb losses of the entity or the right to receive benefits from the entity. Additionally,
  183. SFAS 167 provides more timely and useful information about an enterprise&amp;#8217;s involvement with a
  184. variable interest entity. SFAS 167 will become effective in the first quarter of 2010. We are
  185. currently evaluating the impact of this standard on our Consolidated Financial Statements.
  186. &lt;/div&gt;
  187. &lt;div align="left" style="font-size: 10pt; margin-top: 12pt"&gt;&lt;i&gt;SFAS No.&amp;#160;168&lt;/i&gt;
  188. &lt;/div&gt;
  189. &lt;div align="left" style="font-size: 10pt; margin-top: 6pt"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;In June&amp;#160;2009, the FASB issued SFAS No.&amp;#160;168, &amp;#8220;The &lt;i&gt;FASB Accounting Standards
  190. Codification&lt;/i&gt;&lt;sup style="font-size: 85%; vertical-align: text-top"&gt;TM&lt;/sup&gt; and the Hierarchy of Generally Accepted Accounting Principles, a
  191. replacement of FASB Statement No.&amp;#160;162&amp;#8221; (&amp;#8220;SFAS 168&amp;#8221;), which establishes the FASB Accounting
  192. Standards Codification as the source of authoritative accounting principles recognized by the FASB
  193. to be applied in the preparation of financial statements in conformity with generally accepted
  194. accounting principles. SFAS 168 explicitly recognizes rules and interpretive releases of the
  195. Securities and Exchange Commission (&amp;#8220;SEC&amp;#8221;) under federal securities laws as authoritative GAAP for
  196. SEC registrants. SFAS 168 will become effective in the fourth quarter of 2009 and will require the
  197. Company to update all existing GAAP references to the new codification references for all future
  198. filings.
  199. &lt;/div&gt;
  200. &lt;/div&gt;
  201. </AccountingChangesAndErrorCorrectionsTextBlock>
  202. </xbrl>
  203. }
  204. m_xml_simple=Benchmark.measure do
  205. XmlSimple.xml_in(xml_content, {'ForceContent' => true})
  206. end
  207. m_xml_parser=Benchmark.measure do
  208. Xbrlware::XmlParser.xml_in(xml_content, {'ForceContent' => true})
  209. end
  210. assert(m_xml_parser.real < m_xml_simple.real)
  211. $LOG.debug "XmlParser is " + (m_xml_simple.real/m_xml_parser.real).to_s + " faster as entity replacement is ignored"
  212. end
  213. end