Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Coding/Programming Interviews:Active Template Library (ATL)ActiveXApplication DeveloperArtificial intelligenceAssemblyAssociate Software EngineerAWKAWTC ProgrammingC++ ProgrammingCGI PerlCGI ProgrammingCMMICobolCritical ReasoningData Structures TreesDCOM COMDelphiDTDE4XExtensible Stylesheet Language (XSL)FortranFull-Stack DeveloperHaskellHTML DOMILUIPhone DeveloperJasper Reports DeveloperJava DeveloperLisp ProgrammingLotus NotesMicrosoft Foundation Class (MFC)Mobile DeveloperMVC DeveloperNode.jsOOPPascalPerl ProgrammingPHPPHP DeveloperProgrammingProgramming AlgorithmsProgramming ConceptsPythonRubyRuby on RailsRuby on Rails DeveloperSenior Front End DeveloperSenior Software DeveloperSignature ProgramSOASocket ProgrammingSoftware Development EngineerSoftware engineeringSr. PHP ProgrammerStack And QueueSTLSwift DeveloperTCL (Tool Command Language)Team Leader Android DeveloperUMLUnity 2D Games DeveloperUnity 3D DeveloperUnity DeveloperVBA (Visual Basic for Applications)Visual Basic (VB)Visual C++Web DevelopmentWin32APIWindows ProgramingWordPress DevelopmentWSDLXFormsXHTMLXLinkXMLXPathXQueryXSL-FOXSLT
Copyright © 2018. All Rights Reserved
XSLT Interview Question:
How to transform an XML into XHTML?
Submitted by: AdministratorBelow, I write an example which show you how transform an XML into XHTML.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="html"/>
<xsl:template match="/persons">
<html>
<head>
<title>Test an XML Example</title>
</head>
<body>
<h1>Persons</h1>
<ul>
<xsl:apply-templates select="person">
<xsl:sort select="family-name" />
</xsl:apply-templates>
</ul>
</body>
</html>
</xsl:template>
<xsl:template match="person">
<li>
<xsl:value-of select="family-name"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="name"/>
</li>
</xsl:template>
</xsl:stylesheet>
To get output on the XHTML we write like that,
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Test an XML Example</title> </head>
<body>
<h1>Persons</h1>
<ul>
<li>gupta, Abhi</li>
<li>jain, sudi</li>
</ul>
</body>
</html>
Submitted by: Administrator
Example:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="html"/>
<xsl:template match="/persons">
<html>
<head>
<title>Test an XML Example</title>
</head>
<body>
<h1>Persons</h1>
<ul>
<xsl:apply-templates select="person">
<xsl:sort select="family-name" />
</xsl:apply-templates>
</ul>
</body>
</html>
</xsl:template>
<xsl:template match="person">
<li>
<xsl:value-of select="family-name"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="name"/>
</li>
</xsl:template>
</xsl:stylesheet>
To get output on the XHTML we write like that,
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Test an XML Example</title> </head>
<body>
<h1>Persons</h1>
<ul>
<li>gupta, Abhi</li>
<li>jain, sudi</li>
</ul>
</body>
</html>
Submitted by: Administrator
Copyright 2007-2025 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.