Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

XML / Basic XSL Document

Posted on 2004-11-28
2
Medium Priority
?
217 Views
Last Modified: 2013-11-19
Team can someone help me create two basic XSL docs to display the following code in HTML. It's for demo purposes but urgent.  Just a nice clean basic layout.
Thanks kindly

FIRST
====
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Requirements SYSTEM "E:\Documents and Settings\Administrator\Desktop\xml\requirements.dtd">
<Requirements>
     <ProjectTitle>Extensible Markup Project</ProjectTitle>
     <Purpose>Create A XML File</Purpose>
     <InterfaceGuidelines>Web Based Training</InterfaceGuidelines>
     <PublicContent>
          <Sections>
               <Title>Extensible Markup File</Title>
               <Abstract>This is the creation of an XML file</Abstract>
          </Sections>
     </PublicContent>
     <DocumentationArtifacts>
          <Artifact>
               <ArtTitle>Extensible Markup File Creation</ArtTitle>
               <DescriptionofDocument>Shows how to create an XML file</DescriptionofDocument>
          </Artifact>
     </DocumentationArtifacts>
     <Glossary>
          <GlossaryEntry>
               <Word>Extensible Markup Language XML</Word>
               <Definition>Stands for Extensible Markup Language</Definition>
          </GlossaryEntry>
     </Glossary>
</Requirements>



SECOND
=====
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE TimeEntries SYSTEM "E:\Documents and Settings\Administrator\Desktop\xml\timeEntries.dtd">
<TimeEntries>
      <Date>Jan 1st 2005</Date>
      <TotalTime>48</TotalTime>
      <Name>John Smith</Name>
      <ChargeTo>
            <Requirements>YES</Requirements>
      </ChargeTo>
      <Comments>Pay by Cheque</Comments>
</TimeEntries>

0
Comment
Question by:pauldhadialla
2 Comments
 
LVL 6

Accepted Solution

by:
Leviter earned 1600 total points
ID: 12693900
FIRST
====

<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="no" omit-xml-declaration="no" />

<xsl:template match="/Requirements">
      <html>
      <head>
            <title><xsl:value-of select="ProjectTitle"/></title>
      </head>
      <body>
            <h1><xsl:value-of select="ProjectTitle"/></h1>
            
            <p><xsl:value-of select="Purpose"/></p>
            <p><xsl:value-of select="InterfaceGuidelines"/></p>
            
            <xsl:apply-templates select="PublicContent/Sections"/>
            <xsl:apply-templates select="DocumentationArtifacts/Artifact"/>
            
            <br/>
            <br/>
            <h3>Glossary</h3>
            <xsl:apply-templates select="Glossary/GlossaryEntry"/>
      </body>
      </html>
</xsl:template>

<xsl:template match="PublicContent/Sections">
      <h2><xsl:value-of select="Title"/></h2>
      <p><xsl:value-of select="Abstract"/></p>
</xsl:template>

<xsl:template match="DocumentationArtifacts/Artifact">
      <h2><xsl:value-of select="ArtTitle"/></h2>
      <p><xsl:value-of select="DescriptionofDocument"/></p>
</xsl:template>

<xsl:template match="Glossary/GlossaryEntry">
      <xsl:value-of select="Word"/> - <xsl:value-of select="Definition"/><br/>
</xsl:template>

</xsl:stylesheet>


SECOND
======
<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="no" omit-xml-declaration="no" />

<xsl:template match="/TimeEntries">
      <html>
      <head>
            <title>Time entries</title>
      </head>
      <body>
            <table>
                  <tr>
                        <th>Date</th>
                        <th>Totaltime</th>
                        <th>Name</th>
                        <th>ChargeTo</th>
                        <th>Comments</th>
                  </tr>
                  <tr>
                        <td><xsl:value-of select="Date"/></td>
                       <td><xsl:value-of select="TotalTime"/></td>
                       <td><xsl:value-of select="Name"/></td>
                       <td><xsl:value-of select="ChargeTo/Requirements"/></td>
                       <td><xsl:value-of select="Comments"/></td>
                 </tr>
           </table>
      </body>
      </html>
</xsl:template>
</xsl:stylesheet>



This is just something you can do... I don't know what it is you are trying to demo, but this could be a start for a 'cool' demo.  :-)

For the second example I would add an extra level so that multiple time entries are possible. It would look like this:

<TimeEntries>
     <Entry>
          <Date>Jan 1st 2005</Date>
          <TotalTime>48</TotalTime>
          <Name>John Smith</Name>
          <ChargeTo>
               <Requirements>YES</Requirements>
          </ChargeTo>
          <Comments>Pay by Cheque</Comments>
     </Entry>
</TimeEntries>



Good luck with your demo........
0
 
LVL 35

Assisted Solution

by:YZlat
YZlat earned 400 total points
ID: 12695597
FIRST
___________
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

      <xsl:template match="/">
            <TABLE STYLE="border:1px solid red">
                  <TR STYLE="font-family:Verdana; font-size:8pt;color: red; padding:0px 2px;">
                        <TD STYLE="border: 1px solid red">Project Title</TD>
                        <TD STYLE="border: 1px solid red">Purpose</TD>
                        <TD STYLE="border: 1px solid red">Interface Guidelines</TD>
                        <TD STYLE="border: 1px solid red">Section Title</TD>
                        <TD STYLE="border: 1px solid red">Abstract</TD>
                        <TD STYLE="border: 1px solid red">Artifact title</TD>
                        <TD STYLE="border: 1px solid red">Artifact Description</TD>
                        <TD STYLE="border: 1px solid red">Glossary Entry</TD>
                        <TD STYLE="border: 1px solid red">Definition</TD>  

                  </TR>
                  <xsl:for-each select="Requirements">
                        <TR STYLE="font-family:Verdana; font-size:8pt;color: red; padding:0px 2px;">
                              <TD STYLE="border: 1px solid red">
                                    <xsl:value-of select="ProjectTitle" />
                              </TD>
                              <TD STYLE="border: 1px solid red">
                                    <xsl:value-of select="Purpose" />
                              </TD>
                              <TD STYLE="border: 1px solid red">
                                    <xsl:value-of select="InterfaceGuidelines" />
                              </TD>
                              <TD STYLE="border: 1px solid red">
                                    <xsl:value-of select="PublicContent/Title" />
                              </TD>
                              <TD STYLE="border: 1px solid red">
                                    <xsl:value-of select="PublicContent/Abstract" />
                              </TD>
                              
                              <TD STYLE="border: 1px solid red">
                                    <xsl:value-of select="Glossary/GlossaryEntry/Word" />
                              </TD>
                              <TD STYLE="border: 1px solid red">
                                    <xsl:value-of select="Glossary/GlossaryEntry/Definition" />
                              </TD>
                              
                        </TR>
                  </xsl:for-each>

            </TABLE>
 </xsl:template>
 </xsl:stylesheet>
 
 
SECOND
___________
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

      <xsl:template match="/">
            <TABLE STYLE="border:1px solid red">
                  <TR STYLE="font-family:Verdana; font-size:8pt;color: red; padding:0px 2px;">
                        <TD STYLE="border: 1px solid red">Date</TD>
                        <TD STYLE="border: 1px solid red">Total Time</TD>
                        <TD STYLE="border: 1px solid red">Name</TD>
                        <TD STYLE="border: 1px solid red">Requirements</TD>
                        <TD STYLE="border: 1px solid red">Comments</TD>
                  
                  </TR>
                  <xsl:for-each select="TimeEntries">
                        <TR STYLE="font-family:Verdana; font-size:8pt;color: red; padding:0px 2px;">
                              <TD STYLE="border: 1px solid red">
                                    <xsl:value-of select="Date" />
                              </TD>
                              <TD STYLE="border: 1px solid red">
                                    <xsl:value-of select="TotalTime" />
                              </TD>
                              <TD STYLE="border: 1px solid red">
                                    <xsl:value-of select="Name" />
                              </TD>
                              <TD STYLE="border: 1px solid red">
                                    <xsl:value-of select="ChargeTo/Requirements" />
                              </TD>
                              <TD STYLE="border: 1px solid red">
                                    <xsl:value-of select="Comments" />
                              </TD>      
                        </TR>
                  </xsl:for-each>

            </TABLE>
 </xsl:template>
 </xsl:stylesheet>
 
 

Also put this line in your xml file on the very top:

<?xml-stylesheet type="text/xsl" href="myXSLFile.xslt"?>

 following <?xml version="1.0" encoding="UTF-8" ?>
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question