Thursday, April 21, 2011

How to create unit test for actualHeight in Silverlight 4?

How can I write a unit test to test the actualWidth property to a userControl in Silverligh 4?

I hoped that this method would pass, but it fails.

I am using the Silverlight ToolKit april 2010, and VS 2010.

<TestMethod()> _
Public Sub TestAcrtualWidth()
    Me.MyUserControl.Width = 100
    Me.MyUserControl.UpdateLayout()
    Assert.IsTrue(Me.MyUserControl.ActualWidth > 0)
End Sub
From stackoverflow
  • The problem was that I added MyUserControl to a new instance of a Canvas. If I instead used :

    Me.TestPanel.Children.add(Me.MyUserControl) 
    

    It worked!

How to output a rotated text in C# form application?

I'm writing a c# form application and i want to draw a scale and write some rotated values under it,is there any way to do this?

From stackoverflow
  • You will need to custom draw using the Graphics class. I assume you have some idea how to do that but if not that's a whole other question on its own involving OnPaint overrides and such. You can then use the Graphics class's RotateTransform method and draw the text.

    A Bob Powell article about text rotation.

    lajoo : thank you i think this works.

How To Insert Data into UniData using UniObjects for .NET

I am working on inserting data into our UniData server from .net.

I have successfully updated an existing record using UniQuery by using the Modify statement. And according to the documentation, I can insert new data this way also:

"UniQuery also provides the MODIFY command, which enables you to enter or modify data in a UniData file." - Using UniQuery: pg 1-2

I can't get manage to insert new records this way, though.

Any advice is appreciated.

From stackoverflow
  • In UniData, you cannot programmatically insert new records using UniQuery.

    At ECL you can manually create records using UNIENTRY if the appropriate dictionary items have been defined or you can use ED or AE to create them. All 3 of these require the user to manually enter data however.

    To create new records programmatically you should create a subroutine specifically used for the task and call this via UniObjects.NET

Facebook events api: Event member (FQL)

I am fetching the event members for facebook events. Till yesterday I was getting the proper counts of members of an event. But suddenly the counts have following issues:

  1. For lot of plans on every consecutive request, I am getting random number of members. Strange issue. Seems facebook servers are not synced properly or something similar.

  2. Earlier for the same query string (mentioned below), I was getting the correct counts. But now the count is much less. It seems that at least for a few events now they are sending only the members who are connected with our application (we are using facebook connect).

Example: for the following query currently I am getting "31" members. But on event page members count is much more.

FQL: FB.Facebook.apiClient.fql_query('SELECT uid, eid, rsvp_status FROM event_member WHERE eid=336671213618', function(result, error){alert(result.length);});

Event page: http://www.facebook.com/event.php?eid=109411842404023

Is there any recent change in facebook API or policies?

Thanks in advance.

From stackoverflow
  • Hi, i do have exactly the same problem, i read out the members of an event with the PHP "events_getMembers" function, which does not work anymore since a few days. I don't know when it started exactly, but now i can't get it running. Has anyone an idea if something has changed? All i found was this: http://wiki.developers.facebook.com/index.php/Talk:Events.getMembers

  • Yes there have been changes in this Facebook api due to a loop hole

    you can read about it here

    and the developer who exposed this loophole,

    I guess you will have to wait till this is sorted out by Facebook

Create new recordset by executing query on another recordset in Excel VBA

I am using Excel VBA 2003. Is it possible to create new recordset by executing query on another recordset ?

The query could look like "select * from recordset1 where "

Thanks,

From stackoverflow
  • You can't apply an SQL query to an existing recordset, you can use the (limited) .Filter method, iterate the rows and apply your own criteria or simply modify the query you used to open the 1st recordset to include the additional criteria.

drop down list binding

I have a table which has an Id and a name field. I usually bind the name to the dropdownlist but I was told that any dml should be on the Id so how can I use the name in the dropdownlist and at the same time still use the Id?

From stackoverflow
  • You can set the dropdownlist's Text field to the name and the Value field to the ID.

  • A very similar question was just answered a little while ago - here

  • Use DataTextField and DataValueField when binding:

    ddlList.DataSource = thesource;
    ddlList.DataTextField = "Name";
    ddlList.DataValueField = "ID";
    ddlList.DataBind()
    

    Where ID and Name are fields in your data source.

How to disable panning in Jquery flot when there is no further data ?

How to disable panning in Jquery flot when there is no further data ?

I am currently using plot.pan({ left: -100 }); and plot.pan({ left: 100 }); on left arrow click and right arrow click.

From stackoverflow
  • I've handeled panning limitation by setting the panRange option every time the plot's data values change. This way you don't need any other changes, the navigation plugin will do the rest.

    plot.getOptions().xaxis.panRange =
      [plot.getAxes().xaxis.datamin, plot.getAxes().xaxis.datamax];
    plot.getOptions().yaxis.panRange =
      [plot.getAxes().yaxis.datamin, plot.getAxes().yaxis.datamax];
    

EclipsePDT: how to add a Drupal project ?

hi,

how can I add an Eclipse project to my Eclipse PDT ?

I've a Drupal installation on my hard-disk (a subfolder of Eclipse workspace).

I've tried create new PHP project from eclipse, but it seems not to work.

I've successively tried to import the Drupal project but Eclipse only recognize the SimplyModern project from drupal themes folder, and not the main Drupal project.

thanks

From stackoverflow

YUI Uploader: automatically open browse dialog

I'm using the YUI Uploader component and want to automatically open the browse dialog on page load so the user can choose a file without first clicking the upload button. Is this possible?

The uploader component is a Flash movie so I don't think it's possible to trigger a click on the upload button using Javascript.

From stackoverflow

Ruby Search tree example confusion

I've been trying to take apart this app which creates a search tree based on keywords, but I'm afraid its a bit too complex for me. Would anyone mind explaining it?

The format is off, so here's a pastebin (is pastie.org down?) version of it.

Any help is appreciated.

From stackoverflow
  • It is an implementation of a trie.

    One difference between this implementation of a trie and the traditional implementation is that this implementation stores each string in the leaf nodes. Traditionally, the string is not stored directly but is rather deduced by the path taken through the trie to get to the leaf node.

ActiveMQ & Camel - How to create dependency in routing paths

I have a message routing to implement, which has routes that vary according to the message content. Some strands of the route are dependent on other.

If for example I have Data_A which has Task_A and Task_B to be performed on it. Whereas Data_B has only Task_B to be performed on it.

Here each Task has a queue served by consumers.

If Task_A should be performed only after Task_B if Task_B is requested on the data, how do I set-up such dependencies?

From stackoverflow
  • You can use several routes to branch out the workflow, like this

    from("queue:start").
      choice().xpath("//foo")).to("queue:taskB").
      otherwise().to("queue:taskA");
    
    from("queue:taskB").process(new DoTaskB()).to("queue:taskA");
    
    from("queue:taskA").process(new DoTaskA()).to("queue:done");
    

SSIS subquery different database

Alright SSIS got me. I have Database A source and Database B target. I am taking data form a table in A and transfering it to the same table in B. This is ok. However I have a createdbyUSer column in B which need sto be filled with ID of a user i have in user tab.le in B. So.. (fictional statement) INSERT INTO B.dbo.People (name, address, status, createdBy) Select a.name, a.address, a.status, (SELECT userid from b.dbo.user where username = 'myuser') FROM a.dbo.people

I am lost on how to do this in SSIS. I have too many components to pick from and not sure what path i should go down.

From stackoverflow
  • Simplest answer I can think of:

    OLEDB source from Database A

    Select a.name, a.address, a.status, a.myuser from a.dbo.people
    

    lookup from Database B

    Select b.userid,b.username from b.dbo.user
    

    on the columns tab in the lookup drag a line between username and myuser and click the checkbox next to userid. In the bottom part of that tab alias the userid column as createdBy in the column under the heading Output Alias

    OLEDB Destination to Database B

    select the People table to output to and map the columns from your dataflow to the outputs.

clean url's Drupal Gallery2

I'm trying to configure my Gallery2 integration in Drupal but i'm stuck at Step 4.

I have to put in two path's to drupal's .htaccess file.

The public path (This is the location of your Drupal .htaccess file relative to your webserver document root.) Filesystem path (This is the absolute directory path of your Drupal .htaccess file.)

but i have no idea what i have to put where?

My site sits in public_html/5.0, is this the public path?

From stackoverflow
  • From manual: "You may also decide to skip this step in case you dont want/need short URLs for your embedded gallery."

    Usually .htaccess for drupal is located where you unpack "drupal....tar.gz".

    Try an empty field or ".".

    For absolute directory path enter the document root (public_html or public_html/5.0) and execute "pwd" command. You'll receive something like /home/user1/public_html/5.0 This is your absolute path.

Why Is the Eclipse Plugin for Day Communique not working?

I am trying to get Eclipse working so that it builds my war to a local instance of Day Communique. I am using the plugin for eclipse from day: http://www.day.com/eclipse/

The .war file uses spring to start some processes. When I install the war file using the admin function in Day, the processes start. When I publish via eclipse, the processes do not start.

From stackoverflow
  • Not knowing a ton about Eclipse, Day offers a pre-packaged download of CRXDE with the new 5.3 release. If you have access to the Daycare site you can download it. Double click and it was working.

How do I control Google Search Results display properties?

I am putting the finishing touches on a customized Google Search for a site and need a little assistance tweaking the header on the results page.

I was able to manage the spacing of the results content with:

#results4   { width: 620px; padding: 20px;  }

However you will notice that the top row of information

Results 1 - 10 for search...

runs off the right side of the content area.

I tried using the following code, but it didn't help:

.t  td  { align:left; }

I also tried margin-right and padding but those didn't work either. what is the best way to get that content to move over into the content area?

thanks.

From stackoverflow
  • You can style the iframe that gets rendered on your page like this:

    #cse-search-results iframe { width: 620px; }
    

    Tested in Firefox and IE8, should be fine in other browsers too.

    fmz : Excellent. With a margin-left:20px it looks just right. Thank you.

What Date Source(DS) type and what Round Robin Archive(RRA) should I choose for displaying information about number of website registrations per period?

Hello,

I want have RRA with one measurement = 5min. period. The Y axis displaying total number (not average) of registrations during last 5 minutes. Also, I want graph with information about total number of registrations (Y axis) per day (X axis).

What DS type and RRA "algoritm" shoud I choose to implement this?

Thank you

From stackoverflow
  • You should look at the rrd-beginners guide. Hope this helps you.

File input javascript event, is there an event fire when someone click okay on the dialog box?

Hi,

When someone click on Browse for the input file below:

<input type="file" name="blah" />

A dialog box will appear. The user will then select a file and click 'Ok'. The dialog box will close. Is there an event fire because of that? I tried onfocus and onblur, it didnt work out.

The only way I can think of is to start a timer to check the value content when it is onfocus. Not that elegant. Any solution?

Cheers, Mickey

From stackoverflow
  • I think you can try to listen for an "onchange" event on your element.

    The only drawback with this is if the user selects the same file using "browse" twice, it wont fire as the contents didnt change but I dont know if that is a requirement in your case.

    Mickey Cheong : thanks for the answer. i solved it using a timer.

How do we prevent the bootstrapper to install prerequisites ?

Currently We are installing prequisties softwares using the bootstrapper. So i want to install the prerequisties without using the Bootstrapper ?. Whether it is possible ?

From stackoverflow

Combobox in jquery

Hi,

I've searched Internet quite a long time. But no combox box fit my need was found. Can anyone help me? Thanks in advance!

What I need is a dropdown list have a editable box, which act exactly as the combobox in Windows desktop applications. I have a list of value for the user, but I also what them to type if the options there doest fit their demand. And I'm using asp.net mvc, I want to make sure the control can be bind by default model binder. Thanks!

Best regards

From stackoverflow

Interpreting the Packets using sharppcap

Is it possible to interpret every coming packets using sharppcap?

From stackoverflow
  • Yep.

    SharpPcap uses Packet.Net, http://packetnet.sf.net, as it's packet dissector. Most common packet types are being processed. If you find one that isn't just let me know or open a feature request on the Packet.Net sourceforge tracker.

    Sharppcap and Packet.net are also designed to be as fast as possible. You should be able to capture and process at network data rates in excess of 3MB/s without dropped packets.

    Chris

    Author of SharpPcap and Packet.Net

  • You should also consider using Pcap.Net.

Getting "undefined method" error on form select in cucumber

I'm trying to visit a page with cucumber, with:

visit new_video_path

but I get this error:

undefined method `episode_id' for #<Video:0x22df8dc> (ActionView::TemplateError)
On line #19 of app/views/videos/_form.html.erb
...
19:     <%= select(:video, :episode_id, @episodes.collect {|e| [ e.title, e.id ] }, { :include_blank => true }) %>

It loads fine in the browser, and the form processes fine too.

What did I do wrong?

From stackoverflow
  • Ah, found the problem. I forgot to migrate the test database.

    rake db:migrate RAILS_ENV=test
    

virtual serial port on Arch linux

Hello,

I am using Arch linux and I need to create virtual serial port on it. I tried everything but it seems doesnt work. All I want is to connect that virtual port to another virtual port over TCP and after that to use it in my python application to communicate with python application to other side. Is that posible? Please help me.

Thanx

From stackoverflow
  • socat command is solution.

    First you need to install socat:

    pacman -S socat

    Just insert this in console, but first you should be login as root:

    socat PTY,link=/dev/ttyVirtualS0,echo=0 PTY,link=/dev/ttirtualS1,echo=0

    and now we have two virtual serial ports which are virtualy connected:

    /dev/ttyVirtualS0 <-------> /dev/ttirtualS1

Is there a way to make doxygen process undocumented C code automatically?

Usually it will ignore C files that are not documented, but I'd like to test the Callgraph feature for example, do you know a way around this without changing the C files?

From stackoverflow
  • Set the variable EXTRACT_ALL = YES in your Doxyfile.

    piotr : Also RECURSIVE was missing for me. Thanks

Sitecore - version created in other language when renaming

So I've got this Sitecore content item right, and it's got one version in one language "en-AU".

I have 3 potential languages in the system "en", "en-AU" and "en-NZ".

I rename the item, right, and Sitecore creates a new version in "en".

I delete the "en" version and rename again, same result.. a new version is created .. and again... and again .. see where I'm going with this? And again!

Why would it do that? I thought it was a problem with my pipeline processor, but I turned it off and it still happens!

Any ideas would be welcome.

From stackoverflow
  • What's the default language on your Sitecore user account? (Sitecore > Control Panel > Preferences)

    If you create a new item, what language is it created in?

WP Function to retrieve database connection

Is there a function or command that pulls the db connection info from the WP blog? I am writing a Plugin which would have to connect to the db to retrieve the info, wondering if there was one single command/function i could call which could connect. this would make the plugin portable and would work on any WP blog. is this possible?

From stackoverflow
  • See the Interfacing with the Database docs.

    You should just be able to use the global (curse you, Wordpress) variable $wpdb in your plugin functions, ie:

    global $wpdb;
    //do stuff
    

    Plugins also have a few methods for storing "options" in the database. I just found this article, it details things fairly well.

    HollerTrain : lol one time a global var is awesome
    zombat : Wordpress is all global variables unfortunately. It causes a lot of problems if you get into anything more than the simplest custom development :(

How to get configuration for WCF Service

I want to check whether the endpoint is defined in the configuration before I'll try to create it

System.ServiceModel.ClientBase<T> sourceClient = new System.ServiceModel.ClientBase<T>(EndpointName, new EndpointAddress(discoveryUri));

To check it I need get a configuration but how can I define whether I need to use WebConfigurationManager or ConfigurationManager. Is there any way to define where a WCF service is hosted?

From stackoverflow
  • You would have to need to have the information yourself - the WCF service itself doesn't know whether it'll be hosted in IIS or self-hosted. After all, it's just a ServiceHost instance being spun up some way.

    So I guess you'd have to have some setting that you can put into either web.config or app.config - something like:

    <add key="WCFHost" value="IIS" />
    

    or

    <add key="WCFHost" value="CustomApp" />
    

    and then evaluate that value and depending on what you get back, either open WebConfigurationManager or just ConfigurationManager.

    You might think you could check for the presence of HttpContext: if it's NULL, then you're running in a custom app, if it's not NULL, then it's the web scenario. But that doesn't work since you can host a WCF Service in IIS (thus you'd have a web.config to consult) but without the ASP.NET compatibility settings, in which case, HttpContext would be NULL even though you're running inside a web hosting scenario.

    One option would be to check this setting here:

    AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
    

    This will contain the full path to the current AppDomain's configuration file - if it's a web app, this will contain a path + web.config at the end.

    So if you check

    if(Path.GetFileName(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile) == "web.config")
    

    you can be pretty sure you're in a web app and you have a web.config to look at.

Java Micro Edition (J2ME) - Delete element from Record Store

Hi there,

I have a record store which holds a list of shopping items i am currently serialising the data like so

** (inside) ItemClass **            
ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
DataOutputStream dataOutputStream = new DataOutputStream(byteOutputStream);

dataOutputStream.writeUTF(getOwner());
dataOutputStream.writeUTF(getItemName());
dataOutputStream.writeInt(getQuantity());

dataOutputStream.close();

return byteOutputStream.toByteArray();

This byte array is then written to the record store like so (using for loop for each id)

for (int i = 1; i <= shoppingListStore.getNumRecords(); i++)
{
     byte[] itemRecord = shoppingListStore.getRecord(i);
     newItemObject.fromByteArray(itemRecord);
     userShoppingList.append(newItemObject.getItemName() + " " + newItemObject.getQuantity() + " " + newItemObject.getOwner(), null);
}

The problem comes from using the ID to treverse through the record store as this may change from deletion etc and as such i keep geting invalid id being thrown. I know i cannot use For each ItemObj : Recordstore so how do i treverse through the record store without having to worry about ids?

Thanks in advance

Andy

From stackoverflow
  • Call recordStore.enumerateRecords(null, null, false)

    Then use RecordEnumeration.hasNextElement() and RecordEnumeration.nextRecord()

    Garbit : thank you very much :)

nsIDOMNSHTMLElement IID change

Hi,

I am writing Firefox extension which would be compatible with Firefox's 3.0 to 3.6 versions.

I am using nsIDOMNSHTMLElement interface pointer for setting inner text of html element. I am getting nsIDOMNSHTMLElement interface pointer by calling QI on nsIDOMElement

But IID of nsIDOMNSHTMLElement changes from Firefox's 3.0 to 3.6 versions as gecko version changes.

How can I use nsIDOMNSHTMLElement interface?

How can I compile my extension so that It will work with above mentioned Firefox versions.

Thanks, Vaibhav.

From stackoverflow
  • https://developer.mozilla.org/en/Working_with_Multiple_Versions_of_Interfaces

    Basically, when building your component, prepare all versions of the changed interfaces (e.g. from 3.0 and 3.6) and their IIDs, then in code first try to QI by the newer IID (and use the newer class declaration for the interface), and if that fails, QI using the old IID (and use the old declaration of the interface).

    P.S. And I do recommend you to stop wasting your time and write in JS, whenever possible.

Start and End sectors of partitions?

How can i get the start and end sectors of the partitions of my harddisk via a bash script?

From stackoverflow
  • That's a start:

    sudo /sbin/fdisk  -l /dev/sdb | grep sdb[0-9]
    
    baltusaj : :) That gives block sizes.
    baltusaj : What's the interrelation between blocks and sectors?
    Omry : man fdisk : -u When listing partition tables, give sizes in sectors instead of cylinders.
  • Look at /sys/block/sda/sda1/start and /sys/block/sda/sda1/size.

    Replace sda and sda1 with your device and partition.

    baltusaj : Thanks. That's exactly what i was looking for.

DataGridViewButtonColumn change Button background Color

Hi , I construct a data grid by adding columns and rows.

DataGridViewButtonColumn dgtxc = new DataGridViewButtonColumn();
dgtxc.HeaderText = " stackoverflow";
dataGridView.Columns.Add(dgtxc);

After this i read the grid and if "something" then i want to change the background color of the Button in the grid . I do the following but only the line around the button changes.

if(dataGridView[r,c].value= "something")
{
     if(dataGridView[r,c].Style.BackColor = Color.Red;
}

How can i change the button color like this : button1.background = Color.Red

Thanks in advanced.

From stackoverflow
  • Maybe you can check out here

SOA principals - should a service call another service?

I'm new to SOA (and to Stack Overflow too...)

Some services and web applications we are developing must all log audit information. We are considering an audit service for this. Is there any SOA governing principal that should make me think twice about having one of the services call the audit service to log information? A service-to-service call in other words?

From stackoverflow
  • As a matter of fact, yes.

    A Service should call another Service when appropriate. There are parts of the WS-Standard that specify when and how this should occur:

    SOA Sepcifications - WS-* Specs

    If I remember correctly, you'll want to take a look at WS-Coordination

Rails - Associations - Automatically setting an association_id for a model which has 2 belongs_to

I have 3 models

class User < ...
  belongs_to :language
  has_many :posts
end

class Post < ...
  belongs_to :user
  belongs_to :language
end

class Language < ...
  has_many :users
  has_many :posts
end

Im going to be creating lots of posts via users and at the same time I have to also specify the language the post was written in, which is always the language associatd with the user i.e.

@user.posts.create(:text => "blah", :language_id => @user.language_id)

That's fine but the way I set the language doesn't sit well with me. The language will always be that of the users so is there a 'best-practice' way of doing this?

I know a little about callbacks and association extensions but not sure of any pitfalls.

From stackoverflow
  • I would just make a create_post function in the user model:

    def create_post(text)
      posts.create(:text => text, :language_id => language_id)
    end
    

    then just call it where ever you need.

  • Yes, there is a 'good practice' way involving callbacks.

    class Post
      before_validation_on_create :set_language
    
      protected
      def set_language
        self.language ||= self.user.language if self.user
      end
    
    end
    

    Then, you can

    @user.posts.create(:text => "blah")
    

    or

    post.create(:text => "fewf")
    
    adam : excellent thats brilliant.

App_Code in Web Client Software Factory, Is it a good idea.

Hi guys,

Just want to hear some opinion on adding App_Code in Web Client Software Factory (WCSF) project. The main purpose is to put reusable UI rendering codes which can be use by various pages.

For WCSF, I guess only controller can share across pages within a module which does not seems to be a good place for UI stuff.

Suggestions? :)

From stackoverflow
  • i dont know...

how to usewindows service in asp.net

How to use windows service in asp.net 3,5

From stackoverflow
  • Your question isn't very clear, but I guess you are asking how to communicate with a Windows service from ASP.NET? I asume you are writing both the Windows service and the ASP.NET application?

    I'd recommend Microsoft Message Queing (MSMQ). This will let you send a message from ASP.NET, and have the Windows service pick up messages from the queue.

  • Look into .Net Remoting.

    Your service can expose an object that can then be interacted with by other applications.

How to drop all stored procedures at once in SQL Server database?

Currently we use separate a drop statements for each stored procedure in the script file:

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MySP]')   
  AND type in (N'P', N'PC'))  
DROP PROCEDURE [dbo].[MySP] 

Is there a way to drop them all at once, or maybe in a loop?

From stackoverflow
  • Something like (Found at Delete All Procedures from a database using a Stored procedure in SQL Server).

    Just so by the way, this seems like a VERY dangerous thing to do, just a thought...

    declare @procName varchar(500)
    declare cur cursor 
    
    for select [name] from sys.objects where type = 'p'
    open cur
    fetch next from cur into @procName
    while @@fetch_status = 0
    begin
        exec('drop procedure ' + @procName)
        fetch next from cur into @procName
    end
    close cur
    deallocate cur
    
    z-boss : Why do you think it is very dangerous?
  • I would prefer to do it this way:

    • first generate the list of stored procedures to drop by inspecting the system catalog view:

      SELECT 'DROP PROCEDURE ' + p.NAME
      FROM sys.procedures p 
      

      This generates a list of DROP PROCEDURE statements in your SSMS output window.

    • copy that list into a new query window, and possibly adapt it / change it and then execute it

    No messy and slow cursors, gives you the ability to check and double-check your list of procedure to be dropped before you actually drop it

    z-boss : I need this for deployment, so it has to be automatic.

Question regarding XML validation using XSD

I am looking to create an XSD document that would validate some XML for me. Let's say, for example, that the XML documents are designed to describe books:

<?xml version="1.0" encoding="UTF-8"?>
<book>
    <comment>Bob's very first book</comment>
    <name>Bob's book</name>
    <author>Bob</author>
    <year>2009</year>
    <publisher>
        <name>Dan's book publishing enterprise</name>
        <address>123 Fake St.</address>
    </publisher>
</book>

Let's also say that I only really care about three elements - the name, the author and the year. They are mandatory and should be validated against the schema. I do not control the XML files that I receive so the order of elements should not matter and any additional elements are to be allowed to pass through XSD validation unchecked.

Following these requirements, I have tried to construct an XSD schema that would be able to do this kind of validation, but I can't get it right. The constraint that elements can be defined in any order rules out the sequence indicator. What I'm left is the all or the choice indicators. all would be the obvious choice, but it does not allow me to use the any element.

I also toyed with the idea of using this:

<include schemaLocation="year.xsd"/>
<include schemaLocation="name.xsd"/>
<include schemaLocation="author.xsd"/>
....
    <sequence>
        <any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
    </sequence>

While if found in the XML file, name year and author will be validated, this does not check for mandatory elements - I cannot specify that the year, the author and the name of the book are required to pass validation.

Could anyone give me hint of how to construct an XSD document that will validate a number of unordered mandatory elements and will still allow undefined elements in the XML file to pass validation?

Thanks!

From stackoverflow
  • I am quite sure that you can't do this with the XML Schema. Suggestions:

    • Prepare you document for validation with XSLT.
    • Use Schematron.
    Sevas : It would seem that you are right...

[CSS] Margin display disparity between IE7 and FF3

Hi everyone:

Refer to HTML, CSS below.

Why the margin-bottom will not reflect in IE7, but in FF3? Is there any workaround for it?

Notice that I set margin: 50 in CSS.

<body style="background-color:#fff">
<div class="window">
  d-window
</div>

CSS:

body{margin:10px;padding:0;background-color:#1e1e1e;color:#ddd; border: 1px solid #000000}
.window { width:280px; clear:both; margin: 50px; border: 1px solid #000000}

Thanks

From stackoverflow
  • use a #container div instead of the body and use float on the container but not the .window class that should solve the problem.

PHP : How to Get object or class name

right now, i have this code where $obj_arr maybe contain array and object.


$obj_temp = array ($obj_identity, $arr_user, $obj_locale, $arr_query); 

    foreach ($obj_temp as $maybe_arr) {
            if (is_array($maybe_arr)) :
                $name = (string) key($maybe_arr);
            if (is_object($maybe_arr)) :    
                ???? // how to retrieve a class name ?
            endif;  

            $obj_arr[$name] = $maybe_arr;

    }



obj_will_be_extract($obj_arr);
----

function obj_will_be_extract($obj_arr) {
    extract($obj_arr);

    //Do the rest

}

i need to create array consist combination of object and array. Cause i need to extract it, then how to get an object name ?

From stackoverflow
  • Use get_class to get the class name of an object.

TinyMCE javascript errors

i Have downloaded TinyMCE and running examples. When i run any example and click on html button of TinyMCE GUI i am getting js errors
Permission denied for <file://> to get property Window.tinymce from <file://>. and
this.params is undefined

Check these errors in Firefox while opening firebug.

From stackoverflow
  • Browsers can be overly strict when loading files directly from the file system. Try putting the examples on a web server and you'll probably find they work correctly.

    Regards,

    Adrian Sutton
    http://tinymce.ephox.com

does itunes have an api to upload music through remote site?

i have a client who wants a his music artists to upload their music through the website. does itunes have an api that will alow these customers to upload their music to itunes through the website then have the music sold through the website, so that they dont have to go through itunes?

From stackoverflow
  • Tunecore seems useful for this sort of task. They'll handle uploading to iTunes and a few other stores for a fee.

    Apple doesn't provide an API for just anyone to upload whatever they like to the store.

How to convert varchar to date in PostgreSQL?

Hi,

I have varchar data type column and date data type column . I have to update varchar column data into date column in PostgreSQL.

Is it possible?

Thanks.

chandu

From stackoverflow
  • to_date('05 Dec 2000', 'DD Mon YYYY')
    
  • UPDATE tableName SET  dateColumn= to_date(varcharColumn, 'DD MM YYYY')
    

    Assuming you are saving "07 04 2010"

    if not Reffer following link

    :- http://www.postgresql.org/docs/8.1/interactive/functions-formatting.html

    Frank Heikens : Solution is correct, the url to a very old manual is a little hmmmm.... 8.1 will not be supported as of November 2010. Better use a newer version.