<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
dir=ltr><HEAD><TITLE>Can text imported from an XML file be formatted?</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16674" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=625155607-20062008><FONT face=Arial
color=#0000ff size=2>You can also set the properties in icons with
code</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=625155607-20062008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=625155607-20062008><FONT face=Arial
color=#0000ff size=2>icon.nextSibling.attributes.label =
myLabel;</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=625155607-20062008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=625155607-20062008><FONT face=Arial
color=#0000ff size=2>Which is sometimes more convenient, especially whenyou want
to dynamically generate ids for icons. e.g. you might be building a hot object
type interaction, and the objects are text icons duplicated based on the xml you
load. In that case you might want to also set up event handlers for each object,
so you duplicate the text icons, and then duplicate a prototypical event
handler, and you then loop over the icons to set the id property on the text
icons and the icon property on the event handlers,</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> xerte-bounces@lists.nottingham.ac.uk
[mailto:xerte-bounces@lists.nottingham.ac.uk] <B>On Behalf Of </B>Paul
Swanson<BR><B>Sent:</B> 19 June 2008 22:58<BR><B>To:</B> Xerte discussion
list<BR><B>Subject:</B> RE: [Xerte] Can text imported from an XML file be
formatted?<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>Thanks, Jules</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>I figured there must be a way. Your
suggestion works great.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>I'm basing my piece off the example you refer to, and
was already loading the XML into templateData, then grabbing the <quiz>
node and assigning it to an object called quizData. I'm accessing it with
quizData.question[0] syntax. And I'm using the duplicate() method you describe
in the example to automatically build the pages from the
XML.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>I also figured out a way to automagically prefix a
letter to each option, so the question/options look like:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>How many beans make five?</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>A) One</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>B) Two</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>C) ...</FONT></SPAN></DIV></BLOCKQUOTE>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>I did this by creating a variable to hold the ASCII
character code for A:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>// create a variable to convert answer number to
character<BR>charCode = 65; // ASCII code for letter A</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>Then on the radio button response, I set the label property
to:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>{String.fromCharCode(charCode + icon.index()) + ') '
+ quizData.question[quesIndex].answer[icon.index()]}</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>I love the power of Xerte's scripting!</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=772314421-19062008><FONT face=Verdana
color=#0000ff size=2>Paul</FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> xerte-bounces@lists.nottingham.ac.uk
[mailto:xerte-bounces@lists.nottingham.ac.uk] <B>On Behalf Of </B>Tenney
Julian<BR><B>Sent:</B> Thursday, June 19, 2008 2:21 PM<BR><B>To:</B> Xerte
discussion list<BR><B>Subject:</B> RE: [Xerte] Can text imported from an XML
file be formatted?<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV id=idOWAReplyText36894 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>you're on the right
lines</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2><question><![CDATA[How
<b>long</b> is a piece of
string]]></question></FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>will do what you need.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>If you set the templateData property of
the LO icon to FileLocation + 'myXMLFile.xml', you'll get the data from the
XML as an object, which is much easier / more convenient to handle. So, your
file looks like this:</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2><quiz></FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2> <question><![CDATA[How
long is a piece of string?]]></question></FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2> <question><![CDATA[How
many beans make five?]]></question></FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></quiz></FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>then you can access the data
using:</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>templateData.quiz[0].question[0];
//returns 'How long is a piece of string?'</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>and</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr>
<DIV dir=ltr><FONT face=Arial size=2>templateData.quiz[0].question[1];
//returns 'How many beans make five?'</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>Xerte takes care of loading the data up,
and it all exists in that object form before the piece starts to play - no
need to load it or handle any events. Your code can start to use it rightaway.
Your file will be more complex of course, but you ge the idea. It's very
powerful - look at the developing templates doc on the website for some ideas
about making your piece dynamic. Xerte really excels in this area -
because you can create icons at runtime based on the data (one of the things I
always wanted AW to be able to do). The example in the doc is a quiz, so
you'll find it useful if you haven't read it already,</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>J</FONT></DIV></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> xerte-bounces@lists.nottingham.ac.uk on
behalf of Paul Swanson<BR><B>Sent:</B> Thu 19/06/2008 19:59<BR><B>To:</B>
xerte@lists.nottingham.ac.uk<BR><B>Subject:</B> [Xerte] Can text imported from
an XML file be formatted?<BR></FONT><BR></DIV>
<DIV>
<P><FONT face=Verdana size=2>I'm making an XML file to hold quiz information,
and I wonder if there is a way to make some words from the quiz bold or a
different color? I found that if I insert html tags, such as
<b></b> within the xml text that text is truncated at the first
< when displayed in Xerte. Would using [!CDATA[]] tags allow me to insert
html tags, and if so, how?</FONT></P>
<P><FONT face=Verdana size=2>My XML file has questions in the following
format:</FONT> </P>
<P><FONT face="Courier New" size=2><question></FONT>
<BR> <FONT face="Courier New"
size=2><prompt>Which item under Policy controls access to the simple
policies in LPL?</prompt></FONT>
<BR> <FONT face="Courier New"
size=2><answer correct="false">Policy Components</answer></FONT>
<BR> <FONT face="Courier New"
size=2><answer correct="false">Standard Policies</answer></FONT>
<BR> <FONT face="Courier New"
size=2><answer correct="true">Default Policies</answer></FONT>
<BR> <FONT face="Courier New"
size=2><answer correct="false">Access Limitations</answer></FONT>
<BR><FONT face="Courier New" size=2></question></FONT> </P>
<P><FONT face=Verdana size=2>If I wanted to bold the word 'Policy' in the
<prompt> node, how would I do that?</FONT> </P>
<P><FONT face="Courier New" color=#808080
size=2>_____________________________</FONT> </P>
<P><FONT face="Courier New" color=#808080 size=2> Paul Swanson</FONT>
<BR><FONT face="Courier New" color=#808080 size=2> Instructional
Designer</FONT> <BR><FONT face="Courier New" color=#808080
size=2> Harland Financial Solutions</FONT> <BR><FONT face="Courier New"
color=#808080 size=2> 800.274.7280 Ext. 2462</FONT> <BR><FONT
face="Courier New" color=#808080
size=2> Paul.Swanson@harlandfs.com</FONT> <BR><FONT face="Courier New"
color=#808080 size=2>_____________________________</FONT>
</P></DIV></BLOCKQUOTE></BODY></HTML>