Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: XML XSLT
Hi,
I am new to xslt,I have an urgent requirement to convert an xml file to html file using xslt.Could any one helpme in getting xslt file for the below mentioned xml file urgently,help will be highly appreciated.
 
XML file content
<assessmentItem identifier="">
  <itemBody>
    <div id="questionText"><![CDATA[<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="HMAvenir" SIZE="20" COLOR="#000000" LETTERSPACING="0" KERNING="0"><B>1.  </B>What can eyes do?</FONT></P></TEXTFORMAT>]]></div>
    <div id="text_item_1"><![CDATA[<TEXTFORMAT LEADING="2"><P ALIGN="CENTER"><FONT FACE="HMAvenir" SIZE="20" COLOR="#000000" LETTERSPACING="0" KERNING="0"><B>Assessment</B></FONT></P></TEXTFORMAT>]]></div>
    <choiceInteraction identifier="McqComp_item_7" label="blockInteraction" responseIdentifier="Response#McqComp_item_7" shuffle="false" maxChoices="1">
      <simpleChoice identifier="option_item_8">
        <div id="optionText_item_9"><![CDATA[<TEXTFORMAT LEADING="2"><P ALIGN="CENTER"><FONT FACE="HMAvenir" SIZE="18" COLOR="#000000" LETTERSPACING="0" KERNING="0">A </FONT></P></TEXTFORMAT>]]></div>
      </simpleChoice>
      <simpleChoice identifier="option_item_12">
        <div id="optionText_item_13"><![CDATA[<TEXTFORMAT LEADING="2"><P ALIGN="CENTER"><FONT FACE="HMAvenir" SIZE="18" COLOR="#000000" LETTERSPACING="0" KERNING="0">B </FONT></P></TEXTFORMAT>]]></div>
      </simpleChoice>
      <simpleChoice identifier="option_item_14">
        <div id="optionText_item_15"><![CDATA[<TEXTFORMAT LEADING="2"><P ALIGN="CENTER"><FONT FACE="HMAvenir" SIZE="18" COLOR="#000000" LETTERSPACING="0" KERNING="0">C </FONT></P></TEXTFORMAT>]]></div>
      </simpleChoice>
      <simpleChoice identifier="option_item_16">
        <div id="optionText_item_17"><![CDATA[<TEXTFORMAT LEADING="2"><P ALIGN="CENTER"><FONT FACE="HMAvenir" SIZE="18" COLOR="#000000" LETTERSPACING="0" KERNING="0">D </FONT></P></TEXTFORMAT>]]></div>
      </simpleChoice>
    </choiceInteraction>
    <div id="text_item_18"><![CDATA[<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="HMAvenir" SIZE="18" COLOR="#000000" LETTERSPACING="0" KERNING="1">hear</FONT></P></TEXTFORMAT>]]></div>
    <div id="text_item_19"><![CDATA[<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="HMAvenir" SIZE="18" COLOR="#000000" LETTERSPACING="0" KERNING="1">peek</FONT></P></TEXTFORMAT>]]></div>
    <div id="text_item_20"><![CDATA[<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="HMAvenir" SIZE="18" COLOR="#000000" LETTERSPACING="0" KERNING="1">dark</FONT></P></TEXTFORMAT>]]></div>
    <div id="text_item_21"><![CDATA[]]></div>
  </itemBody>
  <responseDeclaration identifier="Response#McqComp_item_7">
    <correctResponse>
      <value>option_item_12</value>
    </correctResponse>
    <mapping defaultValue="0">
      <mapEntry mapKey="option_item_12" mappedValue="1"/>
    </mapping>
  </responseDeclaration>
  <modalFeedback outcomeIdentifier="FEEDBACK" identifier="correct" showHide="show">
    <div id="modalPopup_correct_Container"/>
  </modalFeedback>
  <modalFeedback outcomeIdentifier="FEEDBACK" identifier="incorrect" showHide="show">
    <div id="modalPopup_incorrect_Container">
      <div id="showAnswer"/>
      <div id="tryAgain"/>
    </div>
  </modalFeedback>
</assessmentItem>
 

HTML file content
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>MCQ</title>
    </head>
    <body>
         <div id="mainContent"   type="screencontent">
            <div data-role="ResponseDeclarationComp" type="responseDeclaration" id="McqComp_item_7" data-options='{"responseDeclaration":{"identifier":"Response#MCQ_item_1","correctResponse":["option_item_12"]}}'>
                <operator name="ResponseOperator" value="ResponseOperator">
                </operator>
            </div>
            <div class="mediaContainer" data-role="mediaContainer">
                <div id="direction" class="direction"><b>1. </b>What can eyes do?</div>
            </div>
            <div data-role="McqComp" class="McqComp" type="McqComp" id="McqComp_item_7" responseIdentifier="Response#MCQ_item_1" data-options='{"maxChoices":"1"}'>
                <operator name="McqOperator" value="McqOperator">
                </operator>
    <div data-role="mcqOptionComp" id="option_item_8" type="mcqOption" class="mcqOption option_item_1"><div>A</div></div>
                <div data-role="mcqOptionComp" id="option_item_12" type="mcqOption" class="mcqOption option_item_2"><div>B</div></div>
                <div data-role="mcqOptionComp" id="option_item_14" type="mcqOption" class="mcqOption option_item_3"><div>C</div></div>
                <div data-role="mcqOptionComp" id="option_item_16" type="mcqOption" class="mcqOption option_item_4"><div>D</div></div>
            </div>
            <div id="text_item_18" class="text_item_1"><div>hear</div></div>
            <div id="text_item_19" class="text_item_2"><div>peek</div></div>
            <div id="text_item_20" class="text_item_3"><div>dark</div></div>
            <div id="text_item_21" class="text_item_4"><div>thin</div></div>
 
            <div data-role="ModalFeedbackComp" class="ModalFeedbackComp" type="modalFeedbackComp" data-options='{"modal":false,"isCentered":true, "feedbackType":"correct"}'>
                <operator name="FeedbackOperator" value="FeedbackOperator">
                </operator>
            </div>
         </div>
    </body>
</html>
 
Thanks in Advance,
Sanjeev
Posted 27-Jun-12 18:59pm
Edited 27-Jun-12 20:08pm
krumia11.9K
v2
Comments
krumia at 28-Jun-12 1:11am
   
What have you done so far?
 
If I answered your question, it would be me programming for you. Please refer to this tutorial: http://w3schools.com/xsl/xsl_transformation.asp
 
If you have any question while developing, please don't hesitate to ask. But people here don't code for free.
Sandeep Mewara at 28-Jun-12 2:09am
   
What have you tried so far? Any effort?
sanjeev_82 at 28-Jun-12 3:23am
   
Hi Sandeep,
Could you please help me in getting correct xslt.I am facing too many problems
 
Regards,
Sanjeev

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi Sandeep,
I am developing the below xsl but facing lot many challenges.Would really appreciate if you could help me.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">
    <xsl:output method="xhtml"  use-character-maps="html-unescape" />
 
    <xsl:character-map name="html-unescape">
        <xsl:output-character character="&lt;" string="&lt;" />
        <xsl:output-character character="&gt;" string="&gt;" />
    </xsl:character-map>
 

 
    <xsl:template match="/" >
 
        <html>
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
                <title>MCQ</title>
            </head>
            <body>
 
                <div id="mainContent"   type="screencontent">
                    <!--<div data-role="ResponseDeclarationComp" type="responseDeclaration" id="McqComp_item_7" data-options='{"responseDeclaration":{"identifier":"Response#MCQ_item_1","correctResponse":["option_item_12"]}}'>-->
                    <div>
                        <operator name="ResponseOperator" value="ResponseOperator">
                        </operator>
                    </div>
                    <div class="mediaContainer" data-role="mediaContainer">
                        <div id="direction" class="direction"><b>1. </b>What can eyes do?</div>
                    </div>
                    <operator name="McqOperator" value="McqOperator">
                    </operator>
                    <xsl:apply-templates/>
                </div>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>
 
    <xsl:template match="choiceInteraction/simpleChoice/div/TEXTFORMAT"/>
 

 

 

 

</xsl:stylesheet>
 

Thanks,
Sanjeev
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 BillWoodruff 170
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,777
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 28 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100