RE: [xsl] XSL new user question: no output from a simple XSLT

Subject: RE: [xsl] XSL new user question: no output from a simple XSLT
From: "Bjorndahl, Brad" <brad.bjorndahl@xxxxxxxxxxxxxxxx>
Date: Wed, 19 Sep 2007 11:26:47 -0400
Hi,

You need to use namespaces and XPath correctly.

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xpath-default-namespace="http://www.ca.com/erwin/data";
xmlns="http://www.ca.com/erwin/data";>
  <xsl:output method="xml" indent="yes"/>

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

  <xsl:template match="Subject_Area_Groups">
    <Subject_Areas>
      <xsl:apply-templates select="Subject_Area"/>
    </Subject_Areas>
  </xsl:template>

  <xsl:template match="Subject_Area">
    <Subject_Area>
      <xsl:value-of select="@name"/>
   </Subject_Area>
  </xsl:template>

</xsl:stylesheet>


Brad


-----Original Message-----
From: Dunk, Michael (Mike) [mailto:mikedunk@xxxxxxxxxxxxx]
Sent: September 19, 2007 10:21 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] XSL new user question: no output from a simple XSLT

Hi,

I'm new to XSLT, working my way through O'Reilly's XSLT and reading Michael
Kay's XSLT Reference. At the moment, I'm stuck on some simple XSLT. I have
looked through the dpawson.com  and www.biglist.com/lists/xsl-list/archives/
for solutions but cannot find anything that solves this problem.

Can anyone help?

The aim is to transform a complex xml file called Subject_Area_Groups.xml, see
below for a sample of this xml:


<?xml version="1.0" encoding="UTF-8"?>
<Subject_Area_Groups xmlns="http://www.ca.com/erwin/data";
xmlns:UDP="http://www.ca.com/erwin/metadata";
                     xmlns:EMX="http://www.ca.com/erwin/data";
                     xmlns:EM2="http://www.ca.com/erwin/EM2data";>

<Subject_Area id="{39146A35-A713-4CAA-9FBF-9AA575FA9F44}+0000001F"
name="&lt;Main Subject Area&gt;">
      <Subject_AreaProps>
         <Built-in_Id>31</Built-in_Id>
         <Definition/>
         <Name>&lt;Main Subject Area&gt;</Name>

<Long_Id>{39146A35-A713-4CAA-9FBF-9AA575FA9F44}+0000001F</Long_Id>
         <Referenced_Entities_Array>
            <Referenced_Entities
index="0">{0EA17FA0-D21B-4F1E-8B11-A250A6CF266C}+00000000</Referenced_En
tities>
            <Referenced_Entities
index="1">{1F3E974C-F180-45EB-AB59-4D1ACF4BB855}+00000000</Referenced_En
tities>
            <Referenced_Entities
index="2">{3F9BEEE0-35DB-4835-A89E-F2B240EC2CB0}+00000000</Referenced_En
tities>
            <Referenced_Entities
index="3">{24950777-C260-41D2-BEC2-C242E9D642F6}+00000000</Referenced_En
tities>
         </Referenced_Entities_Array>
      </Subject_AreaProps>
</Subject_Area>
<Subject_Area id="{AA629B89-1467-49AC-905F-85A4C4FAC6E3}+00000000"
name="Account - Links">
      <Subject_AreaProps>
         <Definition/>
         <Name>Account - Links</Name>

<Long_Id>{AA629B89-1467-49AC-905F-85A4C4FAC6E3}+00000000</Long_Id>
         <Referenced_Entities_Array>
            <Referenced_Entities
index="0">{7636E0B4-81C3-425A-A465-785583E7900A}+00000000</Referenced_En
tities>
         </Referenced_Entities_Array>
      </Subject_AreaProps>
</Subject_Area>
</Subject_Area_Groups>

into a simple list of Subject_Areas:

<Subject_Areas>

  <Subject_Area>

    <Main Subject Area>

  </Subject_Area>

  <Subject_Area>

     Account - Links

   </Subject_Area>

</Subject_Areas>


The XSLT that I have written so far is:

<?xml version='1.0'?>

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="xml"/>

<xsl:template match="/">

  <xsl:apply-templates select="/Subject_Area"/>

</xsl:template>

<xsl:template match="/Subject_Area">

 <Subject_Areas>

  <xsl:value-of select="/Subject_Area/text()"/>

 </Subject_Areas>

</xsl:template>

</xsl:stylesheet>

Unfortunately, this is not giving any output.

Can anyone see what is wrong with the above XSLT?

The XSLT processor used was Saxon 8.8.0.4J.

Best regards,

Mike



Best regards,

Mike


This email and any files transmitted with it are confidential, proprietary and
intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.

Current Thread