Example #1
0
def test_apply_import1():
    _run_xml(
        source_xml="<example><spam/></example>",
        transform_uri=iri.os_path_to_uri(__file__),
        transform_xml="""\
<xsl:transform version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>

<xsl:import href="cs_20070210-1.xslt"/>

<xsl:template match="/">
  <xsl:apply-templates mode="foo"/>
</xsl:template>

<xsl:template match="example" mode="foo">
  <div>
    <span>b</span>
    <xsl:apply-imports/>
  </div>
</xsl:template>

</xsl:transform>""",
        expected="""<?xml version="1.0" encoding="UTF-8"?>
<div><span>b</span><span>a</span></div>""",
    )
Example #2
0
def test_apply_import1():
    _run_xml(
        source_xml = "<example><spam/></example>",
        transform_uri = iri.os_path_to_uri(__file__),
        transform_xml = """\
<xsl:transform version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>

<xsl:import href="cs_20070210-1.xslt"/>

<xsl:template match="/">
  <xsl:apply-templates mode="foo"/>
</xsl:template>

<xsl:template match="example" mode="foo">
  <div>
    <span>b</span>
    <xsl:apply-imports/>
  </div>
</xsl:template>

</xsl:transform>""",
        expected = """<?xml version="1.0" encoding="UTF-8"?>
<div><span>b</span><span>a</span></div>""",
        )
Example #3
0
def test_xslt_uo_20010503_3():
  _run_xml(
    source_xml = """<?xml version='1.0'?>
<x xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="include2.xi" parse='text'/>
</x>
""",
    transform_xml = common_transform,
    expected = """<?xml version="1.0" encoding="UTF-8"?>
<x xmlns:xi="http://www.w3.org/2001/XInclude">
&lt;?xml version='1.0' encoding='utf-8'?&gt;%(linesep)s&lt;foo xmlns:xi="http://www.w3.org/2001/XInclude"&gt;%(linesep)s  &lt;xi:include href="include1.xml"/&gt;%(linesep)s&lt;/foo&gt;
</x>""" % {'linesep' : LINESEP},
    )
Example #4
0
def test_xslt_uo_20010503_1():
  _run_xml(
    source_xml = """<?xml version='1.0'?>
<x xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="include1.xi"/>
</x>
""",
    transform_xml = common_transform,
    expected = """<?xml version="1.0" encoding="UTF-8"?>
<x xmlns:xi="http://www.w3.org/2001/XInclude">
<foo xml:base="%s"/>
</x>""" % iri.absolutize("include1.xi", BASE_URI),
    )
Example #5
0
def test_xslt_uo_20010503_3():
    _run_xml(
        source_xml="""<?xml version='1.0'?>
<x xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="include2.xi" parse='text'/>
</x>
""",
        transform_xml=common_transform,
        expected="""<?xml version="1.0" encoding="UTF-8"?>
<x xmlns:xi="http://www.w3.org/2001/XInclude">
&lt;?xml version='1.0' encoding='utf-8'?&gt;%(linesep)s&lt;foo xmlns:xi="http://www.w3.org/2001/XInclude"&gt;%(linesep)s  &lt;xi:include href="include1.xml"/&gt;%(linesep)s&lt;/foo&gt;
</x>""" % {'linesep': LINESEP},
    )
Example #6
0
def test_xslt_uo_20010503_1():
    _run_xml(
        source_xml="""<?xml version='1.0'?>
<x xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="include1.xi"/>
</x>
""",
        transform_xml=common_transform,
        expected="""<?xml version="1.0" encoding="UTF-8"?>
<x xmlns:xi="http://www.w3.org/2001/XInclude">
<foo xml:base="%s"/>
</x>""" % iri.absolutize("include1.xi", BASE_URI),
    )
Example #7
0
def test_xslt_vars_2_mb_20020907():
    transform = """<?xml version="1.0" encoding="utf-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:variable name="var1" select="'foo'"/>
  <xsl:variable name="var2" select="'bar'"/>
  <xsl:variable name="culprit" select="concat($var1,$var2)"/>

  <xsl:template match="/"/>

</xsl:transform>
"""
    _run_xml(
        source_xml = commonsource,
        transform_uri = __file__,
        transform_xml = transform,
        expected = commonexpected)
Example #8
0
def test_xslt_nested_imports_with_names_that_clash_across_import_precedence_mb_20020527():
    _run_xml(
        source_xml = "<foo/>",
        transform_uri = iri.os_path_to_uri(__file__),
        transform_xml = """<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:import href="resources/mb_20020527-1.xsl"/>

  <xsl:template name="i">
    <foo>import.xsl</foo>
  </xsl:template>

</xsl:stylesheet>
""",
        expected = """<?xml version="1.0" encoding="UTF-8"?>\n<out><foo>import.xsl</foo></out>""",
        )
Example #9
0
def test_xslt_nested_imports_with_names_that_clash_across_import_precedence_mb_20020527(
):
    _run_xml(
        source_xml="<foo/>",
        transform_uri=iri.os_path_to_uri(__file__),
        transform_xml="""<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:import href="resources/mb_20020527-1.xsl"/>

  <xsl:template name="i">
    <foo>import.xsl</foo>
  </xsl:template>

</xsl:stylesheet>
""",
        expected=
        """<?xml version="1.0" encoding="UTF-8"?>\n<out><foo>import.xsl</foo></out>""",
    )
Example #10
0
def test_xslt_ft_write_file_og_20010503():
    _run_xml(
        source_xml="""\
<?xml version="1.0" encoding="ISO-8859-1"?>

<test>
  <data>11</data>
  <data>12</data>
  <data>13</data>
  <data>14</data>
  <data>15</data>
</test>
""",
        transform_xml="""\
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:exsl="http://exslt.org/common"
    extension-element-prefixes="exsl">

<xsl:output method="text" encoding="ISO-8859-1"/>

<xsl:template match="/">
  <xsl:apply-templates select="test/data"/>
</xsl:template>

<xsl:template match="data">
  <xsl:variable name="file" select="concat('%s',.,'.xml')"/>
  <exsl:document href="{$file}" method="xml" indent="yes" encoding="ISO-8859-1">
    <datatree>
      <name><xsl:value-of select="."/></name>
      <what>test</what>
    </datatree>
  </exsl:document>
</xsl:template>

</xsl:stylesheet>""" % BASENAME_URI,
        expected="",
    )
Example #11
0
def test_xslt_ft_write_file_og_20010503():
    _run_xml(
        source_xml = """\
<?xml version="1.0" encoding="ISO-8859-1"?>

<test>
  <data>11</data>
  <data>12</data>
  <data>13</data>
  <data>14</data>
  <data>15</data>
</test>
""",
        transform_xml = """\
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:exsl="http://exslt.org/common"
    extension-element-prefixes="exsl">

<xsl:output method="text" encoding="ISO-8859-1"/>

<xsl:template match="/">
  <xsl:apply-templates select="test/data"/>
</xsl:template>

<xsl:template match="data">
  <xsl:variable name="file" select="concat('%s',.,'.xml')"/>
  <exsl:document href="{$file}" method="xml" indent="yes" encoding="ISO-8859-1">
    <datatree>
      <name><xsl:value-of select="."/></name>
      <what>test</what>
    </datatree>
  </exsl:document>
</xsl:template>

</xsl:stylesheet>""" % BASENAME_URI,
        expected = "",
)
Example #12
0
 def test_borrowed(source_xml=source_xml,
                   transform_xml=transform_xml,
                   expected=expected_out):
     _run_xml(source_xml=inputsource(source_xml),
              transform_xml=inputsource(transform_xml),
              expected=inputsource(expected).stream.read())
Example #13
0
 def test_borrowed(source_xml=source_xml, transform_xml=transform_xml, expected=expected_out):
     _run_xml(
         source_xml = inputsource(source_xml),
         transform_xml = inputsource(transform_xml),
         expected = inputsource(expected).stream.read())