Error in XML formatting caused by adding an image

Here is the XML code I am working with:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="staff.xsl"?>
<st>        
    <employee>
        <name>
            <firstname>Clay</firstname>
            <lastname>Hansen</lastname>
        </name>

        <jobtitle>Professor</jobtitle>

        <department>Department: Communication and Marketing</department>
        <office>Office: CH-H 111</office>
        <phone>Phone: (847)257-1234</phone>
        <email>Email: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ee8d828f97c086ae8f8c8dc08d818dc380">[email protected]</a></email>
        <profile>
            <html xmlns="http://www.w3.org/1999/xhtml">
                <img src="C:\Users\username\Desktop\im.jpg" />                                                                           
            </html>
        </profile>
    </employee>
</st>

https://i.sstatic.net/q2uvl.png I have encountered an issue where adding an image to my XML causes the data not to be displayed in a tabular form, but rather as words in a sentence. How can I go about solving this problem?

Answer №1

The reason behind this is that xsl:value-of retrieves the text nodes of an element's subtree without any markup (in this case, there isn't any). If you want to duplicate the img node, you can do so with the following code:

<xsl:for-each select="employee">
   <td>
       <xsl:copy-of select="profile//xhtml:img"></xsl:copy-of>
   </td>
</xsl:for-each>

Just remember to specify the xhtml namespace in your stylesheet to work with the img nodes:

xmlns:xhtml="http://www.w3.org/1999/xhtml"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Say goodbye to using 'jQuery .load()' with <img> elements inside <a> tags

I have a static HTML page and some other files with the same structure but different content. <div id="textRed" class="scrollbar"> <h1>Header</h1> <p>Lorem Ipsum</p> <a href="images/image1.jpg" data-lightbox ...

Misunderstandings between HTML and CSS

Can someone please clarify how the functionality of the active-slide class? Code: <div class="slider"> <div class="slide active-slide">..</div> <div class = "slide slide-feature">..</div> <div class = "slide">..</di ...

Trouble with achieving equal height columns in nested flexbox layout on Google Chrome

I am looking to evenly space several sidebar blocks throughout a lengthy post. To achieve this, I have utilized Flexbox within the sidebar for handling the even distribution of the blocks and it has been working flawlessly. Check out Code Pen: http://cod ...

Using ngFor to render elements in several table rows

Looking for a solution to display a Python list using Angular in multiple rows instead of a single table row. The current setup is showing more than 200 objects in a single row which is not ideal. List=[1,2,3,4,5, .......100} This is the HTML currently b ...

I am in search of a specialized 3D camera with a unique effect

I am seeking assistance with animating a camera to replicate or closely resemble the effect seen in this demo: Any help would be greatly appreciated. ...

Using the HTML5 time element to include milliseconds in a form

If we take a look at this website, we can see various examples of HTML5 form options, one being the "time" element. Can we customize the time element to include milliseconds as well? I'm not interested in using a plain text box as a fallback option. ...

Custom plugin shortcode HTML appearing within WordPress Edit Page interface

After developing my first WordPress plugin, I encountered a slight issue. Upon activating the plugin, the edit page screen became distorted. Attached is a screenshot for reference. https://i.sstatic.net/wB5aj.png Upon further inspection, it seems that th ...

Automatically expanding PrimeNG Turbotable rows

I am using a PrimeNg turbotable that has a row expansion feature enabled. I am looking for a way to automatically expand the rows by default when the table loads. Shown below is my code: HTML <p-table [columns]="cols" [value]="cars" dataKey="vin"> ...

jQuery not triggering when selecting items from dropdown list

I used to have a dropdownlist in my HTML with the following code: <select id="customDropDown" name="mydropdown"> <option value="CourseIDFilter"id ="1" class ="choosefilter" >Course ID </option> <option value="CourseNameFilter" i ...

Why is my CSS causing a div with 100% width to be slightly taller than expected?

I am working on a website that I want to adjust to the width of different browsers. Everything seems to be functioning properly, except for the fact that the parent div containing the 100% width divs always appears around 5 pixels too tall. This is causin ...

What method is used to determine Muslim prayer times in an android app?

Currently working on my university project which involves creating an Android application. My focus is on developing an app that assists Muslim users in tracking daily prayer times. Despite being a newcomer to the world of Android development and programmi ...

Is there a way to dynamically update CSS based on user input in ASP Razor?

Hey there, I want my users to be able to change the theme on the index page. Currently, I have implemented a code that works with a form select and submit button, but it's not very user-friendly. I would like it so that when a user selects option x, t ...

Repeating linear gradients in the background

After creating a linear-gradient background animation in CSS for my to-do list, I encountered an issue. As I added more items to the list, the website became scrollable and the background started repeating, which made it look unappealing. I attempted to s ...

Issue with Bootstrap Carousel displaying as a static image instead of a slide

I have worked on creating a Portfolio.js file using the react library with react-bootstrap Carousel.js to build an uncontrolled carousel. However, my code is showing the slides vertically instead of behaving like a typical carousel. You can view my code at ...

Ways to enhance the sharpness of an image when using transform scale

I noticed that when I use transform: scale(1.1); on hover for a specific element, the image appears blurry. Any suggestions on how to resolve this issue? Here is an example: https://i.sstatic.net/6zsky.jpg ...

What is the best way to automatically direct users to their profile page after logging in?

After logging in, I need to redirect users to their profile page. The issue I'm encountering is figuring out how to pass the user_id into the URL for successful redirection. I've researched various solutions for this common problem without succe ...

AngularJs - Show the response only upon verifying the correct answer

Let me provide an overview of what has been implemented so far: When a user selects an answer in radio buttons and clicks on "Check Answer", the system displays either "Correct" (in green) or "Incorrect" (in red) in the first answer field. Additionally, th ...

Angular - Applying styles to child components when parent components are hovered over

What is the best way to style a child component when hovering on a parent component, even across component boundaries in Angular 17? The traditional method of using parent:hover .child in the parent CSS doesn't seem to work on the child component. Is ...

What is the jQuery plugin that can search for elements and display them in real-time within a DIV?

Currently, I am in search of a jQuery plugin that can assist me with the following: Ability to have an input field for user search text Search through my elements and display only those that match the search string entered by the user. Essentially creati ...

PHP's 'importStyleSheet' function is a useful tool

I am having trouble running the importStyleSheet function and keep getting a warning message when I try to execute it: Warning: XSLTProcessor::importStylesheet() expects parameter 1 to be object, boolean given. The file paths are correct. Below is the c ...