Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:07:57+00:00 2026-06-11T09:07:57+00:00

Okay so I’ve been having trouble with my first XML project, so I’ve turned

  • 0

Okay so I’ve been having trouble with my first XML project, so I’ve turned to you guys. I’m trying to produce an address book using an XML file that contains the contacts data, that is then transformed in XSLT. Both the XML and XSLT files work correctly, but my problem begins when I try to implement my CSS file into the XSLT so I can format the page to match the rest of the website. Once the CSS is implemented, my table only shows the first row given in the XSLT and stops. Given below is the code for my three files, and the given response with the CSS file included.

XML:

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

<!DOCTYPE addressbook [
<!ELEMENT addressbook (contact)>
<!ELEMENT contact (fname,lname,mi,staddress,city,state,zip,phone,email,twitter)>
<!ELEMENT fname (#PCDATA)>
<!ELEMENT lname (#PCDATA)>
<!ELEMENT mi (#PCDATA)>
<!ELEMENT staddress (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT state (#PCDATA)>
<!ELEMENT zip (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT twitter (#PCDATA)>
]>
<addressbook>
<contact>
<fname>Peyton</fname>
<lname>Manning</lname>
<mi>Z</mi>
<staddress>123 Go Vols</staddress>
<city>Denver</city>
<state>CO</state>
<zip>12345</zip>
<phone>1-800-youwish</phone>
<email>pmanning@broncos.com</email>
<twitter>peyton_manning</twitter>
</contact>

<contact>
<fname>Eric</fname>
<lname>Berry</lname>
<mi>P</mi>
<staddress>123 Arrowhead Stadium</staddress>
<city>Kansas City</city>
<state>MO</state>
<zip>34567</zip>
<phone>816-213-4452</phone>
<email>eberry@chiefs.com</email>
<twitter>eric_berry</twitter>
</contact>
</addressbook>

XSLT:

<?xml-stylesheet type="text/css" href="sitetemplate.css"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>


 <xsl:template match="/*">
    <html>
        <body>
            <table>
                <tr>
                    <th>First Name</th>
                    <th>Last Name</th>
                    <th>Middle Initial</th>
                    <th>Street Address</th>
                    <th>City</th>
                    <th>State</th>
                    <th>Zip</th>
                    <th>Phone</th>
                    <th>Email</th>
                    <th>Twitter</th>
                </tr>
                <xsl:apply-templates/>
            </table>
        </body>
    </html>
 </xsl:template>

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

 <xsl:template match="contact/*">
  <td><xsl:value-of select="."/></td>
 </xsl:template>
</xsl:stylesheet>

CSS:

.text {font-family: Helvetica, Times, serif; color:white;}

.center {text-align:center;}

body {background-image:url('wallpaper.jpg'); font-family: Helvetica, Times, serif;}

hr {border: 0; width: 50%; color:white;}

table, th, td {border:10px white; background-color:blue; color:white;} 


a:link {color:#75B8FA; text-decoration:none;}
a:visited {color:#75B8FA; text-decoration:none;}
a:hover {color:#75B8FA; text-decoration:none;}
a:active {color:#FFFFFF; text-decoration:none;}

And what is shown on the browser when trying to run: http://i144.photobucket.com/albums/r171/jmock89/giventable.png
(Sorry it’s an outside link, I can’t post images on StackOverflow until I have 10 rep.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:07:58+00:00Added an answer on June 11, 2026 at 9:07 am

    If your CSS stylesheet is at: http://myUrl.com/myCSS.css
    then include the following in the transformation, immediately after <html>:

            <head>
              <link rel="stylesheet"
                    type="text/css"
                    href="http://myUrl.com/myCSS.css"/>
            </head>
    

    Alternatively, generate the styles inline:

            <head>
              <style>
                        .text {font-family: Helvetica, Times, serif; color:white;}
    
                        .center {text-align:center;}
    
                        body {background-image:url('wallpaper.jpg'); font-family: Helvetica, Times, serif;}
    
                        hr {border: 0; width: 50%; color:white;}
    
                        table, th, td {border:10px white; background-color:blue; color:white;}
    
    
                        a:link {color:#75B8FA; text-decoration:none;}
                        a:visited {color:#75B8FA; text-decoration:none;}
                        a:hover {color:#75B8FA; text-decoration:none;}
                        a:active {color:#FFFFFF; text-decoration:none;}
              </style>
            </head>
    

    Yet another alternative:

    Generate the necessary processing instruction:

    <?xml-stylesheet type="text/css" href="sitetemplate.css"?>
    

    To do so, add this (immediately preceding <html>):

     <xsl:processing-instruction
     name="xml-stylesheet">type="text/css" href="sitetemplate.css"</xsl:processing-instruction>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so here is what I'm trying to accomplish. First of all below table
Okay, so I'm trying to create a Order Posts by Type using jQuery JSON
okay, so I am using prolog to build a simple xml parser. And I
Okay, so I'm doing my first foray into using the ADO.NET Entity Framework. My
Okay, so I know that using eval() isn't great, but I haven't been able
Okay, I feel a bit foolish for having to ask this but I guess
Okay so the title may be a bit misleading. What I am trying to
Okay, so I'm trying to make a game that uses this algorithm: http://www.codeproject.com/Articles/15573/2D-Polygon-Collision-Detection But
Okay, I'm trying to reverse engineer a feature on a website I found -
Okay, here is one weird bug... In my app, I load multiple xml files.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.