nesting

How to make this ruby method less ugly (nesting)

I have a helper method that creates navigation links for some controllers. def gen_associations(controllers) content_for :leftnav do sorted_controllers = controllers.sort returning String.new do |content| content << content_tag(:h3, "Associations") << content_tag(:ul, :class => "nav") do sorte...

Which is better coding style?

During a code review, a senior dev commented on some nesting I had going on in my code. He suggested I set a bool value so that I never have more than one level of nesting. I think my code is more readable but want to get other devs' opinion on this. Which is better style? Is his knee-jerk aversion to nesting founded? Below are some...

Nesting of xsl:key() within xsl:key() & combining results of xsl:key()

Hi all, I have 2 unrelated questions. I need to do a grouping of data using XSLT. I need this to function like how a nested IF within an IF would function. After which, I need to group the data so that I can split it into multiple files according to the Group condition. Using XSLT Version 1.0 : Q1) How do you nest a key() within anoth...

Nesting datasets with TClientdatasets in more than two levels?

Hi I would like to know if it is possible to nest a dataset within a dataset and then nest this data set with in another dataset. Therfore 3 levels of nesting. Currently I only manage to nest one dataset with in the other. When attemting to nest the third level the database manages to run successfully the first time I compile my program...

Margin on child element moves parent element

I have a div (parent) that contains another div (child). Parent is the first element in body with no particular CSS style. When I set .child { margin-top: 10px; } The end result is that top of my child is still aligned with parent. Instead of child being shifted for 10px downwards, my parent moves 10px down. My DOCTYPE is set to ...

Zend: How to nest different controllers into one big?

What are (the best) approaches for the Zend Framework to nest different controllers actions into one big one? And how would I solve the following situation: A link in my main big view calls an other view where I can select a specific value and come back automatically after selecting to the main view and pre-filling this selected value? ...

Problem while nesting DataTable

Hello. I am trying to achieve nesting in DataTable, i.e. a column of DataTable is a DataTable. My code is something like this: DataTable table = new DataTable(); DataColumn column = new DataColumn("Qualifications", System.Type.GetType("System.Data.DataTable")); table.Columns.Add(column); I am getting a runtime error message at li...

Rails XML builder templates / group data

My SQL result @products=Product.find_by_sql() gives me this ( ID title, user_name 1 Product1 Xpeper 1 Product1 John 2 Product2 Xpeper How can I build XML in my xml.builder view file so the source bould be like this <products> <product> <id>1</id> <title>Product1</title> <users> <user>Xpe...

Using regex to match string between two strings

How can I use a regular expression to match text that is between two strings, where those two strings are themselves enclosed two other strings, with any amount of text between the inner and outer enclosing strings? For example, I have this text: outer-start some text inner-start text-that-i-want inner-end some more text outer-end ...

Problem with nesting in Text.XHtml library with Haskell

Hi I have the following code to generate a blank html page with a series of divs with id's and classes in Haskell using the Text.XHtml.Strict library: module Main where import Text.XHtml.Strict import Text.Printf page :: Html page = pHeader +++ pTop +++ pBody +++ pFooter pHeader :: Html pHeader = header << thetitle << "Page title" ...

How to get a second System.Thread.ThreadPool?

If I use the ThreadPool in a nested way, my application hangs: ThreadPool.QueueUserWorkItem((state) => ThreadPool.QueueUserWorkItem(Action)); How to get a second and independent ThreadPool to achieve nesting? ...

how to create a loop in a function with another function?

Thanks for the help guys ...

Debugging build errors in painfully nested VB .aspx file

I have an VB ASP.NET (.aspx) file that has deeply nested logic and I'm getting lots of build errors like "If must end with a matching End If" and "Do must end with a matching Loop". How do I begin to debug this beast to at least get it to build? ...

Struts 2 nesting iterators

I can't believe how something this simple can seem so hard to do in Struts 2. This is approximately what I would like to do as it would be done in Java. for (Parent parent : parents){ for (Child child: parent.getChildren()){ System.out.println(child.getName()); } } That should translate to something close to this in Stuts t...

Disallow an element to be a child of itself in XML Schema

Hi! Im writing a XML schema for a project. I cannot solve following problem: A element cannot be nested by itself, ex: <document> <text> <b> <i> <a link="http://wikipedia.org"&gt; <b /> </a> </i> </b> </text> </document> This example shouldn't be allow becaus...

More efficient solution to loop nesting required

I am trying to compare two files. I will list the two file content: File 1 File 2 "d.complex.1" "d.complex.1" 1 4 5 5 48 47 65 21 d.complex.10 ...

Storing vector in a struct C++

Why can't I do this: struct sName { vector<int> x; }; It takes only three pointers to store a vector, so I should be able to do this? ...

Nesting Patterns Algorithms / Cutting Waste Problem

First off, I'd like to say that I'm already looking into the "Cutting Stock Problem" algorithm, however I feel that I need a bit more clarification, and possibly some help with some of the math (Not my strong point). What I need to do is have an offset pattern that causes the circle to fit in the crevasse created by having the two circu...

Nesting maximum amount of shapes on a surface

In industry, there is often a problem where you need to calculate the most efficient use of material, be it fabric, wood, metal etc. So the starting point is X amount of shapes of given dimensions, made out of polygons and/or curved lines, and target is another polygon of given dimensions. I assume many of the current CAM suites implem...

DIV tags not being properly nested.

I have created some <div> tags and am setting it to contain two <div> tags that are floated to both sides of the <div>. I noticed when I tried to set a background color that the containing <div> was not properly wrapping around the <div>s that its supposed to contain. I would like to know why this happens. I have seen a similar question...