Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
XML
<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

XML
<!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
Updated 27-Jun-12 19:08pm
v2
Comments
krumia 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 28-Jun-12 2:09am    
What have you tried so far? Any effort?
sanju_09 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

Hi Sandeep,
I am developing the below xsl but facing lot many challenges.Would really appreciate if you could help me.
XML
<?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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900