#Glenn Gasmen's struggle with recursive modes

from Xslt import test_harness

sheet_1 = """<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:ft="http://xmlns.4suite.org/ext"
  xmlns:ot='http://namespaces.opentechnology.org/talk'
  xmlns:dc='http://purl.org/metadata/dublin_core'
  extension-element-prefixes='ft'
  version="1.0"
>
  <xsl:output method="html" encoding="ISO-8859-1"/>
  <xsl:param name='user-mode' select='"full-story"'/>

  <xsl:template match="/">
  <HTML><HEAD><TITLE>Test Skin</TITLE></HEAD><BODY>
    <ft:apply-templates mode='$user-mode'/>
  </BODY></HTML>
  </xsl:template>

  <xsl:template match="ot:story" mode="front-page">

   <DIV ALIGN="CENTER">

    <DIV ALIGN="CENTER">
       <xsl:value-of select="dc:title"/>
    </DIV>

    <TABLE WIDTH="100%" BORDER="0">
      <TR>
        <TD ALIGN="LEFT" WIDTH="33%">
          <xsl:value-of select="dc:creator"/>
        </TD>
        <TD ALIGN="CENTER" WIDTH="33%">
          <xsl:value-of select="dc:datetime"/>
        </TD>
        <TD ALIGN="RIGHT" WIDTH="33%">
          <xsl:value-of select="ot:link"/>
        </TD>
      </TR>
    </TABLE>

    <DIV ALIGN="JUSTIFY">
        <xsl:apply-templates select="dc:description"/>
    </DIV>
   </DIV>

  </xsl:template>

  <xsl:template match="ot:story" mode="full-story">

    <DIV ALIGN="CENTER">
       <xsl:value-of select="dc:title"/>
    </DIV>

    <TABLE WIDTH="100%" BORDER="0">
      <TR>
        <TD ALIGN="LEFT" WIDTH="50%">
          <xsl:value-of select="dc:creator"/>
        </TD>
        <TD ALIGN="RIGHT" WIDTH="50%">
          <xsl:value-of select="dc:datetime"/>
        </TD>
      </TR>
    </TABLE>

    <DIV ALIGN="JUSTIFY">
       <xsl:apply-templates select="dc:content"/>
       <BR/><BR/>
    </DIV>

    <DIV ALIGN="JUSTIFY">
       <xsl:apply-templates select="dc:description"/>
       <BR/><BR/>
    </DIV>

    <xsl:template match="ot:comment">
      <DIV ALIGN="JUSTIFY">
       <xsl:for-each select="dc:title"/>
      </DIV>
    </xsl:template>

  </xsl:template>
</xsl:stylesheet>
"""


source_1 = """<result-set>
<!--
Notes:
* All elements in the valid dublic core meta-data 1.0  element set are in the dc namespace.  All other metadata are in the ot namespace.
* for info on Dublin Core, see http://purl.org/DC/documents/rec-dces-19990702.htm and http://purl.org/dc/documents/rec/dcmes-qualifiers-20000711.htm
-->

<ot:story
  id='urn:uuid:this-is-bogus-uuid-1'
  xmlns:ot='http://namespaces.opentechnology.org/talk'
  xmlns:dc='http://purl.org/metadata/dublin_core'
  xmlns='http://docbook.org/docbook/xml/4.0/namespace'
>
  <dc:creator ot:id='urn:uuid:this-is-bogus-uuid-2' ot:name='Xavier Markus Langley'/>
  <dc:creator>Plagerized</dc:creator>
  <dc:subject>Test Data</dc:subject>
  <dc:datetime>2003-02-30 13:59:23-07:00</dc:datetime>
  <dc:title>Privacy, Part Two: Unwanted Gaze</dc:title>
  <dc:content>
This is an example content:
A growing number of lawyers and scholars, including Rosen, say they now believe that fundamental changes in Net architecture are necessary to protect constitutional values and restore the notion of the "inviolate personality" to the private lives of Americans. These would include copyright management systems to protect the right to read anonymously, permitting individuals to pay with untraceable digital cash; prohibiting the collection and disclosure of identifying information without the reader's knowledge, or using digital certificates to create psudonymous downloading. 

To Rosen, author of Gaze, cyberspace is posing a greater menace to privacy by the day. He details the l998 forced resignation of Harvard Divinity School dean Ronald F. Thiemann, who downloaded pornography onto his university-owned home computer. A Harvard technician installing a computer with more memory at the dean's residence was transferring files from the old computer to the new one and noticed thousands of pornographic pictures. Although none of the pictures appeared to involve minors, the technician told his supervisor. University administrators asked the dean to step down. 

Harvard justified its decision by claiming that Divinity School rules prohibited personal use of university computers in any way that clashed with its educational mission. But the dean was using his computer at home, not work. And no student or colleague suggested he had improperly behaved in any way as head of the Divinity School. His work was never questioned. It's ludicrous to suggest that the school would have fired him if he'd been downloading sports scores or bidding for furniture on eBay. But although he'd committed no crime and performed well in his job, he was forced out in disgrace, while his intimate communications were discussed in public. 


Should free citizens in a democratic society have to spend money for "nyms" to preserve the privacy they ought to be -- and once were -- accorded in law? How many millions of computer users will even know of this new technology, or have the money to use it?  Rosen's implication is that even if software caused the problem, then software will clean up.

His assurances seem a bit "gee-whiz." But to ignore them cynically on that basis, or to trust them completely, ignores the history of technology. What people can create, others can and will undo. Technology that can be used will be used. In an otherwise powerful book, he also glosses over powerful incentives for eliminating privacy in cyberspace. First, the megacorporations dominating media, business and government will continue to aggressively explore ways of tracking potential customers as Net use grows. Secondly, law enforcement agencies like the FBI have been fighting for decades for the right to deploy tracking programs like "Carnivore" (see part one) and are hardly likely to back off. 

  </dc:content>
  <dc:description>
     This is  and example of a description:
     Can pseudonymous downloading, "snoop-proof" e-mail, digital pseuds called 
     "nyms," PDA-like machines, allegedly untraceable digi-cash and other 
     changes in software and the architecture of cyberspace, restore some 
     privacy and restore the idea of the "Inviolate Personality?" Part Two 
     in a series based on Jeffrey Rosen's new book, "The Unwanted Gaze: The 
     Destruction of Privacy in America."
  </dc:description>
</ot:story>

<ot:story
  id='urn:uuid:this-is-bogus-uuid-1'
  xmlns:ot='http://namespaces.opentechnology.org/talk'
  xmlns:dc='http://purl.org/metadata/dublin_core'
>
  <dc:creator ot:id='urn:uuid:this-is-bogus-uuid-2' ot:name='Xavier Markus Langley'/>
   <dc:subject>4Suite</dc:subject>
  <dc:subject>Release</dc:subject>
  <dc:subject>XSLT</dc:subject>
  <dc:subject>DOM</dc:subject>
  <dc:subject>XPath</dc:subject>
  <dc:subject>RDF</dc:subject>
  <dc:subject>Object Databases</dc:subject>
  <dc:datetime>2003-11-19 13:59:23-07:00</dc:datetime>
  <dc:title>4Suite 5.3.8 Released</dc:title>
  <!--
Note that 4Suite is also marked as a keyword in the content.  This is fine.  The final keywords are a union of all the dc:subject children of ot:story and dc:content.
  -->
  <dc:content>
<ot:source>Fourthought, Inc.</ot:source> today announced the latest version of their XML middleware suite, <dc:subject>4Suite</dc:subject>.  This latest version adds support for the latest <dc:subject>XSLT</dc:subject> 2.3 Recommendation and <dc:subject>DOM</dc:subject> Level 7.
  </dc:content>
  <dc:description>
     Can pseudonymous downloading, "snoop-proof" e-mail, digital pseuds called "nyms," PDA-like machines, allegedly untraceable digi-cash and other changes in software and the architecture of cyberspace, restore some privacy and restore the idea of the "Inviolate Personality?" Part Two in a series based on Jeffrey Rosen's new book, "The Unwanted Gaze: The Destruction of Privacy in America."
  </dc:description>
</ot:story>

</result-set>
"""

expected_1 = """<HTML>\012  <HEAD>\012    <META HTTP-EQUIV=\'Content-Type\' CONTENT=\'text/html; charset=ISO-8859-1\'>\012    <TITLE>Test Skin</TITLE>\012  </HEAD>\012  <BODY>\012    <DIV ALIGN=\'CENTER\'>Privacy, Part Two: Unwanted Gaze</DIV>\012    <TABLE WIDTH=\'100%\' BORDER=\'0\'>\012      <TR>\012        <TD WIDTH=\'50%\' ALIGN=\'LEFT\'></TD>\012        <TD WIDTH=\'50%\' ALIGN=\'RIGHT\'>2003-02-30 13:59:23-07:00</TD>\012      </TR>\012    </TABLE>\012    <DIV ALIGN=\'JUSTIFY\'>\012This is an example content:\012A growing number of lawyers and scholars, including Rosen, say they now believe that fundamental changes in Net architecture are necessary to protect constitutional values and restore the notion of the "inviolate personality" to the private lives of Americans. These would include copyright management systems to protect the right to read anonymously, permitting individuals to pay with untraceable digital cash; prohibiting the collection and disclosure of identifying information without the reader\'s knowledge, or using digital certificates to create psudonymous downloading. \012\012To Rosen, author of Gaze, cyberspace is posing a greater menace to privacy by the day. He details the l998 forced resignation of Harvard Divinity School dean Ronald F. Thiemann, who downloaded pornography onto his university-owned home computer. A Harvard technician installing a computer with more memory at the dean\'s residence was transferring files from the old computer to the new one and noticed thousands of pornographic pictures. Although none of the pictures appeared to involve minors, the technician told his supervisor. University administrators asked the dean to step down. \012\012Harvard justified its decision by claiming that Divinity School rules prohibited personal use of university computers in any way that clashed with its educational mission. But the dean was using his computer at home, not work. And no student or colleague suggested he had improperly behaved in any way as head of the Divinity School. His work was never questioned. It\'s ludicrous to suggest that the school would have fired him if he\'d been downloading sports scores or bidding for furniture on eBay. But although he\'d committed no crime and performed well in his job, he was forced out in disgrace, while his intimate communications were discussed in public. \012\012\012Should free citizens in a democratic society have to spend money for "nyms" to preserve the privacy they ought to be -- and once were -- accorded in law? How many millions of computer users will even know of this new technology, or have the money to use it?  Rosen\'s implication is that even if software caused the problem, then software will clean up.\012\012His assurances seem a bit "gee-whiz." But to ignore them cynically on that basis, or to trust them completely, ignores the history of technology. What people can create, others can and will undo. Technology that can be used will be used. In an otherwise powerful book, he also glosses over powerful incentives for eliminating privacy in cyberspace. First, the megacorporations dominating media, business and government will continue to aggressively explore ways of tracking potential customers as Net use grows. Secondly, law enforcement agencies like the FBI have been fighting for decades for the right to deploy tracking programs like "Carnivore" (see part one) and are hardly likely to back off. \012\012  <BR>\012      <BR>\012    </DIV>\012    <DIV ALIGN=\'JUSTIFY\'>\012     This is  and example of a description:\012     Can pseudonymous downloading, "snoop-proof" e-mail, digital pseuds called \012     "nyms," PDA-like machines, allegedly untraceable digi-cash and other \012     changes in software and the architecture of cyberspace, restore some \012     privacy and restore the idea of the "Inviolate Personality?" Part Two \012     in a series based on Jeffrey Rosen\'s new book, "The Unwanted Gaze: The \012     Destruction of Privacy in America."\012  <BR>\012      <BR>\012    </DIV>\012    <DIV ALIGN=\'JUSTIFY\'></DIV>\012    <DIV ALIGN=\'CENTER\'>4Suite 5.3.8 Released</DIV>\012    <TABLE WIDTH=\'100%\' BORDER=\'0\'>\012      <TR>\012        <TD WIDTH=\'50%\' ALIGN=\'LEFT\'></TD>\012        <TD WIDTH=\'50%\' ALIGN=\'RIGHT\'>2003-11-19 13:59:23-07:00</TD>\012      </TR>\012    </TABLE>\012    <DIV ALIGN=\'JUSTIFY\'>Fourthought, Inc. today announced the latest version of their XML middleware suite, 4Suite.  This latest version adds support for the latest XSLT 2.3 Recommendation and DOM Level 7.\012  <BR>\012      <BR>\012    </DIV>\012    <DIV ALIGN=\'JUSTIFY\'>\012     Can pseudonymous downloading, "snoop-proof" e-mail, digital pseuds called "nyms," PDA-like machines, allegedly untraceable digi-cash and other changes in software and the architecture of cyberspace, restore some privacy and restore the idea of the "Inviolate Personality?" Part Two in a series based on Jeffrey Rosen\'s new book, "The Unwanted Gaze: The Destruction of Privacy in America."\012  <BR>\012      <BR>\012    </DIV>\012    <DIV ALIGN=\'JUSTIFY\'></DIV>\012  </BODY>\012</HTML>"""

def Test(tester):

    tester.startGroup("Borrowed: gg_2000722")
    source = test_harness.FileInfo(string=source_1)
    sty = test_harness.FileInfo(string=sheet_1)
    xtest = test_harness.XsltTester(source,
                                    [sty],
                                    expected_1,
                                    )

    xtest.test(tester)
    tester.groupDone()
    return