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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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.

   
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.