DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: XSL does not transforme correctly

  1. #1
    Join Date
    Nov 2005
    Posts
    2

    XSL does not transform correctly

    Hello

    I am using XSL within XML Spy Professional Edition to extract certain elements from an XML file called 'model.xml'.

    The XSL code does not work.

    Pasted below is the XSL code:
    ----------------------------------------

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:template match="/project/namespace/querySubject/queryItem">
    <xsl:for-each select="columnName">
    <p> <xsl:value-of select="text() " /></p>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
    ----------------------------------------------------------------

    Below is a snippet of the source XML file of relevance to this post:
    -------------------------------------------------------------------

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://www.developer.cognos.com/schemas/bmt/32/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.developer.cognos.com/schemas/bmt/32/3 BMTModelSpecification.xsd">
    <name>XpoPlanTrak</name>
    <locales>
    <locale>en</locale>
    </locales>
    <defaultLocale>en</defaultLocale>
    <namespace>
    <name locale="en">XpoPlanTrak</name>
    <lastChanged>2005-11-17T11:08:00</lastChanged>
    <querySubject status="valid">
    <name locale="en">Xponent PlanTrak</name>
    <lastChanged>2005-11-14T16:02:27</lastChanged>
    <definition>
    <dbQuery>
    <sources>
    <dataSourceRef>[].[dataSources].[XpoPlanTrak]</dataSourceRef>
    </sources>
    <sql type="cognos">Select * from [XpoPlanTrak].STG_XPO_PLANTRAK_MU</sql>
    <index>
    <unique>false</unique>
    <queryItems_collection>
    <refobj>[XpoPlanTrak].[Xponent PlanTrak].[IMS_ID]</refobj>
    </queryItems_collection>
    </index>
    <index>
    <unique>false</unique>
    <queryItems_collection>
    <refobj>[XpoPlanTrak].[Xponent PlanTrak].[PRODUCT_GROUP]</refobj>
    </queryItems_collection>
    </index>
    </dbQuery>
    </definition>
    <queryItem>
    <name locale="en">CLIENT_NBR</name>
    <lastChanged>2005-11-14T16:02:06</lastChanged>
    <columnName>XPMU_CLIENT_NBR</columnName>
    <usage>fact</usage>
    <datatype>float64</datatype>
    <size>8</size>
    <nullable>true</nullable>
    <regularAggregate>sum</regularAggregate>
    <semiAggregate>sum</semiAggregate>
    <collationSequenceName>OR_WE8ISO8859P1</collationSequenceName>
    <collationSequenceLevel>2</collationSequenceLevel>
    <originalEncodingName>WE8ISO8859P1</originalEncodingName>
    </queryItem>
    ----------------------------------------------------------------

    The element near the end viz. 'queryItem' is the one I want to query. Within this element I want to output the PCDATA values for the 'name' sub element and 'columnName' sub element.

    There are numerous occurrences of the 'queryItem' element.

    Could you please let me know where I need to correct my code.

    Thanks very much
    Naveen
    Last edited by 3nikki; 11-22-2005 at 04:41 PM.

  2. #2
    Join Date
    Nov 2005
    Posts
    7

    XSLT output

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:template match="//project/namespace/querySubject/queryItem">
    <xsl:for-each select="columnName">
    <p> <xsl:value-of select="text() " /></p>
    </xsl:for-each>
    </xsl:template>

    or

    <xsl:template match="/">
    <xsl:for-each select="project/namespace/querySubject/queryItem/columnName">
    <p> <xsl:value-of select="text() " /></p>
    </xsl:for-each>
    </xsl:template>


    </xsl:stylesheet>

    Try this.

  3. #3
    Join Date
    Nov 2005
    Posts
    2

    XSL does not transform correctly

    Hi Raman

    Thanks for your response. It does not work. I do not even get an output with your script.

    Naveen

  4. #4
    Join Date
    Nov 2005
    Posts
    7
    what transformation tool you have used? saxon?, xalan?, or IE browser and further more I didn't get your full xml. You try with different xpaths like //project/namespace like that

Similar Threads

  1. Replies: 1
    Last Post: 11-23-2002, 02:40 AM
  2. XML and XSL transforming
    By grothlander in forum XML
    Replies: 0
    Last Post: 12-03-2001, 11:06 AM
  3. Replies: 0
    Last Post: 03-20-2001, 02:11 PM
  4. Replies: 2
    Last Post: 03-20-2001, 02:08 PM
  5. MS XSL ISAPI Extension
    By Ryan Tomayko in forum XML
    Replies: 0
    Last Post: 05-26-2000, 05:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center