|
I would like to convert the text data to uppercase and I wrote the expression as below
"/RawData/page/text[upper-case(.)='ABC']" its throwing an exception "XsltContext is needed for this query because of an unknown function"
Reference:
http://www.w3schools.com/xpath/xpath_functions.asp
a
|
|
|
|
|
problem solved with translate function.
textNode = docRawData.SelectSingleNode("/RawData/page/text[translate(text(),\"abcdefghijklmnopqrstuvwxyz\",\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\")='" + rows[n].Trim() + "']");
|
|
|
|
|
Hi,
I'm trying to get the text element which contains value 1.345%, I tried as below to get the results. but the nodeList count is 0. please correct to get the correct results
XmlNodeList nodeList = rawData.SelectNodes("/RawData/page/text[.=<![CDATA[1.345%]]>");
If the value is simple text or integer, its working fine with the below code.
XmlNodeList nodeList = rawData.SelectNodes("/RawData/page/text[.='corporation'");
|
|
|
|
|
Both examples are missing a right square backet. If your second example works though then that wouldn't be the cause. But you should still fix it.
Instead the problem is that you can't treat CDATA like that. At least googling suggests you can't.
|
|
|
|
|
I just forgot to put right square bracket. what to do, to make it work with the value "10.5%" instead "corporation". Thanks in advance
XmlNodeList nodeList = rawData.SelectNodes("/RawData/page/text[.='corporation']");
|
|
|
|
|
I found that the problem is not with "%". The values is having extra spaces as " 10.34%"
So the below expression is not working.
"/Data/page/content[.='10.34%']".
its working with the expression "/Data/page/content[.=' 10.34%']".
Please guide me to solve this issue. Thanks in advance
<Data>
<page>
<content> 10.34%</content>
</page>
</Data>
|
|
|
|
|
Issued solved with the below expression
"/Data/page/content[normalize-space(.)='10.34%']".
|
|
|
|
|
Hello
I have question how can I put condition in my programming in windows phone application?
for example, if I want but code for help user when use my application the users cannot add number more than 80 in text box how I do it ?
Could you please help me !!!!
Kind regards 
|
|
|
|
|
Sounds like you are trying to add range validation to a textbox, but I doubt you are working with XML/XSL. See the forum list to find the forum appropriate for your question. Or you can ask a question in the general "Quick Answers" forum.
Martin Fowler wrote: Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
|
|
|
|
|
You could have posted this in a C# forum, you can get an answer much quciker than here. Make sure you are in the right place before posting a question.
Try this:
try
{
Int32 number = Int32.Parse(txtBoxId.Text);
if(number <= 80)
{
}
else
{
}
}
catch(Excemption e)
{
throw new Excemption("Not a valid interger!");
}
That's a basic function you need, you can call this function on your desired textbox events e.g. on onkeypress.
Hope this helps,
Morgs
|
|
|
|
|
|
Hi, I am having a problem in displaying XML in HTML as shown below -
XML:-
<ABC>
<DEF>
<GHI>Heading</GHI>
<P/> Hello, How are you?
<P/> I am a Developer.
</DEF>
</ABC>
XSLT:-
?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>xml to html</h2>
<table border="0">
<xsl:for-each select="ABC/DEF">
<tr>
<td><xsl:value-of select="GHI" /></td><br/>
<td><xsl:value-of select="." /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
OUTPUT -
Heading
HeadingHello, How are you?I am a Developer.
I want Heading to be in line 1 and then a line break and then comes paragraph. Also i want a space/line break between two paragraphs.
How to get following output instead -
Heading
Hello, How are you?
I am a Developer.
Thanks
Andyyy
|
|
|
|
|
Your HTML is faulty.
<table>
<xsl:for-each select="ABC/DEF">
<tr><td><xsl:value-of select="GHI"/></td></tr>
<xsl:for-each select="p">
<tr><td>
<xsl:value-of select="."/>
</td></tr>
</xsl:for-each>
</xsl:for-each>
</table>
You're using columns (TD) instead of rows (tr).
Also, change your XML to:
<GHI>Heading</GHI>
<p>Hello, How are you?</p>
<p>I am a Developer.</p>
|
|
|
|
|
Thanks for your reply.
I agree with you about HTML part.
But this part of your suggested code doesn't work as it doesn't display paragraphs -
<xsl:for-each select="p">
<tr><td>
<xsl:value-of select="."/>
</td></tr>
</xsl:for-each>
The problem is, i have received XML from third party and there are hundreds of XML that needs to be displayed on webpage and everywhere they have used
<p/>
Paragraph 1
<p/>
Paragraph 2
So should i ask the client to produce XML correctly or is there any work around to be able to display each paragraph in separate line.
Thanks
|
|
|
|
|
You need to identify the inline paragraph and break up the output based on this. I'm platying with the idea but am getting stuck around mixing up carriage returns and line feeds, grrr!
Rhys
"Technological progress is like an axe in the hands of a pathological criminal"
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe"
|
|
|
|
|
If you can get them to parse it correctly, great. Otherwise, try yours again with the right HTML code to see if it can work. I wasn't able to get it myself.
|
|
|
|
|
Have you tried something like this:
<xsl:template match="*|text()">
<xsl:value-of select="."/>
</xsl:template>
And then where you have this:
<xsl:for-each select="ABC/DEF">
<tr>
<td><xsl:value-of select="GHI" /></td><br/>
<td><xsl:value-of select="." /></td>
</tr>
replace the second
<td> line:
<td><xsl:apply-templates/></td>
Edit: sorry, fixed the formatting
|
|
|
|
|
Thanks,
Just tried it but doesn't work -
Here is the html/javascript I am using to call xml and xsl - just incase there is some problem in script instead:-
<html>
<head>
<script type="text/javascript">
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send("");
return xhttp.responseXML;
}
function displayResult()
{
xml=loadXMLDoc("test.xml");
xsl=loadXMLDoc("test.xsl");
if (window.ActiveXObject)
{
ex=xml.transformNode(xsl);
document.getElementById("example").innerHTML=ex;
}
else if (document.implementation && document.implementation.createDocument)
{
xsltProcessor=new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
resultDocument = xsltProcessor.transformToFragment(xml,document);
document.getElementById("example").appendChild(resultDocument);
}
}
</script>
</head>
<body onLoad="displayResult()">
<div id="example" />
</body>
</html>
Thanks
|
|
|
|
|
 The below is not perfect but is getting there. Unfortunately I need to leave the office soon but hope it helps...
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Updated Template</title>
</head>
<body>
<table border="0">
<xsl:for-each select="ABC/DEF">
<tr>
<td><xsl:value-of select="GHI" /></td>
</tr>
<tr>
<td>
<xsl:variable name="inStr" select="."></xsl:variable>
<xsl:variable name="outStr">
<xsl:call-template name="template2">
<xsl:with-param name="parameter2" select="$inStr"/>
</xsl:call-template>
</xsl:variable>
<xsl:copy-of select="$outStr"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template name="template2">
<xsl:param name="parameter2"/>
<xsl:choose>
<xsl:when test="contains($parameter2,'')">
<xsl:value-of select="substring-before($parameter2,'')"/><p/>
<xsl:call-template name="template2">
<xsl:with-param name="parameter2">
<xsl:value-of select="substring-after($parameter2,'')"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$parameter2"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Rhys
"Technological progress is like an axe in the hands of a pathological criminal"
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe"
|
|
|
|
|
Thanks goblinTech,
It's getting there - output am getting is
Heading
Heading
Hello,
How
are
you?
I
am
a
Developer.
I will keep trying.
Thanks for your help.
|
|
|
|
|
You would find this so much easier if your xml was actually xml rather than just having a .xml extension and being a mixture of xml, html and plain text.
I would just tell the client to supply proper input if they want proper output. But then I tend to work for captive clients which makes life a lot easier.
Every man can tell how many goats or sheep he possesses, but not how many friends.
|
|
|
|
|
You are absolutely right. I just tried placing proper p tags and tried Bassam Abdul-Baki's solution and that works like a charm.
It's just this
<p/> , that's causing problem.
I just wanted to give it a go, if it's easily doable before I go back to my boss and suggest him to ask the client to provide proper XML and I have already wasted enough of my time.
Will try for another 30 mins and then no chance.. 
|
|
|
|
|
Even if you get it to work, you should let your boss know that the XML was not well-formed so that they fix it for future usage. The tags in XML are there for a reason. You shouldn't have to say I want the text after the empty tag when technically the empty tag was meant to be just empty.
|
|
|
|
|
just read the specification and it's written
DATA FORMAT
Available in XML valid against a Datapharm DTD
I am not sure how it's valid against DTD, when it's not well formed. 
|
|
|
|
|