how to decrease the height between paragraphs i.e <p> </p> in JSP - height

I got 4 paragraphs like
abcd
efgh
ijkl
mnop
Here is the code:
<p style="line-height: 2"> <label><font color="red">*</font>Alamat :</label>
${actionBean.deposit.alamat1} <p style="line-height: 1"> <label> </label>
${actionBean.deposit.alamat2} </p> <p style="line-height: 1"> <label> </label>
${actionBean.deposit.alamat3} </p>
the size between the paragraphs is too big. I use the line-height attribute but its not workin properly....Please suggest me a good option.
Thanks in advance.

Related

Get the level of nodes

I want to get the level of <li> in my input
input:
<ol start="1" style="1">
<li>
<p type="List Number Level 1">Text 1.</p>
</li>
<li>
<p type="List Number Level 1">Text 2</p>
<ol start="1">
<liFormat><iRef style="a"/>)<t/></liFormat>
<li>
<p type="List Number Level 2">Text 3.</p>
</li>
<li>
<p type="List Number Level 2">Text 4.</p>
</li>
</ol>
</li>
<li>
<p type="List Number Level 1">Text 5.</p>
</li>
</ol>
Output should be :
<ol start="1" style="1">
<li>
<p type="List_1_First">Text 1.</p>
</li>
<li>
<p type="List_1_First">Text 2</p>
<ol start="1">
<liFormat><liRef style="a"/>)<t/></liFormat>
<li>
<p type="List_2_First">Text 3.</p>
</li>
<li>
<p type="List_2_First">Text 4.</p>
</li>
</ol>
</li>
<li>
<p type="List_1_First">Text 5.</p>
</li>
</ol>
Tried code :
<xsl:template match="ol[#start]/li[1]/p[contains(#type,'List')]" priority="30">
<p type="List_{count(li)}_First">
<xsl:apply-templates/>
</p>
</xsl:template>
Here all things have been implemented as i expected. But I have to take the level of li. ex : List_{li level}_First . Nut that par not working properly. I have mentioned my tried code. I am using xslt 2.0.
Thank you
I think you need to count the ancestors here:
<tps:p type="List_{count(ancestor::tps:li)}_First">
Maybe you have other templates in your XSLT, but your current template only matches the first li element under the ol. To get your expected output, maybe you need to do this...
<xsl:template match="tps:ol[#start]/tps:li/tps:p[contains(#type,'List')]" priority="30">
See http://xsltfiddle.liberty-development.net/gWEamKJ for an example.

Using XSLT create href to id based to attribute

I want to create a bootstrap accordion menu using xslt and read data from xml file. I have this xslt
<xsl:template match="/Settings">
<xsl:for-each select="Area">
<div class="panel-group configuration-menu-style" id="Menu">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#Menu" href="#{#Caption}">
<xsl:value-of select="#Caption"/>
</a>
</h4>
</div>
<div id="{#Caption}" class="panel-collapse collapse in">
<div class="panel-body custom-padding">
<table class="table">
<xsl:for-each select="Category">
<tr>
<td class="configuration-submenu-style">
<xsl:value-of select="#Caption"/>
</td>
</tr>
</xsl:for-each>
</table>
</div>
</div>
</div>
</div>
</xsl:for-each>
In this line
<div id="{#Caption}" class="panel-collapse collapse in">
i give id based to attribute and works. Using developer tools in browser i can see that has id="MENU OPTION2" The problem is in this line
<a data-toggle="collapse" data-parent="#Menu" href="#{#Caption}">
<xsl:value-of select="#Caption"/>
</a>
Using developer tools in browser i can see that this element has href="#MENU%20OPTION2
So... how can remove %20 from href?
SOLUTION
<a data-toggle="collapse" data-parent="#Menu" href="#{position()}">
<div id="{position()}" class="panel-collapse collapse in">
BECAUSE 'id="MENU OPTION2" is not valid as id should not contain space'
id="MENU OPTION2" is not valid as id should not contain spaces
Just have a look at this:
What are valid values for the id attribute in HTML?
So I suggest you use "MENU_OPTION2" or "MENU-OPTION2" as there would be no difference when urlencoding those strings.
-- EDIT --
By the way, I just remembered that I already worked on this kind of subject long time ago... http://xul.ccoste.fr/
And if you have a look as my XSLT file http://xul.ccoste.fr/xul-bootstrap.xsl, I used generate-id() to be sure that there would never be any conflict between IDs.
<xsl:template match="tabs">
<ul class="nav nav-tabs">
<xsl:for-each select="tab">
<li>
<xsl:if test="position() = 1">
<xsl:attribute name="class"><xsl:text>active</xsl:text></xsl:attribute>
</xsl:if>
<a data-toggle="tab" href="#{generate-id(../..)}-{position()}">
<xsl:value-of select="#label" />
</a>
</li>
</xsl:for-each>
</ul>

Cannot get content of specific div

I've this html page. I'm trying to extract the following information of this div:
<div class="clearfix">
<div class="container left">
<div class="logo">
<a href="/teams/belarus/fc-bate-borisov/200/">
<img src="http://cache.images.core.optasports.com/soccer/teams/150x150/200.png" alt="FC BATE Borisov" />
</a>
</div>
</div>
<div class="container middle">
<div class="details clearfix">
<dl>
<dt>Gara</dt>
<dd>Premier League</dd>
<dt>Data</dt>
<dd><span class='timestamp' data-value='1466877600' data-format='d mmmm yyyy'>25 giugno 2016</span></dd>
<dt>Game week</dt>
<dd>14</dd>
<dt>calcio di inizio</dt>
<dd>
<span class='timestamp' data-value='1466877600' data-format='HH:MM'>20:00</span>
(<span class="game-minute">FP'</span>)
</dd>
</dl>
</div>
<div class="details clearfix">
<dl>
<dt>Stadio</dt>
<dd>Borisov Arena (Barysaw (Borisov))</dd>
</dl>
</div>
</div>
<div class="container right">
<div class="logo">
<a href="/teams/belarus/fc-vitebsk/204/">
<img src="http://cache.images.core.optasports.com/soccer/teams/150x150/204.png" alt="FC Vitebsk" />
</a>
</div>
</div>
</div>
</div>
</div>
</div>
in particular the tab calcio di inizio - game week - stadio
Actually I've tried this regex: <div[^<>]*class="clearfix"[^<>]*>(?<content>.*?)
but when I test it on https://regex101.com/ I can't run the regex.
I think that the class of the div is associated on multiple divs, so this could be the problem.
And also the doesn't have any class for take it, any idea?
If you add an id to the div you want to get the contents of (for example "myDiv"), you could run the following javascript function to return it's HTML contents:
document.getElementById("myDiv").innerHTML
I am not exactly sure if this is what you want, since its not regex, but if so, I hope this helps!

selecting values of tags within tags

this is a part of the html code i'm interested in:
<div class="mreinfwpr" id="mhd">
<p class="mreinfp">Hours of Operation (View all)(Show less)</p>
<ul id="hroprt" class="alstdul">
<li class="mreinfli">
<span class="mreinflispn1">Today</span><span class="mreinflispn2"><span>11:30 am - 11:30 pm</span>
</span><span class="mreinflispn3">Closed Now</span> </li>
</ul>
<!-- View All Work Timings Vertically -->
<ul class="alstdul dn" id="statHr">
<li class="mreinfli">
<span class="mreinflispn1"> Monday </span><span class="mreinflispn2">11:30 am - 11:30 pm</span>
</li>
<li class="mreinfli">
<span class="mreinflispn1"> Tuesday </span><span class="mreinflispn2">11:30 am - 11:30 pm</span>
</li>
<li class="mreinfli">
<span class="mreinflispn1"> Wednesday </span><span class="mreinflispn2">11:30 am - 11:30 pm</span>
</li>
<li class="mreinfli">
<span class="mreinflispn1"> Thursday </span><span class="mreinflispn2">11:30 am - 11:30 pm</span>
</li>
<li class="mreinfli">
<span class="mreinflispn1"> Friday </span><span class="mreinflispn2">11:30 am - 11:30 pm</span>
</li>
<li class="mreinfli">
<span class="mreinflispn1"> Saturday </span><span class="mreinflispn2">11:30 am - 11:30 pm</span>
</li>
<li class="mreinfli">
<span class="mreinflispn1"> Sunday </span><span class="mreinflispn2">11:30 am - 11:30 pm</span>
</li>
</ul>
</div>
<div class="mreinfwpr">
<p class="mreinfp">Also Listed in</p>
<ul class="alstdul">
<li>
<a onclick="_ct('alsocat', 'dtpg', '17592186044416');" href="http://www.justdial.com/Bangalore/Pubs-<near>-Indira-Nagar-2nd-Stage/ct-1000027567" title="Pubs in Indira-Nagar-2nd-Stage, Bangalore">Pubs</a>
<!-- <li class="spc"></li> -->
<li>
<a onclick="_ct('alsocat', 'dtpg', '17592186044416');" href="http://www.justdial.com/Bangalore/Pizza-Outlets-<near>-Indira-Nagar-2nd-Stage/ct-50105" title="Pizza Outlets in Indira-Nagar-2nd-Stage, Bangalore">Pizza Outlets</a>
<!-- <li class="spc"></li> -->
<li>
<a onclick="_ct('alsocat', 'dtpg', '17592186044416');" href="http://www.justdial.com/Bangalore/Restaurants-<near>-Indira-Nagar-2nd-Stage/ct-304085" title="Restaurants in Indira-Nagar-2nd-Stage, Bangalore">Restaurants</a>
<!-- <li class="spc"></li> -->
<li>
<a onclick="_ct('alsocat', 'dtpg', '17592186044416');" href="http://www.justdial.com/Bangalore/Lounge-Bars-<near>-Indira-Nagar-2nd-Stage/ct-597637" title="Lounge Bars in Indira-Nagar-2nd-Stage, Bangalore">Lounge Bars</a>
<!-- <li class="spc"></li> -->
<li>
<a onclick="_ct('alsocat', 'dtpg', '17592186044416');" href="http://www.justdial.com/Bangalore/Microbrewery-Pubs-<near>-Indira-Nagar-2nd-Stage/ct-1041785821" title="Microbrewery Pubs in Indira-Nagar-2nd-Stage, Bangalore">Microbrewery Pubs</a>
<!-- <li class="spc"></li> -->
<li>
<a onclick="_ct('alsocat', 'dtpg', '17592186044416');" href="http://www.justdial.com/Bangalore/Nightlife-Restaurants-<near>-Indira-Nagar-2nd-Stage/ct-1041746883" title="Nightlife Restaurants in Indira-Nagar-2nd-Stage, Bangalore">Nightlife Restaurants</a>
<!-- <li class="spc"></li> -->
<li>
<a onclick="_ct('alsocat', 'dtpg', '17592186044416');" href="http://www.justdial.com/Bangalore/Foodie-Delight-<near>-Indira-Nagar-2nd-Stage/ct-1041818989" title="Foodie Delight in Indira-Nagar-2nd-Stage, Bangalore">Foodie Delight</a>
<!-- <li class="spc"></li> -->
<!-- <li class="spc"></li> -->
<!-- <li class="spc"></li> -->
<!-- <li class="spc"></li> -->
<li>
<a href="javascript:void(0);" onclick="_ct('morlstdin', 'dtpg');
openDiv('alsp');">more...</a>
</li>
</ul>
</div>
<div class="mreinfwpr">
<p class="mreinfp">Services</p>
<span class="srihd">General</span>
<ul class="alstdul">
<!-- <tr > -->
<li><img class="srimg" src="http://www.justdial.com/public/images/icon/bar.png" width="20" height="20" /><span class="sritxt">Bar </span></li>
<!-- <td class="spc"></td> -->
<li><img class="srimg" src="http://www.justdial.com/public/images/icon/checkmarkNew.png" width="20" height="20" /><span class="sritxt">Outdoor Seating </span></li>
<!-- </tr> -->
<!-- <tr > -->
<li><img class="srimg" src="http://www.justdial.com/public/images/icon/checkmarkNew.png" width="20" height="20" /><span class="sritxt">Alcohol </span></li>
<!-- <td class="spc"></td> -->
<li><img class="srimg" src="http://www.justdial.com/public/images/icon/checkmarkNew.png" width="20" height="20" /><span class="sritxt">AC </span></li>
<!-- </tr> -->
<!-- <tr class="reset" > -->
<li><img class="srimg" src="http://www.justdial.com/public/images/icon/checkmarkNew.png" width="20" height="20" /><span class="sritxt">WiFi </span></li>
<!-- <td class="spc"></td> -->
<li><img class="srimg" src="http://www.justdial.com/public/images/icon/checkmarkNew.png" width="20" height="20" /><span class="sritxt">Dinein </span></li>
<!-- </tr> -->
</ul>
</div>
<div class="mreinfwpr">
<p class="mreinfp">Modes of Payment</p>
<ul class="alstdul">
<li>Cash</td>
<!-- <td class="spc"></td> -->
<li>Master Card</td>
</li>
<li>Visa Card</td>
<!-- <td class="spc"></td> -->
<li>Debit Cards</td>
</li>
<li>Credit Card</td>
<!-- <td class="spc"></td> -->
</div>
<div class="mreinfwpr">
<p class="mreinfp">Year Established</p>
<ul class="alstdul">
<li> 2010</li>
</ul>
</div>
i want data which are in "also listed in" category. i.e:
Also Listed in
Pubs
Pizza Outlets
Restaurants
Lounge Bars
Microbrewery Pubs
Nightlife Restaurants
Foodie Delight
more...
i tried using :
also_listed_in=bSoup.findAll("a", { "onclick" : "_ct('alsocat', 'dtpg', '17592186044416');" })
I was able to obtain the required data. But the problem is that the attribute within the "a" tag, i.e., onclick = _ct('alsocat', 'dtpg', '17592186044416')
keeps changing with different url of same kind. But I've observed that _ct('alsocat', 'dtpg' part of _ct('alsocat', 'dtpg', '17592186044416') is same for all similar urls.
Please help me obtain the required data.
You can use the part of the onclick text that does not change to get what you want:
from bs4 import BeautifulSoup
import re
soup = BeautifulSoup(html)
print(soup.find_all("a",onclick=re.compile(r"_ct\('alsocat', 'dtpg'")))
If _ct('alsocat' is unique to those urls then you can just use a css startswith selector:
print(soup.select("a[onclick^=_ct('alsocat']"))

XSLT transform cross placed tags

I'm new to XSLT and I need to transform cross placed tags like:
<tabbable>
<tab name="tabname1"><content1></content1></tab>
<tab name="tabname2"><content2></content2></tab>
<tab name="tabname3"><content3></content3></tab>
</tabbable>
transform to:
<div>
<ul>
<li>tabname1</li>
<li>tabname2</li>
<li>tabname3</li>
</ul>
<div class="baltab">
<div><transformed-content1/></div>
<div><transformed-content2/></div>
<div><transformed-content3/></div>
</div>
</div>
Unfortunately I can't find detailed tutorials for XSLT.
The solution is simplest as i first think:
Only needs two for-each cycle, with right element selected:
input:
<?xml version="1.0" encoding="ISO-8859-1"?>
<tabbedpane>
<tab text="tablabel1">
<label text="tabcontent1"/>
</tab>
<tab text="tablabel2">
<label text="tabcontent2"/>
</tab>
<tab text="tablable3">
<label text="tabcontent3"/>
</tab>
the transform xml:
<xsl:template match="tabbedpane">
<div class="LFT tabbable">
<ul class="nav nav-tabs">
<xsl:for-each select="tab">
<li class="tab_label">
<xsl:value-of select="#text"/>
</li>
</xsl:for-each>
</ul>
<div class="tabs_holder">
<xsl:for-each select="tab">
<div class="single_tab">
<xsl:apply-templates/>
</div>
</xsl:for-each>
</div>
</div>
</xsl:template>
<xsl:template match="label">
<h6>
<xsl:if test="#id">
<xsl:attribute name="id">
<xsl:value-of select="#id" />
</xsl:attribute>
</xsl:if>
<xsl:value-of select="#text"/>
</h6>
</xsl:template>
and the result is:
<div class="LFT tabbable">
<ul class="nav nav-tabs">
<li class="tab_label">tablabel1</li>
<li class="tab_label">tablabel2</li>
<li class="tab_label">tablable3</li>
</ul>
<div class="tabs_holder">
<div class="single_tab">
<h6>tabcontent1</h6>
</div>
<div class="single_tab">
<h6>tabcontent2</h6>
</div>
<div class="single_tab">
<h6>tabcontent3</h6>
</div>
</div>
</div>
As i needed.