Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML + XSL ----> HTML 2

Status
Not open for further replies.

rcodarini

Programmer
Jul 3, 2001
8
IT
Hi!

I've a new problem :( I have an xml file that describes two html frames:

<FRAMES>
<DIMENSION>
<Height>400</Height>
<Width>400</Width>
</DIMENSION>
<FRAME>
<NAME>First Frame</NAME>
<SRC>Source file</SRC>
</FRAME>
<FRAME>
<NAME>Second Frame</NAME>
<SRC>Source file</SRC>
</FRAME>
</FRAMES>

My problem is: if width is < of 300 then the frames are vertical disposed else if Height is < 300 then the frames are horizontally disposed if the Width and the Height are < 300 than I want to write a message that is not possible this solution. I haven't understand how to use logical conditions (if there are)

Thanks
ROb
 
Hello,
Sure you can.
Cite from MSDN:
<xsl:if> - allows simple conditional template fragments.

<xsl:choose>
<xsl:when test=&quot;&quot;> ...</xsl:when>
<xsl:when test=&quot;&quot;> ...</xsl:when>
<xsl:eek:therwise> ...</xsl:eek:therwise>
</xsl:choose>

- provides multiple conditional testing in conjunction with the <xsl:eek:therwise> and <xsl:when> elements.
The <xsl:when> children of the <xsl:choose> element are tested in order from top to bottom until a test attribute on one of these elements accurately describes conditions present in the source data or an <xsl:eek:therwise> element is reached. Once an <xsl:when> or <xsl:eek:therwise> element is chosen, the <xsl:choose> block is exited. No explicit break or exit statement is required.

In your case a little modification in xml file:
<FRAMES>
<DIMENSION>
<Height>200</Height>
<Width>400</Width>
</DIMENSION>
<FRAME>
<NAME>First Frame</NAME>
<SRC>first.html</SRC>
</FRAME>
<FRAME>
<NAME>Second Frame</NAME>
<SRC>second.html</SRC>
</FRAME>
</FRAMES>

and XSL file:

<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;<xsl:template match=&quot;/&quot;>
<html>
<xsl:choose>
<xsl:when test=&quot;//DIMENSION/Width &lt; 300 and //DIMENSION/Height &lt; 300&quot;>
<body>This is not suitabale for frames.</body>
</xsl:when>
<xsl:when test=&quot;//DIMENSION/Width &lt; 300&quot;>
<frameset>
<xsl:attribute name=&quot;cols&quot;><xsl:value-of select=&quot;//DIMENSION/Height&quot;/>,*</xsl:attribute>
<xsl:for-each select=&quot;//FRAME/SRC&quot;>
<frame>
<xsl:attribute name=&quot;src&quot;><xsl:value-of select=&quot;.&quot;/></xsl:attribute>
</frame>
</xsl:for-each>
</frameset>
</xsl:when>
<xsl:when test=&quot;//DIMENSION/Height &lt; 300&quot;>
<frameset>
<xsl:attribute name=&quot;rows&quot;><xsl:value-of select=&quot;//DIMENSION/Width&quot;/>,*</xsl:attribute>
<xsl:for-each select=&quot;//FRAME/SRC&quot;>
<frame>
<xsl:attribute name=&quot;src&quot;><xsl:value-of select=&quot;.&quot;/></xsl:attribute>
</frame>
</xsl:for-each>
</frameset>
</xsl:when>
<xsl:eek:therwise><body>Choose appropriate width or height.</body></xsl:eek:therwise>
</xsl:choose>
</html>
</xsl:template>
</xsl:stylesheet>

I've tested with
Width 100, Height 200
Width 200, Height 400
Width 400, Height 200
Width 400, Height 400


The conditional operators are usual or, and, =, !=, <, <=, >, >=.
And any < and <= operators must be quoted according to XML 1.0 rules by using &lt; and &lt;=.

You have to have also first.html and second.html.

If you have any further questions please ask.
 
O, tek-tips is converting symbols.
It should be
& lt;
& lt;=
without spaces.
 
Thanks for your help...
but now I've got an idea so I explain my problem... I have a MS Digital Dashboard; with the xml file I want to insert two html files in a web part and if the web part is more wide than high the html are disposed orizontally otherwise there are disposed vertically... there is a method to know the dimensions of a web part? (I think that is the same to know the dimensions of a client area of a browser)


Thanks
ROb
 
Hello,
I don't know what exactly MS Dashboard is returning.
But in general you can get dimensions of a web page using clientWidth, clientHeight or offsetWidth, offsetHeight properties.
etc.
Use them in similar way:
<BODY bgcolor=&quot;yellow&quot; onload=&quot;alert(document.body.clientWidth); alert(document.body.offsetWidth)&quot;>
20 pixels diffrence come from scrollbar.

Hope this helps.
D.
 
This code sample does what you want:

<IFRAME ID=&quot;OpenCases&quot; src=&quot;&quot;></IFRAME>
<script language=&quot;Javascript&quot;>
function onload () {
var oFrame = document.all.OpenCases;
oFrame.width = oFrame.offsetParent.offsetWidth;
oFrame.height = oFrame.offsetParent.offsetHeight;
}

DDSC.RegisterForEvent (&quot;urn:schemas-microsoft-com:dhtml&quot;, &quot;onload&quot;, onload);
</script>

-- tom
 
Hi

I have problem.I am having one mainpage.xml and an mainpage.xsl. In mainpage.xsl i have use frames -links.xml.
For links.xml i also have links.xsl.But to work on Weblogic server & using servlets, I want mainpage.xml to handle quicklinks.xsl i.e in xml refernce to two xsl i.e mainpage.xsl and quicklinks.xsl and in the browser view i should see the frames.
How this is possible ?
Jaideep
mail Id- jrdeshpande@rediffmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top