Search and replace in only certain tags and attributes in XML file by a regular expression - regex

I have an XML file (call it module.xml) as below opened in
an editor like Notepad++ or Geany:
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="head">
<action method="addItem"><type>skin_js</type><name>module/js/jquery.js</name></action>
<action method="addItem"><type>skin_js</type><name>module/js/module-slider.js</name></action>
<action method="addItem"><type>skin_css</type><name>module/module.css</name></action>
<action method="addItem"><type>skin_js</type><name>module/js/module-video.js</name></action>
<action method="addItem"><type>skin_js</type><name>module/js/nicEdit-latest.js</name></action>
</reference>
<reference name="left">
<block type="module/subscribe" name="module.left.subscribe" template="module/left-sidebar.phtml" />
</reference>
<reference name="right">
<block type="module/subscribe" name="module.right.subscribe" template="module/right-sidebar.phtml" before="-" />
</reference>
<reference name="top.links">
<action method="addLink" translate="label title" module="module" ifconfig="module/settings/quicklinks">
<label>Module Title</label>
<url>module</url>
<title>Module Title</title>
<prepare>true</prepare>
<urlParams/>
<position>99</position>
</action>
</reference>
<reference name="footer_links">
<action method="addLink" translate="label title" module="module" ifconfig="module/settings/quicklinks">
<label>Module Title</label>
<url>module</url>
<title>Module Title</title>
<prepare>true</prepare>
<urlParams/>
<position>99</position>
</action>
</reference>
</default>
<module_index_index>
<reference name="content">
<block type="module/list" name="module_list" template="module/list.phtml" />
</reference>
</module_index_index>
<module_create_index>
<reference name="content">
<block type="module/list" name="module.create">
<action method="setTemplate"><template>module/create.phtml</template></action>
</block>
</reference>
</module_create_index>
</layout>
Now I want to replace string module/ with mycompany/module/ in only tags and attributes containing .phtml filenames only, i.e. in content of the template attribute and <template> tag.
How can I do this with a regular expression? I am out of ideas when it comes to selective find/replace with regular expressions.

Note that this will work with properly formatted XML files.
You can use the regex (?=.*\.phtml)module\/ and replace with mycompany/module/.
This:
(?=.*\.phtml)
Is a positive lookahead: it will ensure that the regular expression will be matched in the line. module\/ is the string you want to replace with an escape on the /.
Also, you should read this well-known answer about parsing with regular expression.

Related

Struts 2.3 ignores wildcard actions

I'm setting up an application that uses Struts 2.3 and Tiles 2. Some pages will be heavily Struts driven (e.g. lots of CRUD) while others will be simple, static HTML/JSP pages. I want to set up some actions that handle specific functionality and send all other URLs to a default action, which will check to see if the appropriate static page exists based on the supplied path. If not, a 404 error or some such will be generated instead.
In struts.xml, I have applied a basic configuration that appears like it should work; however, Struts seems to ignore the wildcard action. The non-wildcard actions work just fine.
Here's the struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!--
You could also set the constants in the struts.properties file
placed in the same directory as struts.xml
-->
<constant name="struts.devMode" value="true" />
<!-- <constant name="struts.mapper.class" value="rest" /> -->
<constant name="struts.action.extension" value="," />
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
<constant name="struts.patternMatcher" value="regex" />
<!--
<constant name="struts.convention.action.suffix" value="Controller"/>
<constant name="struts.convention.action.mapAllMatches" value="true"/>
<constant name="struts.convention.default.parent.package" value="rest-default"/>
<constant name="struts.convention.package.locators" value="rest"/>
-->
<package name="base" extends="tiles-default" abstract="yes">
<result-types>
<result-type name="tiles" default="true" class="org.apache.struts2.views.tiles.TilesResult" />
<result-type name="json" class="org.apache.struts2.json.JSONResult"/>
</result-types>
<interceptors>
<interceptor name="json" class="org.apache.struts2.json.JSONInterceptor"/>
<!-- <interceptor name="requestConstants" class="com.ibm.gbs.vdp.constants.ConstantsInterceptor" /> -->
<interceptor-stack name="mainStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="json" />
<!-- <interceptor-ref name="session" /> -->
<!-- <interceptor-ref name="requestConstants" /> -->
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="mainStack" />
<global-results>
<result name="login" type="tiles">login</result>
</global-results>
</package>
<!-- package start -->
<package name="main" extends="base" namespace="/">
<action name="login">
<result type="tiles">login</result>
</action>
<action name="logout" class="com.gswt.common.action.LogoutAction">
<result name="success">login</result>
</action>
<action name="*" class="com.installation.action.PageAction">
<result type="tiles">standard-page</result>
</action>
</package>
<!-- package end -->
<!-- package start -->
<package name="licenses" extends="base" namespace="/licenses">
</package>
<!-- package end -->
<!-- package start -->
<package name="checklists" extends="base" namespace="/checklists">
</package>
<!-- package end -->
<!-- package start -->
<package name="error" extends="base" namespace="/error">
<action name="404">
<result type="tiles">error-404</result>
</action>
</package>
<!-- package end -->
</struts>
And here's an example of the error I receive:
There is no Action mapped for namespace [/] and action name [page] associated with context path []. - [unknown location]
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:553)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:125)
com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:80)
com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908)
com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:997)
com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:1079)
com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:999)
com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3954)
com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:945)
com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191)
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453)
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515)
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:306)
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:277)
com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1049)
com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:643)
com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784)
com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1656)
What am I missing or doing wrong?
Since you are using advanced wildcards then your action name should be a valid regex expression to match the configuration.
Like so
<action name="{.*}" class="com.installation.action.PageAction">
<result type="tiles">standard-page</result>
</action>

How to Exclude Semicolons from MSBuild ExtensionPack.FileSystem.File Replacements

I'm using MSBuild extension pack to replace lines in .proj files.
I'm replacing multiple lines with multiple lines. The lines it's outputting still have a semi colon at the end even when I do a transform.
<ItemGroup>
<TestFile Include="regextest.xml" />
<MyLines Include ="%3CItemGroup%3E%0A"/>
<MyLines Include ="%09%3CReference Include=%22Stuff%22%3E%0A" />
<MyLines Include ="%09%09%3CHintPath%3E..\..\packages\secret.dll%3C/HintPath%3E%0A" />
<MyLines Include ="%09%09%3CPrivate%3ETrue%3C/Private%3E%0A" />
<MyLines Include ="%09%3C/Reference%3E%0A" />
<MyLines Include ="%3C/ItemGroup%3E%0A" />
</ItemGroup>
<Target Name="Default">
<MSBuild.ExtensionPack.FileSystem.File TaskAction="Replace"
TextEncoding="ASCII"
RegexPattern="%3CProjectReference"
RegexOptionList="IgnoreCase"
Replacement="#(MyLines->'%(Identity)')"
Files="#(TestFile)" />
</Target>
And this is the output:
<ItemGroup>
; <Reference Include="Stuff">
; <HintPath>..\..\packages\secret.dll</HintPath>
; <Private>True</Private>
; </Reference>
;</ItemGroup>
Doing it without the transform still has them there too.
One easy way to handle multi-line replacement strings is to form them in a CDATA block inside of a property instead of a collection of single-line items (this is where the semicolons come from). In this case, you could create the multi-line replacement string as a property and then assign its value to an item, then pass the item to the Replace task action:
<PropertyGroup>
<MyMultiLine>
<![CDATA[
%3CItemGroup%3E
%3CReference Include="Stuff"%3E
%3CHintPath%3E..\..\packages\secret.dll%3C/HintPath%3E
%3CPrivate>True%3C/Private%3E
%3C/Reference%3E
%3C/ItemGroup%3E
]]>
</MyMultiLine>
</PropertyGroup>
<ItemGroup>
<TestFile Include="regextest.xml" />
<MyMultiLineItem Include="$(MyMultiLine)" />
</ItemGroup>
<Target Name="Default">
<MSBuild.ExtensionPack.FileSystem.File TaskAction="Replace"
TextEncoding="ASCII"
RegexPattern="%3CProjectReference"
RegexOptionList="IgnoreCase"
Replacement="#(MyMultiLineItem ->'%(Identity)')"
Files="#(TestFile)" />
</Target>

Freeswitch call intercerpt configuration

I am trying to configure call intercept groups and I am having a hard time finding what is wrong with my config. When I dial the feature code to intercept *110(interceptgroup no) (in this case *110101) the dialplan doesn't match and fails. The hash is inserted successfully, I can see it in the cli via hash select/intercept_2/101. What am I missing here?
Here is my user config from directory/default.xml:
<user bluebox_id="3" id="1001">
<variables>
<variable name="internal_caller_id_number" value="1001"/>
<variable name="user_context" value="context_4"/>
<variable name="force_transfer_context" value="context_4"/>
<variable name="user_originated" value="true"/>
<variable name="toll_allow" value="domestic"/>
<variable name="accountcode" value="1001"/>
<variable name="callrecord_inbound" value="1"/>
<variable name="callrecord_outbound" value="1"/>
<variable name="interceptgroup" value="101"/>
</variables>
<params>
<param name="password" value="removed"/>
<param name="dial-string" value="{presence_id=${dialed_user}#${dialed_domain}}${sofia_contact(${dialed_user}#${dialed_domain})}"/>
</params>
</user>
<user bluebox_id="5" id="1238">
<variables>
<variable name="internal_caller_id_number" value="1238"/>
<variable name="user_context" value="context_4"/>
<variable name="force_transfer_context" value="context_4"/>
<variable name="user_originated" value="true"/>
<variable name="toll_allow" value="domestic"/>
<variable name="accountcode" value="1238"/>
<variable name="callrecord_inbound" value="1"/>
<variable name="callrecord_outbound" value="1"/>
<variable name="interceptgroup" value="101"/>
</variables>
<params>
<param name="password" value="removed"/>
<param name="dial-string" value="{presence_id=${dialed_user}#${dialed_domain}}${sofia_contact(${dialed_user}#${dialed_domain})}"/>
</params>
</user>
Here is my dialplan config from dialplan.xml:
<extension name="main_number_43" continue="true">
<condition field="destination_number" expression="^1238$">
<action application="hash" data="insert/intercept_2/101/${uuid}"/>
<action application="set" bluebox="settingTimeout" data="call_timeout=30"/>
<action application="set" bluebox="settingRing" data="ringback=${us-ring}"/>
<action application="set" bluebox="settingRingXfer" data="transfer_ringback=${us-ring}"/>
<action application="export" bluebox="sipCalleeIdName" data="sip_callee_id_name=linksys"/>
<action application="export" bluebox="sipCalleeIdNumber" data="sip_callee_id_number=1238"/>
<action application="bridge" data="user/1238#$${location_4}"/>
<action application="hangup"/>
</condition>
</extension>
<extension name="main_number_45" continue="true">
<condition field="${regex(m:/${destination_number}/^\*110([0-9]+)$/$1)}" expression="^${interceptgroup}$"/>
<condition field="destination_number" expression="^\*110([0-9]+)$">
<action application="answer"/>
<action application="set" data="intercept_unanswered_only=true"/>
<action application="intercept" data="${hash(select/intercept_2/$1)}"/>
<action application="sleep" data="2000"/>
<action application="hangup"/>
</condition>
</extension>
After some headache I discovered that you cannot prepend this particular feature code with a *, it causes freeswitch to parse the digits differently by separating the feature code itself (*110 in this case) from the digits you enter as an argument, which in this case is the intercept group number. Removing the * fixed it.
<extension name="main_number_45" continue="true">
<condition field="${regex(m:/${destination_number}/^\110([0-9]+)$/$1)}" expression="^${interceptgroup}$"/>
<condition field="destination_number" expression="^\110([0-9]+)$">
<action application="answer"/>
<action application="set" data="intercept_unanswered_only=true"/>
<action application="intercept" data="${hash(select/intercept_2/$1)}"/>
<action application="sleep" data="2000"/>
<action application="hangup"/>
</condition>
</extension>

Sharp architecture 2.0 unit testing

I am just trying to test some validation which involves the database. The setup of my test code looks something like this:
[TestFixture]
public class UserValidatorTester : RepositoryTestsBase
{
[SetUp]
public void Setup()
{
ServiceLocatorInitializer.Init();
base.SetUp();
}
...
The ServiceLocatorInitializer looks like this:
public class ServiceLocatorInitializer
{
public static void Init()
{
IWindsorContainer container = new WindsorContainer();
container.Register(
Component
.For(typeof(IEntityDuplicateChecker))
.ImplementedBy(typeof(EntityDuplicateChecker))
.Named("entityDuplicateChecker"));
container.Register(Component.For(typeof(ISessionFactoryKeyProvider)).ImplementedBy(typeof(DefaultSessionFactoryKeyProvider)).Named("sessionFactoryKeyProvider"));
ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));
}
}
I am getting:
at SharpArch.Domain.SafeServiceLocator`1.GetService()
at SharpArch.NHibernate.SessionFactoryKeyHelper.GetKeyFrom(Object anObject)
at SharpArch.NHibernate.NHibernateRepositoryWithTypedId2.get_Session()
at EID2.Tasks.Repositories.UserRepository.SaveOrUpdate(User entity) in C:\Users\csetzkorn\Documents\Visual Studio 2010\Projects\EID2\Solutions\EID2.Tasks\Repositories\UserRepository.cs:line 17
at EID2.Tasks.UserTasks.CreateUser(CreateUserViewModel CreateUserViewModel) in C:\Users\csetzkorn\Documents\Visual Studio 2010\Projects\EID2\Solutions\EID2.Tasks\UserTasks.cs:line 33
at EID2.Tests.Validation.UserValidatorTester.LoadTestData() in C:\Users\csetzkorn\Documents\Visual Studio 2010\Projects\EID2\Solutions\EID2.Tests\Validation\UserValidatorTester.cs:line 39
at SharpArch.Testing.NUnit.NHibernate.RepositoryTestsBase.SetUp()
--NullReferenceException
at Microsoft.Practices.ServiceLocation.ServiceLocator.get_Current()
at SharpArch.Domain.SafeServiceLocator1.GetService()
Christian
PS:
Included dlls:
<ItemGroup>
<Reference Include="Castle.Core">
<HintPath>..\..\Packages\Castle.Core.2.5.2\lib\SL4\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Castle.Windsor">
<HintPath>..\..\Packages\Castle.Windsor.2.5.3\lib\NET40\Castle.Windsor.dll</HintPath>
</Reference>
<Reference Include="CommonServiceLocator.WindsorAdapter">
<HintPath>..\..\Packages\CommonServiceLocator.WindsorAdapter.1.0\lib\NET35\CommonServiceLocator.WindsorAdapter.dll</HintPath>
</Reference>
<Reference Include="EID2.Tasks">
<HintPath>..\xxx.Tasks\bin\Debug\xxx.Tasks.dll</HintPath>
</Reference>
<Reference Include="FluentValidation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a82054b837897c66, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Packages\FluentValidation\FluentValidation.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation">
<HintPath>..\..\Packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="MvcContrib.TestHelper">
<HintPath>..\..\Packages\MvcContrib.Mvc3-ci.3.0.68.0\lib\MvcContrib.TestHelper.dll</HintPath>
</Reference>
<Reference Include="NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\ReferencedAssemblies\NHibernate\NHibernate.dll</HintPath>
</Reference>
<Reference Include="NHibernate.ByteCode.Castle">
<HintPath>..\..\ReferencedAssemblies\NHibernate\NHibernate.ByteCode.Castle.dll</HintPath>
</Reference>
<Reference Include="NHibernate.Validator">
<HintPath>..\..\ReferencedAssemblies\NHibernate\NHibernate.Validator.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\Packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="Rhino.Mocks">
<HintPath>..\..\ReferencedAssemblies\RhinoMocks\Rhino.Mocks.dll</HintPath>
</Reference>
<Reference Include="SharpArch.Domain">
<HintPath>..\..\ReferencedAssemblies\SharpArchitecture\SharpArch.Domain.dll</HintPath>
</Reference>
<Reference Include="SharpArch.NHibernate">
<HintPath>..\..\ReferencedAssemblies\SharpArchitecture\SharpArch.NHibernate.dll</HintPath>
</Reference>
<Reference Include="SharpArch.Testing">
<HintPath>..\..\ReferencedAssemblies\SharpArchitecture\SharpArch.Testing.dll</HintPath>
</Reference>
<Reference Include="SharpArch.Testing.NUnit">
<HintPath>..\..\ReferencedAssemblies\SharpArchitecture\SharpArch.Testing.NUnit.dll</HintPath>
</Reference>
<Reference Include="SharpArch.Tests">
<HintPath>..\..\ReferencedAssemblies\SharpArchitecture\SharpArch.Tests.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite">
<HintPath>..\..\Packages\System.Data.SQLite.1.0.66.0\lib\System.Data.SQLite.DLL</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\ReferencedAssemblies\ASP.NET MVC\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
PPS:
sql lite config
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
<property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
<property name="connection.connection_string">Data Source=:memory:;Version=3;New=True;</property>
<property name="connection.release_mode">on_close</property>
<property name="show_sql">true</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
</session-factory>
</hibernate-configuration>
There is a couple of the things that could go wrong with sqlite and there are different solutions for different problems, I think the problem you having is because sqlite.dll was built against .net System.Data while what you have is .net 4 System.Data, try adding:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
to the configuration element in the test app.config.
Also, if you are on x64 machine, and are referencing the x86 sqlite, then you need to change the target framework for your test assembly to x86 (right click project, select properties, build tab, and select x86 for the target framework)
The issue is that the NHibernate Session factory cannot be created. Read the error message:
System.ArgumentException : Unable to find the requested .Net Framework Data Provider. It may not be installed.
Do you have the SQLLite dll included in your project?
System.Data.SQLite.dll

Magento design - new homepage columns

I want to make a custom design for my magento store like this :
How can I proceed to do that, specially for the products from category1 and category2, I want there a new header for this list, with a little images, not like the standard category grid...
Thanks a lot for help;
Create CMS page.
Switch to the Design mode. Select Layout - 1 column.
Edit Layout Update XML
<block type="cms/block" name="block1_static">
<action method="setBlockId"><id>cms_block1-static</id></action>
</block>
<block type="page/html_wrapper" name="left.callout.wrapper" translate="label">
<action method="setElementId"><value>hompage-left-callout</value></action>
<block type="core/template" name="left.callout" template="callouts/right_col.phtml">
<action method="setImgSrc"><src>images/media/left_banner_1.gif</src></action>
</block>
</block>
<block type="page/html_wrapper" name="center.wrapper" translate="label">
<action method="setElementId"><value>hompage-center</value></action>
<block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml" after="cms_page"><action method="addPriceBlockType"><type>bundle</type><block>bundle/catalog_product_price</block><template>bundle/catalog/product/price.phtml</template></action></block>
<block type="reports/product_viewed" name="home.reports.product.viewed" alias="product_viewed" template="reports/home_product_viewed.phtml" after="product_new"><action method="addPriceBlockType"><type>bundle</type><block>bundle/catalog_product_price</block><template>bundle/catalog/product/price.phtml</template></action></block>
</block>
<block type="page/html_wrapper" name="right.callout.wrapper" translate="label">
<action method="setElementId"><value>hompage-right-callout</value></action>
<block type="core/template" name="right.callout" template="callouts/right_col.phtml">
<action method="setImgSrc"><src>images/media/right_banner_1.gif</src></action>
</block>
</block>
There is two blocks for example - viewed products and new products. There is not default block to show products from specific category in Magento. You should create this block and template for it and use this block at place of examples block.
Position of blocks you may align with css. Each block will be wrapped with div with specific ID. ElementId and ElementClass you may set wrapper block.