[XML] XML, XSL,CSS mess

Source: Internet
Author: User
Tags compare xml files datetime version thread xmlns xsl
Css|xml

Made a little piece of XML. Communicate with everyone.
Three files. (Blue.xml blue.xsl blue.css) to the local same directory.

Blue.xml:

<?xml version= ' 1.0 ' encoding= ' GB2312 '?>
<?xml:stylesheet type= ' text/xsl ' href= ' blue.xsl '?>
<Topic>
<Issue>
<TopicId>000001</TopicId>
<UserName>ycoe12</UserName>
<RankName> Super User </RankName>
The problem of <topicname>[jsp]servlet thread </TopicName>
<datetime>2005-12-26 01:03:44</datetime>
<ReplyNum>2</ReplyNum>
<ReadNum>68</ReadNum>
<Content> How do I implement threading in a servlet? For example, with two threads, let one thread communicate with another thread.
My method: Implements Runnable. Let it sleep immediately after the build. But I don't know how to get another thread to notify this thread when it's finished?? (communication between two requests)
I want to judge the process of another thread by detecting httpsession. But it doesn't seem so good ...
Thank you </Content>
</Issue>
<Replys>
<Reply>
<TopicID>000001</TopicID>
<UserName> Red Hacker </UserName>
<RankName> Classic Killers </RankName>
<ReplyID>0001</ReplyID>
<Content> this should be synchronized with thread?? </Content>
<datetime>2005-12-26 13:22:15</datetime>
</Reply>
<Reply>
<TopicId>000001</TopicId>
<UserName>ycoe12</UserName>
<RankName> Super User </RankName>
<ReplyID>0002</ReplyID>
<Content> No, it simply means to notify another thread when it is finished with one thread ... No, simply to tell another thread when it's finished with one thread ... No, simply to tell another thread when it's finished with one thread ... </Content>
<datetime>2005-12-26 20:41:51</datetime>
</Reply>
</Replys>
</Topic>

Blue.xsl:

<?xml version= "1.0" encoding= "GB2312"?>
<!--
<xsl:stylesheet version= "1.0" xmlns:xsl= "Http://www.w3.org/1999/XSL/Transform" >
<xsl:output method= "html" encoding= "gb2312" version= "4.0"/>
-->
<xsl:stylesheet version= "1.0" xmlns:xsl= "http://www.w3.org/TR/WD-xsl" >
<xsl:template match= "text ()" >
<xsl:value-of/>
</xsl:template>
<xsl:template match= "/" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title><xsl:value-of select= "Topic/issue/topicname"/></title>
<link rel= ' Stylesheet ' href= ' blue.css ' type= ' text/css '
<body>
<div id= "Divframe" >
<div id= "Divtitle" >
<span id= "Spantitleleft" ><xsl:value-of select= "Topic/issue/topicname"/></span>
<span id= "Spantitleright" > Author: <xsl:value-of select= "Topic/issue/username"/> | <xsl:value-of select= "Topic/issue/rankname"/>| Publish time: <xsl:value-of select= "Topic/issue/datetime"/></span>
</div>
<div id= "Divmain" >
<xsl:apply-templates select= "Topic/issue/content"/>
</div>
<div id= "Divreply" >
<xsl:apply-templates select= "Topic/replys"/>
</div>
</div>
</body>
</xsl:template>
<xsl:template match= "Replys" >
<xsl:for-each select= "Reply" >
<div>
<div id= "Replyperson" > Reply person: <xsl:value-of select= "UserName"/> | <xsl:value-of select= "Rankname"/>|</div>
<div><xsl:apply-templates select= "Content"/></div>
<div> Publish time: <xsl:value-of select= "DateTime"/></div>
</div>
</xsl:for-each>
</xsl:template>
<xsl:template match= "Content" >
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>

BLUE.CSS:

Body
{
Text-align:center;
Background-color: #ffffff;
}
Div
{
Font-family:verdana;
Text-align:left;
}
#divFrame
{
Background-color: #CCCCCC;
width:95%;
padding:8px;
}
#divTitle
{
Background-color: #F7F3F7;
BORDER:1PX solid black;
width:100%;
font-size:16px;
Font-weight:bold;
line-height:30px;
Color: #0051A5;
padding-left:10px;
}
#divMain
{
font-size:14px;
margin-top:5px;
BORDER:1PX solid black;
padding:10px;
Background-color:white;
}
#divReply
{
Background-color: #ffffff;
margin-top:5px;
margin-bottom:5px;
BORDER:1PX solid black;
width:100%;
font-size:9pt;
padding:10px;
letter-spacing:2px;
line-height:24px;
}
#spanTitleLeft
{
Float:left;
}
#spanTitleRight
{
Font-weight:normal;
font-size:12px;
Float:right;
padding-right:10px;
}
#replyPerson {
border-bottom:1px solid #0066cc;
Background-color: #f1f5fa;
}

(I've seen someone do a similar electronic document before.) XML is more of a data file, using XML we can separate content from style if we compare XML files to structured raw materials. So XSL is like "sieve" and "mold", the sieve selects the raw material that it needs, and these materials form the final product through the mold. The model is roughly the same: we first design the performance page, then remove the part of the content that needs to be fetched from the XML, and then use the XSL statement to sift out the relevant data from the XML to populate it.

XML in the expansion is a tree structure, the tree structure of custom tags called nodes, there is a parent-child relationship between the nodes, to access the nodes from the root node must be "/" to enter the layer.

How to extract relevant data from XML requires the use of the modal query language provided by XSL. is a specific statement that extracts data from XML using the relevant pattern-matching rule expression, the "sieve" described above.

Select mode:
<xsl:for-each>, <xsl:value-of> and <xsl:apply-templates>

Match mode:
<xsl:template>

<xsl:template match= "Replys" >
<xsl:for-each select= "Reply" >
<div>
<div id= "Replyperson" > Reply person: <xsl:value-of select= "UserName"/> | <xsl:value-of select= "Rankname"/>|</div>
<div><xsl:apply-templates select= "Content"/></div>
<div> Publish time: <xsl:value-of select= "DateTime"/></div>
</div>
</xsl:for-each>
</xsl:template>

Simply put this paragraph:

The XSL template refines the design of the XSL into a template (block) Finally, the templates (blocks) are combined into a complete XSL; like ships and containers, we don't pile up all the goods in pieces, we load them in separate containers and then pile them up on the ship. This method allows you to consider the overall design of the entire XSL, and then a number of forms into different modules, and then specifically design these modules, and finally integrate them together, so that the macro and micro, in line with the people of the Organization, standardization requirements.

Loading container--writing template (block):<xsl:template>
<xsl:template match= "Replys" >
match── determine what circumstances to execute this template. is the name of the mark;
The top-level template must set the match to "/".
<xsl:template> using the match attribute to select nodes satisfying the condition from XML, in the true pair of these specific nodes formed
A template for a particular output form.

<xsl:for-each select= "Reply" > Cycle selection.
Select: Determine what template should be executed in this context, that is, select the template (block) that was established with the < Xsl:template > tag.
<xsl:value-of> Direct output selection.
Call Template (block): <xsl:apply-templates select= "Content"/>
Call XSL last paragraph.
<xsl:template match= "Content" >
<xsl:apply-templates/>
</xsl:template>

Say a lot. Not very polite. Happy New Year to everyone.
Some basic concepts and more references to Microsoft's "XSL Developer Guide":
Www.microsoft.com/china/msdn/Archives/workshop/xmlfaq.asp



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.