0

i try code from How can I use XSLT to assemble an XML Hierarchy

a.xml:

    <Xml>
        <Classes>
            <Class Name="BIOLOGY101" ClassId="11"/>
            <Class Name="PHYSICS101" ClassId="13"/>
            <Class Name="CALCULUS101" ClassId="17"/>
            <Class Name="BIOLOGY101" ClassId="19"/>
        </Classes>
    </Xml>

b.xml :

<Xml>
    <Students>
        <Student Name="Bob Johnson" ClassId="11"/>
        <Student Name="Bob Johnson" ClassId="17"/>
        <Student Name="Bob Johnson" ClassId="19"/>
        <Student Name="Joe Jackson" ClassId="11"/>
        <Student Name="Joe Jackson" ClassId="13"/>
        <Student Name="Joe Jackson" ClassId="17"/>
        <Student Name="Rick Robertson" ClassId="13"/>
        <Student Name="Rick Robertson" ClassId="17"/>
        <Student Name="Rick Robertson" ClassId="19"/>
    </Students>
</Xml>

Stylesheet (merge.xsl):

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="Class">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <!-- Apply <Student> elements from b.xml -->
      <xsl:apply-templates
        select="document('b.xml')/Xml/Students/Student
          [@ClassId = current()/@ClassId]"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="Student">
    <xsl:copy>
      <xsl:apply-templates select="@Name"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

hope output :

    <?xml version="1.0"?>
<Xml>
  <Classes>
    <Class Name="BIOLOGY101" ClassId="11">
      <Student Name="Bob Johnson"/>
      <Student Name="Joe Jackson"/>
    </Class>
    <Class Name="PHYSICS101" ClassId="13">
      <Student Name="Joe Jackson"/>
      <Student Name="Rick Robertson"/>
    </Class>
    <Class Name="CALCULUS101" ClassId="17">
      <Student Name="Bob Johnson"/>
      <Student Name="Joe Jackson"/>
      <Student Name="Rick Robertson"/>
    </Class>
    <Class Name="BIOLOGY101" ClassId="19">
      <Student Name="Bob Johnson"/>
      <Student Name="Rick Robertson"/>
    </Class>
  </Classes>
</Xml>

but when i launching with a.xml, i get the result is BLANK.. nothing showing anything in my browser mozilla.. (note : in header a.xml i write this code :

    <?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="merge.xsl"?>

somebody can me please ?? thanks..

Community
  • 1
  • 1
Rijal
  • 1
  • 3

1 Answers1

0

It is working fine. Press F12 in order to view the result. For more information Please refer why browser (Firefox/Chrome) is showing blank result.

Attached screenshot (Developer tool)

enter image description here

Why XSLT is not working in browser

Community
  • 1
  • 1
nawazlj
  • 779
  • 8
  • 18
  • still not working @nawazlj and i have look in http://stackoverflow.com/questions/29941662/xslt-not-working-in-web-browser , but still not working.. – Rijal Jul 20 '16 at 02:24
  • @Rijal can you add your screenshot what it is coming after pressing `F12`. – nawazlj Jul 20 '16 at 04:23
  • i just know after press f12, showing the result: @nawazlj thanks buudy it's working :) – Rijal Jul 20 '16 at 07:03
  • @Rijal if it's correct answer then please accept answer – nawazlj Jul 20 '16 at 07:08
  • can you help me please again.. i want my result use stylesheet like :
    Nim Mahasiswa :
    example, how to my result using table.. best regards.. Rijal
    – Rijal Jul 20 '16 at 07:09
  • after look your screenshot, i already know look in tab class.. and it's working.. i got what i want, thanks buddy (y) @nawazlj – Rijal Jul 20 '16 at 07:12