www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > XML

    XML Discussion and technical support for using and deploying XML applications and websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-07-2009, 09:51 AM
    manishrathi manishrathi is offline
    Registered User
     
    Join Date: Jun 2009
    Posts: 61
    using xsl for root element

    This is an xml file, that is to be transformed to html document
    HTML Code:
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="article1.xsl"?>
       
       <article>
          <headline>Blowing XML Bubbles</headline>
            |
             |
    This is xsl style sheet which transforms xml file into html

    HTML Code:
    <?xml version="1.0"?>
    
    <xsl:stylesheet version="1.0" xmlns="http://www.w.org/1999/XSL/Transform">
    <xsl:output method="html" />
    
    <xsl:template match="/">
       <HTML>
          <HEAD>
             <TITLE>
                  <xsl:value-of select="article/headline">
                 |
                  |
    Is it must to use <xsl:template match="/"> ? Can I just avoid root template and create xsl by putting "/" as root before article in value-of tag as below ?
    HTML Code:
    <?xml version="1.0"?>
    
    <xsl:stylesheet version="1.0" xmlns="http://www.w.org/1999/XSL/Transform">
    <xsl:output method="html" />
    
       <HTML>
          <HEAD>
             <TITLE>
                  <xsl:value-of select="/article/headline">
                 |
                  |
    Or do I need to have root template in the stylesheet ? How can we create <xsl:apply-templates /> outside root template ? For example, I have a paragraph in xml file which contains some bold words. Now to create these words bold in html doc , I can use following code
    HTML Code:
    <xsl:template match="bold">
       <B>
            <xsl:apply-templates />
       </B>
    </xsl:template>
    This code is used outside root template, why is it allowed outside root template ?

    Please explain in detail as reading from book did not help
    Reply With Quote
      #2  
    Old 11-07-2009, 09:55 AM
    Charles's Avatar
    Charles Charles is offline
    JavaScript Banned
     
    Join Date: Nov 2002
    Location: Baltimore, Maryland
    Posts: 11,667
    Try it both ways.
    __________________
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web
    Reply With Quote
      #3  
    Old 11-09-2009, 06:23 PM
    rnd me's Avatar
    rnd me rnd me is offline
    working on the chain...
     
    Join Date: Jul 2008
    Location: urbana, il
    Posts: 1,273
    just think of each template as a chunk of the final output.
    the more chunks you have, the easier it is to re-arrange the output.

    you don't need a root template, but it sure helps.
    you will probably find xml "leaking out" if you don't use one.

    you can have as many templates as you like, each with a specific purpose.
    you seem to be using match and apply, but i like name and call better; it's more specific.

    everytime <xsl:apply-templates /> is called, every template is examined to see if it's match attrib matches the current node context. If it does, the results of the template evaluation are inserted into the place where the <xsl:apply-templates /> is.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 08:25 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.