XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
mebi mathewSubject: html tag ignored
Author: mebi mathew
Date: 20 Nov 2007 08:58 AM
Hi all
I have a xml,xsl and java file.My xsl file is calling a java method and doing an encryption.
My xml file is as follows

<itemfeedback title="Correct Answer" ident="LID1_FBK1">
<material> <matextension><a href="http://www.gmail.com">Gmail</a>
<a href="http://www.gmail.com">Gmail1</a></matextension> </material>
</itemfeedback>

My xsl file is as follows

<xsl:for-each select="./itemfeedback">
<xsl:if test="@title != 'Hint'">
<xsl:variable name="fbTitle">
<xsl:value-of select = "@title"/>
</xsl:variable>
<xsl:variable name="fbText">
<xsl:choose>
<xsl:when test="material/matextension">
<xsl:for-each select="material/matextension">
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select = "normalize-space(material/mattext)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<xsl:variable name="encryptedfbTitle" select="util:encryptString(string(./@title))"/>
<xsl:variable name="fbTextModified" select="util:substituteSingleQuote(string($fbText))"/>
<xsl:variable name="encryptedfbText" select="util:encryptString(string($fbTextModified))"/>

<xsl:value-of select="$answer"/>[<xsl:value-of select="position()"/>].feedBackTitle = '<xsl:value-of select = "$encryptedfbTitle"/>';
<xsl:value-of select="$answer"/>[<xsl:value-of select="position()"/>].feedBackText = '<xsl:value-of select = "$encryptedfbText"/>';
</xsl:if>
</xsl:for-each>

<xsl:template match="h1|h2|h3|h4|h5|h6|b|big|i|small|s|strike|sub|sup|tt|u|font|br|pre|center|hr|blockquote|q|address|ins|del|div|p|abbr|acronym|cite|code|dfn|em|strong|samp|var|span|area|map|ol|ul|dir|li|dl|dt|dd|table|tr|td|th|thead|tfoot|tbody|caption|applet|param|script|form|input|textarea|select|option">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

My java file is as follows

public static String substituteSingleQuote(String original) {
if (original == null) return "";
String singleQuote = "'";
String singleQuoteEntity = "'";

if (original.indexOf(singleQuote) < 0)
return original;

StringBuffer orig = new StringBuffer("");
int position = original.indexOf(singleQuote);
while (position >= 0) {
int ampEntityPos = original.indexOf(singleQuoteEntity);
orig.append(original.substring(0, position));
orig.append(singleQuoteEntity);
if (ampEntityPos == position)
original = original.substring(position + singleQuoteEntity.length());
else
original = original.substring(position + singleQuote.length());
position = original.indexOf(singleQuote);
}

orig.append(original);

return orig.toString();
}
public static String encryptString(String text){
System.out.println(text);
StringBuffer buff = new StringBuffer();
int key = 150;


if((!text.equals(""))&&(!text.equals(null))){

int length = text.length();
for ( int i=0; i<length ; i++ ){
buff.append((char)( text.charAt(i) ^ key ));
}

buff.append(key);
return buff.toString();
}else{
return "";
}
}

xsl is calling the encryptString method but the problem for me is the output which is coming in encryptString method is wrong.Output is coming as GmailGmail1 The output should come as <a href="http://www.gmail.com">Gmail</a>
<a href="http://www.gmail.com">Gmail1</a>

Posttop
Minollo I.Subject: html tag ignored
Author: Minollo I.
Date: 20 Nov 2007 03:20 PM
General XSLT questions are better asked on the xsl-list email list run by Mulberry Technologies.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.