Example #1
0
def Test(tester):
    tester.startTest("Checking for BIG5 codec")
    try:
        import codecs
        big5_decoder = codecs.getdecoder('big5')
    except LookupError:
        try:
            from encodings import big5
        except ImportError:
            tester.warning(
                "No BIG5 encoding support for case 1.  You can install \n"
                "BIG5 by downloading and installing ChineseCodes from\n"
                "ftp://python-codecs.sourceforge.net/pub/python-codecs/")
            tester.testDone()
            return
        else:
            big5_decode = big5.decode
    else:
        big5_decode = lambda s: big5_decoder(s)[0]
    tester.testDone()

    b5 = big5_decode(source_1)
    utf8 = b5.encode("utf-8")

    source = test_harness.FileInfo(string=utf8)
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester, source, [sheet], expected_1)

    source = test_harness.FileInfo(string=source_2)
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester, source, [sheet], expected_2)
    return
Example #2
0
def Test(tester):
    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_1,
                          title="mixed XML and HTML in HTML output; indent=no")

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(
        tester,
        source, [sheet],
        expected_2,
        title="mixed XML and HTML in HTML output; indent=yes")

    source = test_harness.FileInfo(string=source_3)
    sheet = test_harness.FileInfo(string=sheet_3)
    test_harness.XsltTest(
        tester,
        source, [sheet],
        expected_3,
        title="deeply mixed XML and HTML in HTML output; indent=yes")

    return
Example #3
0
def Test(tester):
    source = test_harness.FileInfo(string="<ignored/>")

    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected,
                          title='Import with variables')

    sheet = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected,
                          title='Import with params')

    sheet = test_harness.FileInfo(string=error_sheet_1)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          "",
                          exceptionCode=Error.DUPLICATE_TOP_LEVEL_VAR,
                          title='Include with variables')

    sheet = test_harness.FileInfo(string=error_sheet_2)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          "",
                          exceptionCode=Error.DUPLICATE_TOP_LEVEL_VAR,
                          title='Include with params')
    return
Example #4
0
def Test(tester):
    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_1,
                          topLevelParams={'currentLanguage': 'en'},
                          title='Selector sheet 1, source 1, lang=en')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_2,
                          topLevelParams={'currentLanguage': 'ja'},
                          title='Selector sheet 1, source 1, lang=ja')

    source = test_harness.FileInfo(string=uche_source_1)
    sheet = test_harness.FileInfo(string=uche_sheet_1)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          uche_expected_1,
                          topLevelParams={'currentLanguage': 'en'},
                          title="Uche's selector sheet 1, source 1, lang=en")

    # Don't run until we can try on Matt's console to avoid terminal corruption
    ##    source = test_harness.FileInfo(string=uche_source_1)
    ##    sheet = test_harness.FileInfo(string=uche_sheet_1)
    ##    test_harness.XsltTest(tester, source, [sheet], uche_expected_2,
    ##                          topLevelParams={'currentLanguage' : 'ja'})
    ##                          title="Uche's selector sheet 1, source 1, lang=ja")
    return
Example #5
0
def Test(tester):
    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_1,
                          title='Default encoding')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_2,
                          title='UTF-8 encoding')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_3)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_3,
                          title='ISO-8859-1 encoding')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_4)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_4,
                          title='Default output method and encoding')
    return
Example #6
0
def Test(tester):
    tester.startGroup('forwards-compatible processing')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1a)
    test_harness.XsltTest(tester, source, [sheet], expected_1a,
                          title='1.0 sty w/non-1.0 top-level elem')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1b)
    test_harness.XsltTest(tester, source, [sheet], expected_1b,
                          exceptionCode=Error.ILLEGAL_ELEMENT_CHILD,
                          title='1.0 sty w/implicit 1.0 illegal top-level elem')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1c)
    test_harness.XsltTest(tester, source, [sheet], expected_1c,
                          exceptionCode=Error.ILLEGAL_ELEMENT_CHILD,
                          title='1.0 sty w/explicit 1.0 illegal top-level elem')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1d)
    test_harness.XsltTest(tester, source, [sheet], expected_1d,
                          exceptionCode=Error.ILLEGAL_ELEMENT_CHILD,
                          title='3.0 sty w/explicit 1.0 illegal top-level elem')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1e)
    test_harness.XsltTest(tester, source, [sheet], expected_1e,
                          title='3.0 sty w/3.0 top-level elem illegal in 1.0')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(tester, source, [sheet], expected_2,
                          title='forwards-compatible example from XSLT 1.0 spec')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_3)
    test_harness.XsltTest(tester, source, [sheet], expected_3,
                          title='1.0 literal result elem w/fallback')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_4)
    test_harness.XsltTest(tester, source, [sheet], expected_4,
                          title='uninstantiated non-1.0 literal result elem')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_5)
    test_harness.XsltTest(tester, source, [sheet], expected_5,
                          title='non-1.0 literal result elem w/fallback')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_6)
    test_harness.XsltTest(tester, source, [sheet], expected_6,
                          exceptionCode=Error.FWD_COMPAT_WITHOUT_FALLBACK,
                          title='non-1.0 literal result elem w/o fallback')

    tester.groupDone()
    return
Example #7
0
def Test(tester):
    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(uri='Xml/Xslt/Borrowed/rdftripledump.xslt')
    test_harness.XsltTest(tester, source, [sheet], expected_1)

    source = test_harness.FileInfo(string=source_2)
    sheet = test_harness.FileInfo(uri='Xml/Xslt/Borrowed/rdftripledump.xslt')
    test_harness.XsltTest(tester, source, [sheet], expected_2)
    return
Example #8
0
def Test(tester):
    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester, source, [sheet], expected_1, title='test 1')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(tester, source, [sheet], expected_2, title='test 2')
    return
Example #9
0
def Test(tester):
    source = test_harness.FileInfo(uri='Xml/Xslt/Core/addr_book1.xml')
    sheet = test_harness.FileInfo(uri='Xml/Xslt/Core/addr_book1.xsl')
    test_harness.XsltTest(tester, source, [sheet], EXPECTED1, title='test 1')

    tester.startTest('test 1 using Ft.Xml.Xslt.Transform')
    result = Transform('Xml/Xslt/Core/addr_book1.xml',
                       'Xml/Xslt/Core/addr_book1.xsl')
    tester.compare(EXPECTED1, result, func=TreeCompare.HtmlTreeCompare)
    tester.testDone()

    source = test_harness.FileInfo(uri='Xml/Xslt/Core/addr_book1.xml')
    sheet = test_harness.FileInfo(string=SHEET2)
    test_harness.XsltTest(tester, source, [sheet], EXPECTED2, title='test 2')

    source = test_harness.FileInfo(uri='Xml/Xslt/Core/addr_book1.xml')
    sheet = test_harness.FileInfo(string=SHEET3)
    test_harness.XsltTest(tester, source, [sheet], EXPECTED3, title='test 3')

    source = test_harness.FileInfo(string=SOURCE4, validate=1)
    sheet = test_harness.FileInfo(string=SHEET4)
    test_harness.XsltTest(tester, source, [sheet], EXPECTED4, title='test 4')

    tester.startTest('alternate stream output using Ft.Xml.Xslt.Transform')
    stream = cStringIO.StringIO()
    result = Transform('Xml/Xslt/Core/addr_book1.xml',
                       'Xml/Xslt/Core/addr_book1.xsl',
                       output=stream)
    tester.compare(EXPECTED1,
                   stream.getvalue(),
                   func=TreeCompare.HtmlTreeCompare)
    tester.testDone()

    tester.startTest('top-level-param overide using Ft.Xml.Xslt.Transform')
    result = Transform(
        SOURCE5,
        SHEET5,
        params={
            'override': 'xyz',
            'list': ['a', 'b', 'c']
        },
    )
    tester.compare(EXPECTED5, result, func=TreeCompare.XmlTreeCompare)
    tester.testDone()

    # Appending explicit stylesheet when xml-stylesheet PI already
    # specifies one results in both stylesheets being appended. If
    # it's the same stylesheet, it's an error.
    #
    #source = test_harness.FileInfo(uri='Xml/Xslt/Core/addr_book1.xml')
    #sheet = test_harness.FileInfo(uri='Xml/Xslt/Core/addr_book1.xsl')
    #    test_harness.XsltTest(tester, source, [sheet], EXPECTED1, ignorePis=0,
    #                          title='test 5')

    return
Example #10
0
def Test(tester):
    source = test_harness.FileInfo(string=SOURCE_1)
    sheet = test_harness.FileInfo(string=SHEET_1)
    test_harness.XsltTest(tester, source, [sheet], EXPECTED_1,
                          title="EXSLT str:replace within func:function")

    source = test_harness.FileInfo(string=SOURCE_1)
    sheet = test_harness.FileInfo(string=SHEET_2)
    test_harness.XsltTest(tester, source, [sheet], EXPECTED_1,
                          title="EXSLT regex:replace within func:function")
    return
Example #11
0
def Test(tester):
    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester, source, [sheet], expected_1)

    #Test again with a specfied baseUri
    uri = Uri.OsPathToUri(os.path.abspath(__file__))
    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1, baseUri=uri)
    test_harness.XsltTest(tester, source, [sheet], expected_1)
    return
Example #12
0
def Test(tester):
    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester, source, [sheet], expected_1,
                          title="xsl:attribute with namespace from top-level param 1")

    source = test_harness.FileInfo(string=source_2)
    sheet = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(tester, source, [sheet], expected_2,
                          title="xsl:attribute with namespace from top-level param 2")
    return
Example #13
0
def Test(tester):
    source = test_harness.FileInfo(uri="Xml/Xslt/Core/addr_book1.xml")
    sty = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester, source, [sty], expected_1, title='xsl:if')

    source = test_harness.FileInfo(string=source_2)
    sty = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(tester,
                          source, [sty],
                          expected_2,
                          title="test text and element children of xsl:if")
    return
Example #14
0
def Test(tester):
    source = test_harness.FileInfo(uri="Xml/Xslt/Borrowed/slides4svg.xml")
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester, source, [sheet], expected_1, title='test 1')

    source = test_harness.FileInfo(uri="Xml/Xslt/Borrowed/slides4svg.xml")
    sheet = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(tester, source, [sheet], expected_2, title='test 2')

    source = test_harness.FileInfo(string=source_2)
    sty = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(tester, source, [sheet], expected_3, title='test 3')
    return
Example #15
0
def test_Test(tester):
    sty = """\
<?xml version="1.0"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:regexp="http://exslt.org/regular-expressions"
  version="1.0"
>

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:value-of select="regexp:test(., 'no', 'g')"/>
  </xsl:template>

</xsl:stylesheet>
"""
    source = test_harness.FileInfo(string=SOURCE)
    sheet = test_harness.FileInfo(string=sty)
    expected = "true"
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected,
                          title='regexp:test() global')

    sty = """\
<?xml version="1.0"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:regexp="http://exslt.org/regular-expressions"
  version="1.0"
>

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:value-of select="regexp:test(., 'exslt', 'gi')"/>
  </xsl:template>

</xsl:stylesheet>
"""
    source = test_harness.FileInfo(string=SOURCE)
    sheet = test_harness.FileInfo(string=sty)
    expected = "true"
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected,
                          title='regexp:test() global, case-insensitive')
    return
Example #16
0
def Test(tester):
    source = test_harness.FileInfo(string=xml_source)
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_1,
                          title='Using position()')

    source = test_harness.FileInfo(string=xml_source)
    sheet = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_2,
                          title='Using xsl:for-each and xsl:sort')
    return
Example #17
0
def Test(tester):
    source = test_harness.FileInfo(string=source_2)
    sheet = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_2,
                          title='xsl:copy')

    source = test_harness.FileInfo(uri='Xml/Xslt/Core/addr_book1.xml')
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_1,
                          title="Identity transform")
    return
Example #18
0
def Test(tester):
    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_1,
                          title='With default namespace')

    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(tester,
                          source, [sheet],
                          expected_2,
                          title='With named namespace')
    return
Example #19
0
def Test(tester):

    tester.startGroup("Literal elements and text")

    source = test_harness.FileInfo(string=source_1)
    sty = test_harness.FileInfo(string=sheet_1)
    test_harness.XsltTest(tester, source, [sty], expected_1, title='test 1')

    source = test_harness.FileInfo(string=source_2)
    sty = test_harness.FileInfo(string=sheet_2)
    test_harness.XsltTest(tester, source, [sty], expected_2, title='test 2')

    tester.groupDone()

    return
Example #20
0
def Test(tester):
    source = test_harness.FileInfo(string=SOURCE_1)
    sty = test_harness.FileInfo(string=SHEET_1)
    test_harness.XsltTest(tester, source, [sty], EXPECTED_1,
                          title="ft:uri-to-element")

    return
Example #21
0
def test_closure(tester):
    TRANSFORM = """<?xml version='1.0' encoding='UTF-8'?>
<xsl:transform
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:dyn="http://exslt.org/dynamic"
  exclude-result-prefixes="dyn"
  version="1.0"
>

  <xsl:template match="doc">
    <result>
      <xsl:for-each select="dyn:closure(*, '*[@x]')">
        <node>
          <xsl:value-of select="@x"/>
        </node>
      </xsl:for-each>
    </result>
  </xsl:template>

</xsl:transform>
"""

    SOURCE2 = """<doc><a x='1'><e x='2'/></a><b x='3'><f/></b><c><g x='4'/></c><d x='5'><h x='6'/></d></doc>"""

    EXPECTED = '<?xml version="1.0" encoding="UTF-8"?>\n<result><node>2</node><node>4</node><node>6</node></result>'

    source = test_harness.FileInfo(string=SOURCE2)
    transform = test_harness.FileInfo(string=TRANSFORM)
    test_harness.XsltTest(tester,
                          source, [transform],
                          EXPECTED,
                          title='dyn:closure()')
    return
Example #22
0
def test_Concat(tester):
    src = """\
<a>
  <c>Is this EXSLT? No. no</c>
  <c>Is this EXSLT? No. no</c>
  <c>Is this EXSLT? No. no</c>
</a>
"""
    sty = """\
<?xml version="1.0"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:str="http://exslt.org/strings"
  version="1.0"
>

  <xsl:output method="text"/>

  <xsl:template match="/a">
    <xsl:value-of select="str:concat(c)"/>
  </xsl:template>

</xsl:stylesheet>
"""
    source = test_harness.FileInfo(string=src)
    sheet = test_harness.FileInfo(string=sty)
    expected = "Is this EXSLT? No. no" * 3
    test_harness.XsltTest(tester, source, [sheet], expected,
                          title='str:concat()')
    return
Example #23
0
def test_Padding(tester):
    sty = """<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:str="http://exslt.org/strings"
  extension-element-prefixes="str"
>

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:copy-of select="str:padding(20, '---4567----23----890----------')"/>
    <xsl:text>&#10;</xsl:text>
    <xsl:value-of select="."/>
    <xsl:text>&#10;</xsl:text>
    <xsl:copy-of select="str:padding(10, '+-+')"/>
  </xsl:template>

</xsl:stylesheet>"""

    expected = """\
---4567----23----890
Is this EXSLT? No. no
+-++-++-++"""

    source = test_harness.FileInfo(string=SOURCE)
    sheet = test_harness.FileInfo(string=sty)
    test_harness.XsltTest(tester, source, [sheet], expected,
                          title='str:padding()')
    return
Example #24
0
def test_Intersection(tester):
    sty = """\
<?xml version="1.0"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:set="http://exslt.org/sets"
  xmlns:x="http://uche.ogbuji.net/dummy"
  version="1.0"
>

  <xsl:output method="text"/>

  <x:spam/>
  <x:eggs/>

  <xsl:variable name='self' select='document("")/*'/>
  <xsl:variable name='empty' select='/parent::*'/>

  <xsl:template match="/">
    <xsl:variable name='result' select='set:intersection($self/x:*, $self/x:spam)'/>
    <xsl:value-of select='count($result)'/>
    <xsl:text> </xsl:text>
    <xsl:value-of select='name($result)'/>
  </xsl:template>

</xsl:stylesheet>
"""
    source = test_harness.FileInfo(string=SOURCE)
    sheet = test_harness.FileInfo(string=sty)
    expected = "1 x:spam"
    test_harness.XsltTest(tester, source, [sheet], expected,
                          title='set:intersection()')
    return
Example #25
0
def Test(tester):
    source = test_harness.FileInfo(string=source_1)
    sheet = test_harness.FileInfo(uri='Xml/Xslt/Borrowed/dchudnov.xslt')
    test_harness.XsltTest(tester, source, [sheet], expected_1,
                          title='General XSLT features and processing time')

    return
Example #26
0
def test_map1(tester):
    TRANSFORM = """<?xml version='1.0' encoding='UTF-8'?>
<xsl:transform
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:dyn="http://exslt.org/dynamic"
  exclude-result-prefixes="dyn"
  version="1.0"
>

  <xsl:template match="doc">
    <result>
      <xsl:for-each select="dyn:map(*, '@id')">
        <num>
          <xsl:value-of select="."/>
        </num>
      </xsl:for-each>
    </result>
  </xsl:template>

</xsl:transform>
"""

    EXPECTED = '<?xml version="1.0" encoding="UTF-8"?>\n<result><num>1</num><num>2</num><num>3</num><num>4</num></result>'

    source = test_harness.FileInfo(string=SOURCE)
    transform = test_harness.FileInfo(string=TRANSFORM)
    test_harness.XsltTest(tester,
                          source, [transform],
                          EXPECTED,
                          title='dyn:map()')
    return
Example #27
0
def Test(tester):
    source = test_harness.FileInfo(string=SOURCE_1)
    sty = test_harness.FileInfo(string=SHEET_1)
    test_harness.XsltTest(tester,
                          source, [sty],
                          EXPECTED_1,
                          title="f:decode, f:encode and f:raw-text-output")
Example #28
0
def Test(tester):
    tester.startGroup('pick stylesheet from xml-stylesheet PIs')
    for tup in tests:
        (title_st, source_st, expected_st) = tup[:3]
        errcode = None
        media = None
        if len(tup) > 3:
            errcode = tup[3]
        if len(tup) > 4:
            media = tup[4]
        expected = expected_st or ''
        source = test_harness.FileInfo(string=source_st, baseUri=uri)
        if media:
            proc = Processor.Processor()
            proc.mediaPref = media
            tester.startTest(title_st)
            isrc = DefaultFactory.fromString(source_st, uri)
            result = proc.run(isrc, ignorePis=0)
            tester.compare(expected_st, result, func=TreeCompare.TreeCompare)
            tester.testDone()
            del proc, isrc, result
        else:
            test_harness.XsltTest(tester,
                                  source, [],
                                  expected,
                                  exceptionCode=errcode,
                                  title=title_st,
                                  ignorePis=0)
    tester.groupDone()
    return
Example #29
0
def test_evaluate1(tester):
    TRANSFORM = """<?xml version='1.0' encoding='UTF-8'?>
<xsl:transform
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:dyn="http://exslt.org/dynamic"
  exclude-result-prefixes="dyn"
  version="1.0"
>

  <xsl:template match="doc">
    <result>
      <xsl:for-each select="*">
        <num>
          <xsl:value-of select="dyn:evaluate(concat('name(/doc/*[', position(), '])'))"/>
        </num>
      </xsl:for-each>
    </result>
  </xsl:template>

</xsl:transform>
"""

    EXPECTED = '<?xml version="1.0" encoding="UTF-8"?>\n<result><num>otu</num><num>abuo</num><num>ato</num><num>ano</num></result>'

    source = test_harness.FileInfo(string=SOURCE)
    transform = test_harness.FileInfo(string=TRANSFORM)
    test_harness.XsltTest(tester,
                          source, [transform],
                          EXPECTED,
                          title='dyn:evaluate()')
    return
Example #30
0
def test_map4(tester):

    TRANSFORM = """<?xml version='1.0' encoding='UTF-8'?>
<xsl:transform
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:dyn="http://exslt.org/dynamic"
  exclude-result-prefixes="dyn"
  version="1.0"
>

  <xsl:template match="doc">
    <result>
      <xsl:for-each select="dyn:map(*, '. > 2')">
        <num>
          <xsl:copy-of select="."/>
        </num>
      </xsl:for-each>
    </result>
  </xsl:template>

</xsl:transform>
"""

    EXPECTED = '<?xml version="1.0" encoding="UTF-8"?>\n<result><num><exsl:boolean xmlns:exsl="http://exslt.org/common"/></num><num><exsl:boolean xmlns:exsl="http://exslt.org/common"/></num><num><exsl:boolean xmlns:exsl="http://exslt.org/common">true</exsl:boolean></num><num><exsl:boolean xmlns:exsl="http://exslt.org/common">true</exsl:boolean></num></result>'

    source = test_harness.FileInfo(string=SOURCE2)
    transform = test_harness.FileInfo(string=TRANSFORM)
    test_harness.XsltTest(tester,
                          source, [transform],
                          EXPECTED,
                          title='dyn:map() w/boolean expr')
    return