Daily Archives

Articles indexed Saturday April 10 2010

Page 10/89 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • xslt cookbook example not working

    - by Liza dawson
    Hi I am working on this from xslt cookbook type my.xml <?xml version="1.0" encoding="UTF-8"?> <people> <person name="Al Zehtooney" age="33" sex="m" smoker="no"/> <person name="Brad York" age="38" sex="m" smoker="yes"/> <person name="Charles Xavier" age="32" sex="m" smoker="no"/> <person name="David Williams" age="33" sex="m" smoker="no"/> <person name="Edward Ulster" age="33" sex="m" smoker="yes"/> <person name="Frank Townsend" age="35" sex="m" smoker="no"/> <person name="Greg Sutter" age="40" sex="m" smoker="no"/> <person name="Harry Rogers" age="37" sex="m" smoker="no"/> <person name="John Quincy" age="43" sex="m" smoker="yes"/> <person name="Kent Peterson" age="31" sex="m" smoker="no"/> <person name="Larry Newell" age="23" sex="m" smoker="no"/> <person name="Max Milton" age="22" sex="m" smoker="no"/> <person name="Norman Lamagna" age="30" sex="m" smoker="no"/> <person name="Ollie Kensington" age="44" sex="m" smoker="no"/> <person name="John Frank" age="24" sex="m" smoker="no"/> <person name="Mary Williams" age="33" sex="f" smoker="no"/> <person name="Jane Frank" age="38" sex="f" smoker="yes"/> <person name="Jo Peterson" age="32" sex="f" smoker="no"/> <person name="Angie Frost" age="33" sex="f" smoker="no"/> <person name="Betty Bates" age="33" sex="f" smoker="no"/> <person name="Connie Date" age="35" sex="f" smoker="no"/> <person name="Donna Finster" age="20" sex="f" smoker="no"/> <person name="Esther Gates" age="37" sex="f" smoker="no"/> <person name="Fanny Hill" age="33" sex="f" smoker="yes"/> <person name="Geta Iota" age="27" sex="f" smoker="no"/> <person name="Hillary Johnson" age="22" sex="f" smoker="no"/> <person name="Ingrid Kent" age="21" sex="f" smoker="no"/> <person name="Jill Larson" age="20" sex="f" smoker="no"/> <person name="Kim Mulrooney" age="41" sex="f" smoker="no"/> <person name="Lisa Nevins" age="21" sex="f" smoker="no"/> </people> type generic-attr-to-csv.xslt <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:csv="http://www.ora.com/XSLTCookbook/namespaces/csv"> <xsl:param name="delimiter" select=" ',' "/> <xsl:output method="text" /> <xsl:strip-space elements="*"/> <xsl:template match="/"> <xsl:for-each select="$columns"> <xsl:value-of select="@name"/> <xsl:if test="position( ) != last( )"> <xsl:value-of select="$delimiter/> </xsl:if> </xsl:for-each> <xsl:text>&#xa;</xsl:text> <xsl:apply-templates/> </xsl:template> <xsl:template match="/*/*"> <xsl:variable name="row" select="."/> <xsl:for-each select="$columns"> <xsl:apply-templates select="$row/@*[local-name(.)=current( )/@attr]" mode="csv:map-value"/> <xsl:if test="position( ) != last( )"> <xsl:value-of select="$delimiter"/> </xsl:if> </xsl:for-each> <xsl:text>&#xa;</xsl:text> </xsl:template> <xsl:template match="@*" mode="map-value"> <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet> type my.xsl <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:csv="http://www.ora.com/XSLTCookbook/namespaces/csv"> <xsl:import href="generic-attr-to-csv.xslt"/> <!--Defines the mapping from attributes to columns --> <xsl:variable name="columns" select="document('')/*/csv:column"/> <csv:column name="Name" attr="name"/> <csv:column name="Age" attr="age"/> <csv:column name="Gender" attr="sex"/> <csv:column name="Smoker" attr="smoker"/> <!-- Handle custom attribute mappings --> <xsl:template match="@sex" mode="csv:map-value"> <xsl:choose> <xsl:when test=".='m'">male</xsl:when> <xsl:when test=".='f'">female</xsl:when> <xsl:otherwise>error</xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> using the apache xalan parser D:\Test>java org.apache.xalan.xslt.Process -in my.xml -xsl my.xsl -out my.csv [Fatal Error] generic-attr-to-csv.xslt:15:6: The value of attribute "select" associated with an element type "xsl:v alue-of" must not contain the '<' character. file:///D:/Test/generic-attr-to-csv.xslt; Line #15; Column #6; org.xml.sax.SAXParseException: The value of attribut e "select" associated with an element type "xsl:value-of" must not contain the '<' character. java.lang.NullPointerException at org.apache.xalan.transformer.TransformerImpl.createSerializationHandler(TransformerImpl.java:1171) at org.apache.xalan.transformer.TransformerImpl.createSerializationHandler(TransformerImpl.java:1060) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1268) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1251) at org.apache.xalan.xslt.Process.main(Process.java:1048) Exception in thread "main" java.lang.RuntimeException at org.apache.xalan.xslt.Process.doExit(Process.java:1155) at org.apache.xalan.xslt.Process.main(Process.java:1128) Any ideas what am i doing wrong

    Read the article

  • pfSense Firewall or Linsys/Cisco router for small offices

    - by Tim Meers
    I'm about to start switching some networks around for multiple small offices. Each office has about 10 to 15 users and 10 to 15 computers. Each office has a spread of generic routers and access points. The routers vary from being used as routers, to just being an access point for wireless. Nothing formal has really ever beem implemented for each of the 10 offices. What I'm wanting is to set up a pfSense box for each office to configure things like: traffic shaping (for VoIP QOS) URL Filtering DHCP static routing multiple VLANs I'll then use some of the existing hardware for wireless. Maybe even integrate the wireless right into the firewall depending on the office layout. So my question, would this be better to do a full blown firewall box, or but a new business class or high end consumer class Linksys router to do the URL filtering, QOS and DHPC? Each option could allow for remote access and VPN for remote maintnance and each would only cost a nominal about of money for something decent, i.e. under $250.

    Read the article

  • Is it worth caching a Dictionary for foreign key values in ASP.net?

    - by user169867
    I have a Dictionary<int, string> cached (for 20 minutes) that has ~120 ID/Name pairs for a reference table. I iterate over this collection when populating dropdown lists and I'm pretty sure this is faster than querying the DB for the full list each time. My question is more about if it makes sense to use this cached dictionary when displaying records that have a foreign key into this reference table. Say this cached reference table is a EmployeeType table. If I were to query and display a list of employee names and types should I query for EmployeeName and EmployeeTypeID and use my cached dictionary to grab the EmployeeTypeIDs name as each record is displayed or is it faster to just have the DB grab the EmployeeName and JOIN to get the EmployeeType string bypassing the cached Dictionary all together. I know both will work but I'm interested in what will perform the fastest. Thanks for any help.

    Read the article

  • Should you do validation checks that go outside the possiblility of normal user activity?

    - by Scarface
    Hey guys I have been thinking about form security a lot lately. I have been told time and time again to check if form input is a number if you are expecting a number or escape it in case (unless you use proper mysqli formatting) to avoid injection. 1.After the safety checks are done, should I do additional logic checks? For example, if the user is sending a friend request to them-self for example even if my user interface will not show the form if the user is looking at their own page.

    Read the article

  • capture data from FORM using jquery/ajax/json

    - by nisardotnet
    i have few textbox on the form and when the user submit i want to capture the data and insert into db here is what my code looks like beforeSubmit: function(data) { // called just before the form is submitted var item = $("[id$='item']"); var category = $("[id$='category']"); var record = $("[id$='record']"); var json = "{'ItemName':'" + escape(item.val()) + "','CategoryID':'" + category.val() + "','RecordID':'" + record.val() + "'}"; var ajaxPage = "DataProcessor.aspx?Save=1"; //this page is where data is to be retrieved and processed var options = { type: "POST", url: ajaxPage, data: json, contentType: "application/json;charset=utf-8", dataType: "json", async: false, success: function(response) { alert("success: " + response); }, error: function(msg) { alert("failed: " + msg); } }; //execute the ajax call and get a response var returnText = $.ajax(options).responseText; if (returnText == 1) { record.html(returnText); $("#divMsg").html("<font color=blue>Record saved successfully.</font>"); } else { record.html(returnText); $("#divMsg").html("<font color=red>Record not saved successfully.</font>"); } // $("#data").html("<font color=blue>Data sent to the server :</font> <br />" + $.param(data)); }, here is what is the Data sent to the server: if i uncomment this line: // $("#data").html("Data sent to the server : " + $.param(data)); _VIEWSTATE=%2FwEPDwULLTE4ODM1ODM4NDFkZOFEQfA7cHuTisEwOQmIaj1nYR23&_EVENTVALIDATION=%2FwEWDwLuksaHBgLniKOABAKV8o75BgLlosbxAgKUjpHvCALf9YLVCgLCtfnhAQKyqcC9BQL357nNAQLW9%2FeuDQKvpuq2CALyveCRDwKgoPWXDAKhwImNCwKiwImNC1%2Fq%2BmUXqcSuJ0z0F%2FQXKM3pH070&firstname=Nisar&surname=Khan&day_fi=12&month_fi=12&year_fi=1234&lastFour_fi=777&countryPrefix_fi=1&areaCode_fi=555-555&phoneNumber_fi=5555&email_fi=nisardotnet%40gmail.com&username=nisarkhan&password=123456&retypePassword=123456 DataProcessor.aspx.cs: public partial class DataProcessor : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) ProcessAjaxRequest(); } private void ProcessAjaxRequest() { if (Request.ContentType.Contains("json") && Request.QueryString["Save"] != null) SaveMyData(); } private void SaveMyData() { //data passed in as JSON format System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream); string line = ""; line = sr.ReadToEnd(); //This is all you need to parse JSON string into an JObject. //Require namespace Newtonsoft.Json.Linq; JObject jo = JObject.Parse(line); Console.WriteLine((string)jo["RecordID"]); Console.WriteLine(Server.UrlDecode((string)jo["ItemName"])); //use Server.UrlDecode to reverse the text that was escaped before it was passed in to its original state Response.Write((string)jo["CategoryID"]); //this send to responseText of .ajax(options).responseText } } the above code is not working and i need a way to capture the values before i insert into db. any help? Thanks.

    Read the article

  • Applying pagination options to a one-to-many list in Grails

    - by UltraVi01
    I have a User class that hasMany = [friends:User] Now I am trying to display the friends list - ${user.friends} However, I'd like to be able to apply parameters like I can with, for example, User.findAllBy(user, [max:10, sort: 'dateCreated', order: 'desc"]) Can someone kindly tell me how to do this on a one-to-many in Grails / Groovy ?

    Read the article

  • Qt - reading from a text file

    - by user289175
    Hello world, I have a table view with three columns; I have just passed to write into text file using this code QFile file("/home/hamad/lesson11.txt"); if(!file.open(QIODevice::WriteOnly)) { QMessageBox::information(0,"error",file.errorString()); } QString dd; for(int row=0; row < model->rowCount(); row++) { dd = model->item(row,0)->text() + "," + model->item(row,1)->text() + "," + model->item(row,2)->text(); QTextStream out(&file); out << dd << endl; } But I'm not succeed to read the same file again, I tried this code but I don't know where is the problem in it QFile file("/home/hamad/lesson11.txt"); QTextStream in(&file); QString line = in.readLine(); while(!in.atEnd()) { QStringList fields = line.split(","); model->appendRow(fields); } Any help please ?

    Read the article

  • width of a frustum at a given distance from the near plane

    - by structolite
    I'm using CML to manage the 3D math in an OpenGL-based interface project I'm making for work. I need to know the width of the viewing frustum at a given distance from the eye point, which is kept as a part of a 4x4 matrix that represents the camera. My goal is to position gui objects along the apparent edge of the viewport, but at some distance into the screen from the near clipping plane. CML has a function to extract the planes of the frustum, giving them back in Ax + By + Cz + D = 0 form. This frustum is perpendicular to the camera, which isn't necessarily aligned with the z axis of the perspective projection. I'd like to extract x and z coordinates so as to pin graphical elements to the sides of the screen at different distances from the camera. What is the best way to go about doing it? Thanks!

    Read the article

  • about sending messages among bg.html, popup.html and contentscript.js

    - by T_t
    Hi!:) In my extension, when a button named "mybutton1" in the popup.html is clicked, it sends a message "getvar1" to the contentscript.js, then the contentscript.js sends a message "i want var1" to the background.html to get an object named "var1".If the button named "mybutton2" is clicked, the contentscript.js gets the "var2" object. How should i do under this condition? What's more, i am a little confused about the chrome.extension.onRequest.addListener method and chrome.extension.sendRequest method.Could someone tell me the mechanism of the two methods? Thanks!

    Read the article

  • Custom RoleProvider: Can't insert record in UsersInRole Table

    - by mahr.g.mohyuddin
    Hi, I have implemented a LINQ to SQL based RoleProvider, when I assign role to a user following exception is thrown while AddUsersToRoles method is called. I have defined a composite primary key userid & roleId on this table, it still throwing this exception: Can't perform Create, Update or Delete operations on 'Table(UsersInRole)' because it has no primary key. My LinQ to SQL implementation of AddUsersToRoles method is as follows. It breaks at db.UsersInRoles.InsertOnSubmit(userInRole); using (RussarmsDataContext db = new RussarmsDataContext()) { List<UsersInRole> usersInRole = new List<UsersInRole>(); foreach (string username in usernames) { foreach (string rolename in rolenames) { UsersInRole userInRole = new UsersInRole(); object userId = ProvidersUtility.GetUserIdByUserName(username,applicationName); object roleId = ProvidersUtility.GetRoleIdByRoleName(rolename,applicationName); if (userId != null && roleId != null) { userInRole.UserId = (Guid)userId; userInRole.RoleId = (Guid)roleId; db.UsersInRoles.InsertOnSubmit(userInRole); } } } try { // db.UsersInRoles.InsertAllOnSubmit(usersInRole); db.SubmitChanges(); } catch (ChangeConflictException) { db.ChangeConflicts.ResolveAll(RefreshMode.OverwriteCurrentValues); db.SubmitChanges(); } } Any help will be appreciated. Thanks.

    Read the article

  • How to get Resharper to show a Refactoring that it already has.

    - by AngryHacker
    Whenever Resharper encounters code like this: (treeListNode.Tag as GridLine).AdvertiserSeparation = 5; it presents you with a possible fix (since treeListNode.Tag as GridLine might be null). It says: 'Replace with Direct Cast', which turns the code into the following: ((GridLine) treeListNode.Tag).AdvertiserSeparation = 5; This is great. However, when it encounters code like this: GridLine line = treeListNode.Tag as GridLine; line.AdvertiserSeparation = 5; Resharper simply displays a warning 'Possible System.NullReferenceException', but does not offer me to 'Replace with Direct Cast'. Is there a way to make Resharper offer me this refactoring, since it already has it?

    Read the article

  • "Unverifiable code failed policy check" for a closed source assembly

    - by Jason
    I'm attempting to dynamically load some (purchased) assemblies from resource streams in a C# program during an MSI installation routine, but I'm getting "Unverifiable code failed policy check". I read some tips online about compiling the embedded assembly with /clr:safe, but I don't have that option. Is there a way to work around this policy check? Thanks.

    Read the article

  • UIScrollView subviews not showing at first

    - by igul222
    I created a custom UIScrollView subclass that works a like a UITableView, keeping a collection of subviews and re-using them whenever the user scrolls. It's implemented like this: -(void)layoutSubviews { for(UIView *subview in [self subviews]) [subview removeFromSuperview]; // then re-add subviews after changing the frame and some attributes } This works fine with simple UIViews, but when I try to do it with a UIView that has a UILabel subview, the "base" view appears fine, but the UILabel doesn't show up at all. I can get the UILabel to show up by scrolling the entire UIView off screen and then bringing it back on. What could be causing this? So far, I've tried calling [myUIView setNeedsLayout], [myUIView setNeedsDisplay], and [myUIView layoutIfNeeded] from various places. None of them worked, and the last one crashed my app. I've also done the same thing to myUIScrollViewSubclass, with similar results.

    Read the article

  • operator<< cannot output std::endl -- Fix?

    - by dehmann
    The following code gives an error when it's supposed to output just std::endl: #include <iostream> #include <sstream> struct MyStream { std::ostream* out_; MyStream(std::ostream* out) : out_(out) {} std::ostream& operator<<(const std::string& s) { (*out_) << s; return *out_; } }; template<class OutputStream> struct Foo { OutputStream* out_; Foo(OutputStream* out) : out_(out) {} void test() { (*out_) << "OK" << std::endl; (*out_) << std::endl; // ERROR } }; int main(int argc, char** argv){ MyStream out(&std::cout); Foo<MyStream> foo(&out); foo.test(); return EXIT_SUCCESS; } The error is: stream1.cpp:19: error: no match for 'operator<<' in '*((Foo<MyStream>*)this)->Foo<MyStream>::out_ << std::endl' stream1.cpp:7: note: candidates are: std::ostream& MyStream::operator<<(const std::string&) So it can output a string (see line above the error), but not just the std::endl, presumably because std::endl is not a string, but the operator<< definition asks for a string. Templating the operator<< didn't help: template<class T> std::ostream& operator<<(const T& s) { ... } How can I make the code work? Thanks!

    Read the article

  • How to use objects as modules/functors in Scala?

    - by Jeff
    Hi. I want to use object instances as modules/functors, more or less as shown below: abstract class Lattice[E] extends Set[E] { val minimum: E val maximum: E def meet(x: E, y: E): E def join(x: E, y: E): E def neg(x: E): E } class Calculus[E](val lat: Lattice[E]) { abstract class Expr case class Var(name: String) extends Expr {...} case class Val(value: E) extends Expr {...} case class Neg(e1: Expr) extends Expr {...} case class Cnj(e1: Expr, e2: Expr) extends Expr {...} case class Dsj(e1: Expr, e2: Expr) extends Expr {...} } So that I can create a different calculus instance for each lattice (the operations I will perform need the information of which are the maximum and minimum values of the lattice). I want to be able to mix expressions of the same calculus but not be allowed to mix expressions of different ones. So far, so good. I can create my calculus instances, but problem is that I can not write functions in other classes that manipulate them. For example, I am trying to create a parser to read expressions from a file and return them; I also was trying to write an random expression generator to use in my tests with ScalaCheck. Turns out that every time a function generates an Expr object I can't use it outside the function. Even if I create the Calculus instance and pass it as an argument to the function that will in turn generate the Expr objects, the return of the function is not recognized as being of the same type of the objects created outside the function. Maybe my english is not clear enough, let me try a toy example of what I would like to do (not the real ScalaCheck generator, but close enough). def genRndExpr[E](c: Calculus[E], level: Int): Calculus[E]#Expr = { if (level > MAX_LEVEL) { val select = util.Random.nextInt(2) select match { case 0 => genRndVar(c) case 1 => genRndVal(c) } } else { val select = util.Random.nextInt(3) select match { case 0 => new c.Neg(genRndExpr(c, level+1)) case 1 => new c.Dsj(genRndExpr(c, level+1), genRndExpr(c, level+1)) case 2 => new c.Cnj(genRndExpr(c, level+1), genRndExpr(c, level+1)) } } } Now, if I try to compile the above code I get lots of error: type mismatch; found : plg.mvfml.Calculus[E]#Expr required: c.Expr case 0 = new c.Neg(genRndExpr(c, level+1)) And the same happens if I try to do something like: val boolCalc = new Calculus(Bool) val e1: boolCalc.Expr = genRndExpr(boolCalc) Please note that the generator itself is not of concern, but I will need to do similar things (i.e. create and manipulate calculus instance expressions) a lot on the rest of the system. Am I doing something wrong? Is it possible to do what I want to do? Help on this matter is highly needed and appreciated. Thanks a lot in advance. After receiving an answer from Apocalisp and trying it. Thanks a lot for the answer, but there are still some issues. The proposed solution was to change the signature of the function to: def genRndExpr[E, C <: Calculus[E]](c: C, level: Int): C#Expr I changed the signature for all the functions involved: getRndExpr, getRndVal and getRndVar. And I got the same error message everywhere I call these functions and got the following error message: error: inferred type arguments [Nothing,C] do not conform to method genRndVar's type parameter bounds [E,C genRndVar(c) Since the compiler seemed to be unable to figure out the right types I changed all function call to be like below: case 0 => new c.Neg(genRndExpr[E,C](c, level+1)) After this, on the first 2 function calls (genRndVal and genRndVar) there were no compiling error, but on the following 3 calls (recursive calls to genRndExpr), where the return of the function is used to build a new Expr object I got the following error: error: type mismatch; found : C#Expr required: c.Expr case 0 = new c.Neg(genRndExpr[E,C](c, level+1)) So, again, I'm stuck. Any help will be appreciated.

    Read the article

  • Video Editing Software

    - by stanigator
    I would like to add some text labels certain segments of a video. I have had a lot of trouble using Windows Movie Maker for video editing. I know a friend of mine who uses adobe premiere and adobe after effects, but I don't know what's the easiest software to use to achieve my goal. What are your thoughts?

    Read the article

  • Scheme Infix to Postfix

    - by Cody
    Let me establish that this is part of a class assignment, so I'm definitely not looking for a complete code answer. Essentially we need to write a converter in Scheme that takes a list representing a mathematical equation in infix format and then output a list with the equation in postfix format. We've been provided with the algorithm to do so, simple enough. The issue is that there is a restriction against using any of the available imperative language features. I can't figure out how to do this in a purely functional manner. This is our fist introduction to functional programming in my program. I know I'm going to be using recursion to iterate over the list of items in the infix expression like such. (define (itp ifExpr) ( ; do some processing using cond statement (itp (cdr ifExpr)) )) I have all of the processing implemented (at least as best I can without knowing how to do the rest) but the algorithm I'm using to implement this requires that operators be pushed onto a stack and used later. My question is how do I implement a stack in this function that is available to all of the recursive calls as well?

    Read the article

  • iPhone first responders

    - by William Jockusch
    I am confused about the iPhone responder chain. Specifically, in the iPhone event handling guide http://developer.apple.com/iPhone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/EventHandling/EventHandling.html, we have the following: The first responder is the responder object in an application (usually a UIView object) that is designated to be the first recipient of events other than touch events. But UIView is a subclass of UIResponder. And the UIResponder class reference says this: - (BOOL)canBecomeFirstResponder Return Value YES if the receiver can become the first responder, NO otherwise. Discussion Returns NO by default. If a responder object returns YES from this method, it becomes the first responder and can receive touch events and action messages. Subclasses must override this method to be able to become first responder. I am confused by the apparent contradiction. Can anyone clear it up for me? For what it's worth, I did set up a simple view-based application, and call canBecomeFirstResponder and isFirstResponder on its view. Both returned NO.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >