Daily Archives

Articles indexed Sunday January 16 2011

Page 16/29 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • How to run an exe using c prog

    - by Ujjwal
    Hi All, I am new to this forum. I am in need of a program in C that runs an exe file in Windows. While googling I found the code below : 1. Code: #include<stdlib.h> #include<stdio.h> int main() { (void)system("C:\\Windows\\notepad.exe"); return 0; } The above code compiles successfully in Borland Turbo C. But it fails to run Notepad. 2 Code: #include<stdlib.h> #include<stdio.h> void main() { int result ; result=system("C:\\Windows\\notepad.exe"); printf("%d",result); } The above code on running gives -1 as output. Why am I getting -1. My OS Windows XP Borland Turbo C Compiler Please help.

    Read the article

  • Can I use a UINavigationController as the detail view of a UISplitViewController?

    - by B Sweigard
    I'm running into a problem with an iPad app where I would like to have UINavigationControllers in both of the views within a UISplitView. I've looked through other similar questions here, but most link to a tutorial online that doesn't completely solve the problem. Here's a 2-minute walkthrough to re-create the problem I'm having: Create a New Project in XCode, starting from the Split View-based Application template. Add the following NSLog statement as the first line within the DetailViewController's willHideViewController method: NSLog(@"toolbar: %@", toolbar); If you run the application now, the log will show that the DetailViewController's toolbar is alive and well. Now... Open MainWindow.xib and expand the SplitViewController. Drag a Navigation Controller from the library on top of the DetailViewController. Expand the new Navigation Controller and change the class of the UIViewController within to a DetailViewController. Ctrl-drag from the SplitViewController to the DetailViewController and assign it as the delegate. Save MainWindow.xib and run the app again. At this point, the detail view has a navigation bar and an empty toolbar. If you view the logs, you should find that the toolbar is null. Why is this? Am I missing some sort of connection in Interface Builder? Is the navigation bar the problem for some reason? Unlike the tutorial at http://www.cimgf.com/2010/05/24/fixing-the-uisplitviewcontroller-template/, I would like to keep both the navigation bar and the toolbar (preferably with the toolbar at the top when in portrait and not visible when in landscape), so that I still have a functional "Back" button when the iPad is in portrait orientation. Does anyone have any suggestions for fixing this problem? An example project with this sort of set-up would be ideal.

    Read the article

  • Various way to stop a thread - which is the correct way

    - by Yan Cheng CHEOK
    I had came across different suggestion of stopping a thread. May I know, which is the correct way? Or it depends? Using Thread Variable http://download.oracle.com/javase/1.4.2/docs/guide/misc/threadPrimitiveDeprecation.html private volatile Thread blinker; public void stop() { blinker = null; } public void run() { Thread thisThread = Thread.currentThread(); while (blinker == thisThread) { try { thisThread.sleep(interval); } catch (InterruptedException e){ } repaint(); } } Using boolean flag private volatile boolean flag; public void stop() { flag = false; } public void run() { while (flag) { try { thisThread.sleep(interval); } catch (InterruptedException e){ } repaint(); } } Using Thread Variable together with interrupt private volatile Thread blinker; public void stop() { blinker.interrupt(); blinker = null; } public void run() { Thread thisThread = Thread.currentThread(); while (!thisThread.isInterrupted() && blinker == thisThread) { try { thisThread.sleep(interval); } catch (InterruptedException e){ } repaint(); } }

    Read the article

  • PHP Curl progress bar (callback returning percentage)

    - by WarDoGG
    I have implemented the curl progress bar using curl_setopt($curl, CURLOPT_PROGRESSFUNCTION, 'callback'); curl_setopt($curl, CURLOPT_BUFFERSIZE,64000); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); and a callback function. problem is, the script is outputting the percentage on my html everytime like this : 0 0.1 0.2 0.2 0.3 0.4 .. .. .. 1 1.1 How do i combine this with CSS to show a changing progress bar ?

    Read the article

  • Skip sanitization for videos in html5lib

    - by pug
    I am using a wmd-editor in django, much like this one in which I am typing. I would like to allow the users to embed videos in it. For that I am using the Markdown video extension here. The problem is that I am also sanitizing user input using html5lib sanitization and it doesn't allow object tags which are required to embed the videos. One solution could be to check the input for urls of well-known video sites and skip the sanitization in those cases. Is there a better solution?

    Read the article

  • jQuery: hover (mouseleave event fired when mouse is over child)

    - by CronosS
    Hi, I want to create a zoom effect on some thumbs. Here is my javascript simplified code : parent.hover( function(){ parent.stop().animate({/* css */}, inputZoomDuration, "linear"); wrapper.stop().animate({/* css */}, inputZoomDuration, "linear"); child.stop().animate({/* css */}, inputZoomDuration, "linear"); }, function(){ alert("leave"); child.stop().animate({/* css */}, 140, "linear"); wrapper.stop().animate({/* css */}, 140, "linear"); parent.stop().animate({/* css */}, 140, "linear"); } ); and the html is like : <div parent> <div wrapper> <div child> </div> </div> </div> I increase the size of all my divs when I over the "parent". But a soon as I over (or leave, btw) one of the child, the alert appears. Without the alert, the result is a very bugy animation. Is there any way to prevent the mouseleave event to be fired when a child is overed? Best regards, thanks.

    Read the article

  • complex regular expression task

    - by Don Don
    Hi, What regular expressions do I need to extract section title(s) in a text file? So, in the following sample text, I'd like to extract "Communication and Leadership" "1.Self-Knowledge" "2. Humility" "(3) Clear Thinking". Many thanks. Communication and Leadership True leaders understand that, rather than forcing their followers into a preconceived mold, their job is to motivate and organize followers to collectively accomplish goals that are in everyone's interests. The ability to communicate this to co-workers and followers is critical to the effectiveness of leadership. 1.Self-Knowledge Superior leaders are able to devote their skills and energies to leadership of a group because they have worked through personal issues to the point where they know themselves thoroughly. A high level of self-knowledge is a prerequisite to effective communication skills, because the things that you communicate as a leader are coming from within. 2. Humility This subversion of personal preference requires a certain level of humility. Although popular definitions of leaders do not always see them as humble, the most effective leaders actually are. This humility may not be expressed in self-effacement, but in a total commitment to the goals of the organization. Humility requires an understanding of one's own relative unimportance in comparison to larger systems. (3) Clear Thinking Clarity of thinking translates into clarity of communication. A leader whose goals or personal analysis is muddled will tend to deliver unclear or ambiguous directions to followers, leading to confusion and dissatisfaction. A leader with a clear mind who is not ambivalent about her purposes will communicate what needs to be done in a s traightforward and unmistakable manner.

    Read the article

  • Facebook Graph API shows different results in me/home

    - by elekatonio
    Hi, When I do a GET with my browser (already logged-in at Facebook): https://graph.facebook.com/me/home?access_token={token} the results are different than doing the same via a FB app using Facebook C# SDK. Specifically, what the API is not returning are feeds posted by other applications. Why can be this happening? Can't an application retrieve updates from other applications even if it has the read_stream permission? I even requested for additional permissions: read_stream,user_activities,friends_activities,friends_likes,user_likes,read_requests but nothing has changed. What I need is to get ALL and the same stories an user would see at his FB news feed.

    Read the article

  • jquery load a specific #Div content from multiple html files

    - by Vikram
    Hello friends I am trying to make a Content Slider for my site. I have multiple HTML files and the structure of these files is like this: <div id="title"><h2>Title of the Slide</h2></div> <div id="image"><a href="http://mylink.com"><img src="image.jpg" width="600" height="300" alt="image"</a></div> <div id="content">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</div> I have been trying to use the following script get content (but no success): <?php function render($position="") { ob_start(); foreach(glob("/slides/*.html") as $fileName) { $fname = basename( $fileName ); $curArr = file($fname); $slides[$fname ]['title'] = $curArr[0]; $slides[$fname ]['image'] = $curArr[1]; $slides[$fname ]['content'] = $curArr[2]; foreach($slides as $key => $value){ ?> <div id="slide-title"> <?php echo $value['title'] ?> </div> <div id="slide-content"> <?php echo $value['image'] ?> </div> <div id="slide-image"> <?php echo $value['content'] ?> </div> <?php }} ?> <?php return ob_get_clean(); } But then I came to know about a jQuery function.... (again no success) jQuery.noConflict(); (function($){ $(document).ready(function () { $('#slide-title').load('slides/slide1.html #title'); $('#slide-content').load('slides/slide1.html #content'); $('#slide-image').load('slides/slide1.html #image'); }); })(jQuery); Now My questions are..... Am I using the right syntax. How do I get the content from multiple files using jQuery. Please Note : My knowledge on Programming is almost '0'. I have just started learning it.

    Read the article

  • highlight scrolling text on iphone(about lyrics show )

    - by ????
    hi all, i'm in troubled show lyrics .i use uitextview show lyrics code snips IBOutlet UILabel *lrcshow; IBOutlet UITextView *showlrc; self.lrcshow.text = [lrcDictss objectForKey:[NSString stringWithFormat:@"%d",(int)self.player.currentTime]]; if (self.lrcshow.text!=nil) { NSRange selection = [self.showlrc.text rangeOfString:self.lrcshow.text]; if( selection.location != NSNotFound ) { showlrc.selectedRange = selection; } } lyrics line by line scrolling show,the problem is now playing(selectedRange) lyric is not highlight, i want this line highlight how can i code ? any suggestion?or use calayer ?cgcontext quartz core instead it? how can i code ? ps.use uitextview show is rigidly ,not smooth! lr style show pic url this is my app style: http://www.flickr.com/photos/53054715@N05/5359722887/ this is good style: flickr.com/photos/53054715@N05/5360345226/

    Read the article

  • Need help with Django tutorial

    - by Nai
    I'm doing the Django tutorial here: http://docs.djangoproject.com/en/1.2/intro/tutorial03/ My TEMPLATE_DIRS in the settings.py looks like this: TEMPLATE_DIRS = ( "/webapp2/templates/" "/webapp2/templates/polls" # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) My urls.py looks like this: from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^polls/$', 'polls.views.index'), (r'^polls/(?P<poll_id>\d+)/$', 'polls.views.detail'), (r'^polls/(?P<poll_id>\d+)/results/$', 'polls.views.results'), (r'^polls/(?P<poll_id>\d+)/vote/$', 'polls.views.vote'), (r'^admin/', include(admin.site.urls)), ) My views.py looks like this: from django.template import Context, loader from polls.models import Poll from django.http import HttpResponse def index(request): latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5] t = loader.get_template('c:/webapp2/templates/polls/index.html') c = Context({ 'latest_poll_list': latest_poll_list, }) return HttpResponse(t.render(c)) I think I am getting the path of my template wrong because when I simplify the views.py code to something like this, I am able to load the page. from django.http import HttpResponse def index(request): return HttpResponse("Hello, world. You're at the poll index.") My index template file is located at C:/webapp2/templates/polls/index.html. What am I doing wrong?

    Read the article

  • PHP and MySQL on IIS7: can't find php_mcrypt.dll in php.ini

    - by user46250
    I have installed PHP with Microsoft Web PI. Then I installed mysql. According to http://learn.iis.net/page.aspx/353/install-and-configure-mysql-for-php-applications-on-iis-7/ I have to Uncomment the following lines by removing the semicolon: extension=php_mysqli.dll extension=php_mbstring.dll extension=php_mcrypt.dll But there is no extension=php_mcrypt.dll in php.ini installed by web PI so should I add it by hand then where ? and where should I check that php_mcrypt.dll exists ? Seems nobody knows, should better ask on Microsoft forum ?

    Read the article

  • SQL ERROR: Verify that the instance name is correct and that SQL Server is configured to allow remote connections?

    - by scepak
    I am getting following error while connecting to my local Sql Express. An error has occurred. Details of the exception: A network-related or instance-specific error occurred while establishing a conne ction to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Serve r/Instance Specified) Unable to connect to SQL Server database. I am able to connect to Sql Server using Management Studio.

    Read the article

  • Broken cups installation on a ubuntu server 64

    - by user67046
    Hi, I am having trouble with an cups installation. It seems to be in a broken state. When i try to reinstall it it stalls, the same if i try to remove it completely. I am running the server version 64 bit of Ubuntu 10.10 with kernel Linux version 2.6.35-22-server. When i try to start the cups daemon with the following command sudo service cups start It just stays there and nothing happens. I have tried to remove it, to be able to reinstall it, with the following command sudo apt-get purge cups It finally stalls with the following message Removing cups ... After that nothing happens. The process tree for the apt-get command looks like this. 1404 1404 1404 ? 00:00:00 sshd 26495 26495 26495 ? 00:00:00 sshd 26581 26495 26495 ? 00:00:00 sshd 26582 26582 26582 pts/4 00:00:00 bash 27158 27158 26582 pts/4 00:00:00 apt-get 27172 27172 27172 pts/2 00:00:00 dpkg 27176 27172 27172 pts/2 00:00:00 cups.prerm 27178 27172 27172 pts/2 00:00:00 stop I have tried to leave the process running for a while to see if i get any error messages but without success. To get out of it I have to kill the processes. sudo dpkg --configure cups dpkg: error processing cups (--configure): package cups is already installed and configured Errors were encountered while processing: cups sudo dpkg --status cups Package: cups Status: purge ok installed Priority: optional Section: net Installed-Size: 8292 Maintainer: Ubuntu Developers <[email protected]> Architecture: amd64 Version: 1.4.4-6ubuntu2.3 Replaces: cupsddk-drivers (<< 1.4.0) Provides: cupsddk-drivers Depends: libavahi-client3 (>= 0.6.16), libavahi-common3 (>= 0.6.16), libc6 (>= 2.7), libcups2 (>= 1.4.4-3~), libcupscgi1 (>= 1.4.2), libcupsdriver1 (>= 1.4.0), libcupsimage2 (>= 1.4.0), libcupsmime1 (>= 1.4.0), libcupsppdc1 (>= 1.4.0), libdbus-1-3 (>= 1.0.2), libgcc1 (>= 1:4.1.1), libgnutls26 (>= 2.7.14-0), libgssapi-krb5-2 (>= 1.8+dfsg), libijs-0.35, libkrb5-3 (>= 1.6.dfsg.2), libldap-2.4-2 (>= 2.4.7), libpam0g (>= 0.99.7.1), libpaper1, libpoppler7, libslp1, libstdc++6 (>= 4.1.1), libusb-0.1-4 (>= 2:0.1.12), zlib1g (>= 1:1.1.4), debconf (>= 1.2.9) | debconf-2.0, upstart-job, poppler-utils (>= 0.12), procps, ghostscript, lsb-base (>= 3), cups-common (>= 1.4.4), cups-client (>= 1.4.4-6ubuntu2.3), ssl-cert (>= 1.0.11), adduser, bc, ttf-freefont, cups-ppdc Recommends: foomatic-filters (>= 4.0), cups-driver-gutenprint, ghostscript-cups Suggests: cups-bsd, foomatic-db-compressed-ppds | foomatic-db, hplip, xpdf-korean | xpdf-japanese | xpdf-chinese-traditional | xpdf-chinese-simplified, cups-pdf, smbclient (>= 3.0.9), udev Breaks: foomatic-filters (<< 4.0) Conflicts: cupsddk-drivers (<< 1.4.0) Conffiles: /etc/fonts/conf.d/99pdftoopvp.conf a5221cfad70a981c80864229ef56586d /etc/logrotate.d/cups 5bb41fa9900f0d1c565954405a2bd7c4 /etc/default/cups 2b436fbb1a32b82b6aba45a76a1d7e40 /etc/pam.d/cups ff2488324854f7b1e892bb0df062d5f0 /etc/init/cups.conf 1a3cd022e8474e3d2b44640f33ce68e3 /etc/ufw/applications.d/cups 29e98a6d850da251e180c3d68dec2bd3 /etc/apparmor.d/usr.sbin.cupsd 60c4b26bfd5c033baa3dd48a3b2e9911 /etc/cups/cupsd.conf e2c7ec15835ea0939e5e86f7c6efcc03 /etc/cups/snmp.conf 2326a8af1e112676d55245bc5eb459ca /etc/cups/cupsd.conf.default a68d54d76021e857dd1d64edf57d36c5 Description: Common UNIX Printing System(tm) - server The Common UNIX Printing System (or CUPS(tm)) is a printing system and general replacement for lpd and the like. It supports the Internet Printing Protocol (IPP), and has its own filtering driver model for handling various document types. . This package provides the CUPS scheduler/daemon and related files. Original-Maintainer: Debian CUPS Maintainers <[email protected]> Would be greatful if someone could provide some help on how to solve this issue.

    Read the article

  • consulting a network admin for rails and php applications

    - by Karo Devos
    Hi I'm a web developer who writes most of the time rails applications. Next month I'm going to switch from my current VPS to linode. I'm wondering how much it would cost to properly set (or teach me how to do it) everything to get my app up and running. My requirements are probably: nginx/apache, REE/ruby, passenger, full blown php environment, system wide RVM, search engine such a sphinx, being able to perform cronjobs. I have some knowledge of unix and I was able to install everything I needed on my development system. However I had quite a few issues setting up everything on my production server.

    Read the article

  • Batch-Remove Specific Text from Photo Descriptions

    - by David
    I've recently upgraded to iPhoto '11 (couldn't resist the pricing on the new app store) and as I'm adding more meta-data to my library and generally organizing things (places, faces, etc... I hadn't upgraded since '08) I've noticed something odd in my photos. Every photo in my library has a description (though many are short), but it would appear that somehow the description of one of the photos has been appended to many. I don't know if maybe I accidentally screwed up a batch change at some point in the past, or if the library upgrade somehow messed up, or what else may have happened. But what I need to do is fix these somehow. Now, manually editing is something of a daunting task. Within a library of 21,248 photos, 18,858 of them have this additional text. The one thing I do have going for me is that it's a specific string. If there's a way to "remove this string from everywhere in the library without removing the rest of any given description" then that would be perfect. Is there anything I can do like this? Maybe even manually editing a library file in a text editor? (Would that break anything else in iPhoto if its library was edited outside of the application, even while it's not running?) Does anybody have any ideas?

    Read the article

  • Problem starting X in unbuntu 10.10

    - by xain
    Hi, I recently installed ubuntu 10.10 on my old toshiba a100 (where I've been running XP with no problems for ages). The installation went fine, I can log in with my user account, but after that the screen has only the wallpaper (and the mouse is enabled). Any hints on how to troubleshoot it ? These are the Xorg and the messages log files. Thanks When booted in safe graphics mode it worked just fine. Is there a way to set that configuration as the default so I don't have to go through those menus every time I boot ?

    Read the article

  • JDK 7 Feature Complete Milestone Reached

    - by Henrik Ståhl
    The JDK 7 project has reached Feature Complete (FC). This means that development and QA have finished all planned feature and test development work in the release and are moving the focus to testing and bug fixing on all supported JDK 7 platforms. This is a major step towards JDK 7 General Availability (GA) and implies that we are tracking close to the plan published on openjdk.java.net. (The original plan was FC on 12/16. We hit this less than a week late, but verifying that everything was done in time took a couple of weeks due to the intervening holidays.) The definition of the FC milestone allows for exceptions to be integrated later. There are very few such exceptions in the project, the most prominent being updated JAXP/JAXB/JAX-WS and integration of the enhanced JMX agent from JRockit. Our project management does not expect the exceptions to have any negative impact on the release plan. The project may still be delayed if the Expert Groups for the JSRs included in Java SE 7 (203, 292, 334, 336) decide to introduce changes which cannot be accomodated within the existing schedule. Apart from that caveat, Oracle remains confident with the published plan.

    Read the article

  • Failure Driven Development

    - by DevSolo
    At our shop, we strive to be agile. And I'd say we are making great strides. That said, a few of us have spotted a pattern we have started calling "Failure Driven Development". Failure Driven Development can basically be desribed as an agile release/iteration cycle where the bugs/features are guided not by tasks and stories with acceptance criteria, but with defects entered in the defect tracking software. Our team has a great Project Manager who strives to get the acceptance criteria from the customer(s), but it's not always possible. From my development chair, this is due to the customer either not knowing exactly what they want or (and this is the kicker) two different "camps" at the customer's main office conflict with how a story should be implemented. Camp A will losely dictate that Feature X works like this, then Camp B will fail it due not functioning like that. Hence, the term "FDD". The process is driven by "failures". This leads to my question: Has anyone else encountered this and if so, any tips/suggestions for dealing with it? We have, of course, tried to get Camp A and B to agree prior, but everyone knows this isn't always the case. Thanks

    Read the article

  • How do you combat programming fatigue?

    - by Karpie
    Not fatigue as in 'I need sleep' but fatigue as in 'I just can't be bothered anymore' which usually sets in when you hit roadblocks in whatever project you're working on, generally the closer you get to deadlines. It can be in work projects or personal projects, but it's something I keep hitting more and more lately. I'll get an idea, get into working on it, have a few really good days and make progress, then just some niggly things will trip me up, I can't get things working the way you want, I've hit limitations in the framework, I've got problems I can't find documentation for, etc. and it just gets too frustrating. Or am I alone in this?

    Read the article

  • What would you choose for your project between .NET and Java at this point in time ?

    - by Basic
    You are just starting a new project and you have these two technologies to choose from, Java and .NET. The project you are working doesn't involve having features that would make it easy to choose between the two technologies (e.g. .NET has this that I need and Java does not) and both of them should work just fine for you (though you only need one of course). Take into account: Performance Tools available (even 3rd party tools) Cross platform compatibility Libraries (especially 3rd party libraries) Cost (Oracle seems to try and monetize Java) Development process (Easiest/Fastest) Also keep in mind that Linux is not your main platform but you would like to port your project to Linux/MacOs as well. You should definitely keep in mind the trouble that has been revolving around Oracle and the Java community and the limitations of Mono and Java as well. It would be much appreciated if people with experience in both can give an overview and their own subjective view about which they would choose and why.

    Read the article

  • GNOME session not starting after filesystem corruption

    - by user3215
    I'm running Ubuntu 9.10 desktop edition. Suddenly today /home became corrupted and I was prompted to run fsck manually. I ran fsck -y /home and rebooted the system. The system booted but I got no GUI interface (GNOME session) but a black screen with a user prompt instead. Any tricks here to start my system normally? Any help is greatly appreciated. EDIT:1 The error were similar to the the following(may be with some mistakes as I had to type it manually): machine1 login: root password: at login Sun Jan 16 15:30:46 IST 2011 on tty1 EXT3-fs error (devie sda1): ext3_lookup :deleted inode referenced aborting journal on device sda1 Remounting filesystem read-only root@machine1:~# startx ktemp: failed to create file via template `/tmp/serverauth.xxxxxxxxxxx: Read-only file /usr/bin/startx: line 157: cannot create temp file for here-document: Read-only file xauth: error in locking authority file /root/.Xauthority /usr/bin/startx: line 173: cannnot create temp file for here-document: Read-only file xauth: error in locking authority file /root/.Xauthority /usr/bin/startx: line 173: cannnot create temp file for here-document: Read-only file X: cannot stat /tmp/.x11-unix (No such file or directory), aborting giving up. xinit: No such file or directory (errno 2): unable to connect to xserver xinit: No such process (errno 3): Server error xauth: error in locking authority file /root/.Xauthority

    Read the article

  • NTFS partitions hidden under EXT4 file system / partion...want to recover files from NTFS

    - by user7534
    Hi all, I am new to ubuntu, but very impressed with the system. so one day i tried installing ubuntu 10.10 along with windows in dual boot first place it didnt get installed properly and during second attempt i could do it right but oh...i lost my windows 7 , here is my problem and what i have done till now. i have hdd installed with ubuntu same disk have windows partitions and i need to extract data from those ...very very important i tried to access the same from ubuntu ...can not access it, 3.reinstalled the windows 7 , hdd is not detected 4.during installation ubuntu gone , so reintalled scan in ubuntu says hdd is fine and DiskInternals linux reader actual show the NTFS partitions , recovery tool not able to get any data out. , please help i need data from these partitions...please I feel that i have put ext4 partition on ntfs filesystem...and now not able to access it

    Read the article

  • Schema to support dynamic properties

    - by Johan Fredrik Varen
    Hi people. I'm working on an editor that enables its users to create "object" definitions in real-time. A definition can contain zero or more properties. A property has a name a type. Once a definition is created, a user can create an object of that definition and set the property values of that object. So by the click of a mouse-button, the user should ie. be able to create a new definition called "Bicycle", and add the property "Size" of type "Numeric". Then another property called "Name" of type "Text", and then another property called "Price" of type "Numeric". Once that is done, the user should be able to create a couple of "Bicycle" objects and fill in the "Name" and "Price" property values of each bike. Now, I've seen this feature in several software products, so it must be a well-known concept. My problem started when I sat down and tried to come up with a DB schema to support this data structure, because I want the property values to be stored using the appropriate column types. Ie. a numeric property value is stored as, say, an INT in the database, and a textual property value is stored as VARCHAR. First, I need a table that will hold all my object definitions: Table obj_defs id | name | ---------------- 1 | "Bicycle" | 2 | "Book" | Then I need a table for holding what sort of properties each object definition should have: Table prop_defs id | obj_def_id | name | type | ------------------------------------ 1 | 1 | "Size" | ? | 2 | 1 | "Name" | ? | 3 | 1 | "Price" | ? | 4 | 2 | "Title" | ? | 5 | 2 | "Author" | ? | 6 | 2 | "ISBN" | ? | I would also need a table that holds each object: Table objects id | created | updated | ------------------------------ 1 | 2011-05-14 | 2011-06-15 | 2 | 2011-05-14 | 2011-06-15 | 3 | 2011-05-14 | 2011-06-15 | Finally, I need a table that will hold the actual property values of each object, and one solution is for this table to have one column for each possible value type, such as this: Table prop_vals id | prop_def_id | object_id | numeric | textual | boolean | ------------------------------------------------------------ 1 | 1 | 1 | 27 | | | 2 | 2 | 1 | | "Trek" | | 3 | 3 | 1 | 1249 | | | 4 | 1 | 2 | 26 | | | 5 | 2 | 2 | | "GT" | | 6 | 3 | 2 | 159 | | | 7 | 4 | 3 | | "It" | | 8 | 5 | 3 | | "King" | | 9 | 6 | 4 | 9 | | | If I implemented this schema, what would the "type" column of the prop_defs table hold? Integers that each map to a column name, varchars that simply hold the column name? Any other possibilities? Would a stored procedure help me out here in some way? And what would the SQL for fetching the "name" property of object 2 look like?

    Read the article

  • Reusing xalan transformer causing its extension functions break

    - by Leslie Norman
    I am using xalan 2.7.1 to validate my xml docs with xslt style sheet. It works fine for the first document and returns error message in case of error along with correct line and column number of xml source by making use of NodeInfo.lineNumber and NodeInfo.columnNumber extensions. The problem is when I try to reuse transformer to validate other xml docs, it successfully transforms the document but always returns lineNumber=columnNumber=-1 for all errors. Any idea? Here is my code: TransformerFactory tFactory = TransformerFactory.newInstance("org.apache.xalan.processor.TransformerFactoryImpl", null); tFactory.setAttribute(TransformerFactoryImpl.FEATURE_SOURCE_LOCATION, Boolean.TRUE); StreamSource xsltStreamSource = new StreamSource(new File("E:\\Temp\\Test\\myXslt.xsl")); Transformer transformer=null; try { transformer = tFactory.newTransformer(xsltStreamSource); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); File srcFolder = new File("E:\\Temp\\Test"); for (File file :srcFolder.listFiles()) { if (file.getName().endsWith("xml")) { transformer.transform(new StreamSource(file), new StreamResult(outStream)); transformer.reset(); } } System.out.println(outStream.toString()); } catch (TransformerException e) { e.printStackTrace(); } Edit: New code after implementing @rsp suggestions: package mycompany; import java.io.File; import javax.xml.transform.ErrorListener; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import org.apache.xalan.processor.TransformerFactoryImpl; public class XsltTransformer { public static void main(String[] args) { TransformerFactory tFactory = TransformerFactory.newInstance("org.apache.xalan.processor.TransformerFactoryImpl", null); tFactory.setAttribute(TransformerFactoryImpl.FEATURE_SOURCE_LOCATION, Boolean.TRUE); StreamSource xsltStreamSource = new StreamSource(new File("E:\\Temp\\Test\\myXslt.xsl")); try { Transformer transformer = tFactory.newTransformer(xsltStreamSource); File srcFolder = new File("E:\\Temp\\Test"); for (File file : srcFolder.listFiles()) { if (file.getName().endsWith("xml")) { Source source = new StreamSource(file); StreamResult result = new StreamResult(System.out); XsltTransformer xsltTransformer = new XsltTransformer(); ErrorListenerImpl errorHandler = xsltTransformer.new ErrorListenerImpl(); transformer.setErrorListener(errorHandler); transformer.transform(source, result); if (errorHandler.e != null) { System.out.println("Transformation Exception: " + errorHandler.e.getMessage()); } transformer.reset(); } } } catch (TransformerException e) { e.printStackTrace(); } } private class ErrorListenerImpl implements ErrorListener { public TransformerException e = null; public void error(TransformerException exception) { this.e = exception; } public void fatalError(TransformerException exception) { this.e = exception; } public void warning(TransformerException exception) { this.e = exception; } } }

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >