Hi every body, i have a problem to display the
XML node value in XSL file, can any body please help me to solve the problem?
There are some description here:
Actually, i'm doing a web application using
asp, vb, MS Server 2000,
xml, xpath, xsl. From
asp i form a
XML request string and send it to vb. After vb process the data and return the expexted value in a
XML response string. One of the node in the
XML response string is <MessageContent> which is retrieved from the database and the content consist of carriage return and line feed characters.
In vb, i declare a string variable to store the value first, then i assign the string to the
XML node, like belows:
- Code: Select all
Dim objDOM as DOMDocument40
Dim nodeMessageContent As IXMLDOMElement
Dim strContent As String
:
Set nodeMessageContent = objDOM.CreateElement("MessageContent")
nodeMessageContent.Text = strContent
When i debug the code and print the value of nodeMessageContent(nodeMessageContent.nodeTypedVal ue), i'm aware that the carriage return and the line feed characters has been omitted, the returned value is "Hello, every body this is a XSL displaying problem can someone please help me?" This is not my original message, you can see the original string at
XML file below. As i know that this is the
XML normal practices, not a error. So to solve my problem that to remain the carriage return and line feed characters, i'm decided to use this method:
- Code: Select all
:
Dim abytContent() As Byte
:
abytContent = strContent
Set nodeMessageContent = objDOM.createNode("element", _
"MessageContent", "")
nodeMessageContent.dataType = "bin.base64"
nodeMessageContent.nodeTypedValue = abytContent
This is work. Now the value in the node contains the carriage return and line feed characters. This node then append to a parent node and form a
XML response string that consists of a few number of node.
When this
XML string return back to the
asp,
asp will process the output in a XSL file, the schema i define with that specific node is like below:
Schema:
- Code: Select all
:
<xs:element name="MessageContent">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:base64Binary">
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
:
In XSL file, when i retrieve the value of the tag, "MessageContent", it's not work. The method i use is:
XSL:
- Code: Select all
:
<TABLE><TR><TD>
<SPAN>
<xsl:attribute name="class">msgContent</xsl:attribute>
<xsl:value-of select="//MessageContent"/>
</SPAN>
</TABLE></TR></TD>
:
XML File:
- Code: Select all
:
<MessageContent>
Hello, every body
this is a XSL displaying problem
can someone please help me?
</MessageContent>
:
Actually, there is a
HTML tags in the message, the original message is:
- Code: Select all
<Font color="#FF0000">Hello, every body</Font>
this is a XSL displaying problem
<B>can someone please help me?</B>
My expected output is the message content which in the red and bold text.
Anyone please help me.
Thanks a lot