|
You were almost there with your second effort:
sum(/books/book[title[@genre = 'fiction']]/price[. < 30])
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Using dot .& lt;30 seems to be working too and less confusing instead of number(text()).
Thanks for your reply.
|
|
|
|
|
Hello,
I'd like to make a project that has DOM support. I'm thinking of using Xerces. What I'd like too is to have a API to access the same DOM implementation both in C++ and JAVA..... I mean, some apps will use it through C++, others in Java, while the rest of the library will be C++. Is Xerces a good solution for that? As I see there are both Java and C++ bindings, will this help achieve what I need?
|
|
|
|
|
AFAIK the two Xerces (C++/Java) implementations are completely separate. It sounds like you have read something that says they are one implementation, could you supply a link to that?
gotchagotcha wrote: What I'd like too is to have a API to access the same DOM implementation both in C++ and JAVA
Why? The whole point is that the DOM is the standard and therefore the API's are mostly identical. Designing your applications with a DAL probably provides a much larger benefit than sharing a DOM implementation.
Also to use native code from Java requires the use of JNI so you can't directly utilize a C++ anything by writing pure Java code. Anyway if you are bent on doing this I suppose you could provide the JNI wrappers for the C++ Xerces DOM. It seems pointless to me but whatever.
|
|
|
|
|
Hi All,
I am writing the following code
"<a href="{@FileRef}" > <xsl:value-of select="@Title" />
</a>"
The problem is that my "FileRef" contains special character in it (like test's.aspx, the single quotes in it).In the browser the URL is shown as
test's.aspx.
Is there any work around for this.
I don't know how to handle the unsafe character in xslt.
Thanks in Advance
Alok....
modified on Wednesday, April 15, 2009 10:39 AM
<div class="ForumMod">modified on Wednesday, April 15, 2009 10:43 AM</div>
|
|
|
|
|
IMHO, I would avoid using "special" characters and white space in a URL since it always gets URL-encoded. In your case, the single quote will be change to %28 . Besides, since XSLT is really XML, you can use " instead of ' . Please note that you can place characters such as a single quote in CDATA sections!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
please help me....
how can i convert data set to xml according to my DTD
R RajaGuru
|
|
|
|
|
Do you know what a DTD is, and why do you need to use one? If you have the answers to these questions, you should know what to do.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
|
hi all
This is to read the tag line by line.
using System.Xml;
...
...
...
XmlTextReader reader = new XmlTextReader ("reader.xml");
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
Console.Write("<" + reader.Name);
Console.WriteLine(">");
break;
case XmlNodeType.Text: //Display the text in each element.
Console.WriteLine (reader.Value);
break;
case XmlNodeType.EndElement: //Display the end of the element.
Console.Write("</" + reader.Name);
Console.WriteLine(">");
break;
}
}
Console.ReadLine();
How do i read the specific tag
if i just want to read all the tag that have this < big > tag?
thank you
|
|
|
|
|
This might help you get started:
reader.ReadToFollowing("big");
do
{
} while (reader.ReadToNextSibling("big"));
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
You can use XPath to simplify your work. For example:
XmlDataDocument xmlDoc = new XmlDataDocument();
xmlDoc.Load("yourfile.xml");
XmlNodeList xmlNodeList = xmlDoc.SelectNodes("roottag/big"); //XPath expression
More detail information pls. refer to Microsoft MSDN.
|
|
|
|
|
Unfortunately, our poster is using XmlTextReader . You don't use XPath with that.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi all,
Can you please let me know how to change the following XML so that i have HOME and SERVICES as parent node.At the moment HOME Contains SERVICES as a Sub Node.
What i want is When i click on Home the Service Link shouldnt be hidden.
<?xml version="1.0" encoding="utf-8" ?>
<siteMap>
<siteMapNode title="Home" >
<siteMapNode title="Services" >
<siteMapNode title="Training" url="~/Training.aspx"/>
</siteMapNode>
</siteMapNode>
</siteMap>
Thank you In advance.
|
|
|
|
|
kibromg wrote: What i want is When i click on Home the Service Link shouldnt be hidden.
I don't know if anyone will understand your post, I know I don't. XML is text so when you click on it nothing is going to happen.
My guess is you left some stuff out of your post under the mistaken notion that we already know what you are thinking and doing, we don't, that's not really how internet forums work. Or perhaps you don't know anything about XML yourself. If that is the case try some of the tutorials at www.w3schools.com
|
|
|
|
|
I'm using an XMLDataSource to pull rss feeds into my site. Some of the feeds have really long descriptions, so I'd like to limit the length of the description fields, and then append a "..." to the end.
Is there any way to do that?
|
|
|
|
|
Found solution. Here's ASP.net code in case it helps anyone else:
<pre> <asp:DataList ID="DataList1" runat="server" DataSourceID="XmlDataSource1" BackColor="#333333"
BorderStyle="None" GridLines="Vertical" BorderColor="#333333" BorderWidth="0px">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#XPath("pubDate")%>' Font-Names="Verdana" Font-Size="XX-Small"></asp:Label><br />
<asp:HyperLink ID="HyperLink1" runat="server" Text='<%#XPath("title")%>' NavigateUrl='<%#XPath("link")%>' Target="_blank" Font-Names="Verdana" Font-Size="Small"></asp:HyperLink><br />
<asp:Label ID="description_label" runat="server" Text='<%#XPath("description")%>'></asp:Label><br />
<br />
</ItemTemplate>
</asp:DataList>
Here's the code behind:
<pre> Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound
Dim ShortDescriptionLabel As Label = CType(e.Item.FindControl("description_label"), Label)
If ShortDescriptionLabel.Text.Length > 200 Then
ShortDescriptionLabel.Text = ShortDescriptionLabel.Text.Substring(0, 200) & "..."
End If
ShortDescriptionLabel.Text = ShortDescriptionLabel.Text
End Sub
|
|
|
|
|
hi im doing a small project for friend.. i need to get the data out of xml so that i can verify the username and password
xml is like this
PLEASE HELP THE ERROR I GET IS EXPLAINED IN THE MIDDLE.. THANKS ALOTTTT
<clientlogind>
<client username="faizych">
Password="pass"
/>
<client username="taha89">
Password="pass78"
/>
and to get the value im doing
private void button1_Click(object sender, EventArgs e)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load("path.xml");
System.Xml.XmlNodeList client;
XmlNode clientNode = xmldoc.DocumentElement;
client = clientNode.SelectNodes("Client");
string Usernamttext = txtUsername.Text;
string passwordtext = txtpassword.Text;
foreach (XmlNode DataNode in client)
{
string userid;
string password;
************************************************************************************************
******* ERROR HERE*** now when i run it it gives me an error when it gets to the line below that """object reference not set to an instance of an object"""
*************************************************************************************************
userid = DataNode.SelectSingleNode("Username").InnerText.Trim();
password = DataNode.SelectSingleNode("password").InnerText.Trim();
if (string.Compare(Usernamttext, userid) == 0)
{
if (string.Compare(passwordtext, password) == 0)
{
break;
UserProfile UserProfileForm = new UserProfile();
UserProfileForm.usernamevalue = userid;
UserProfileForm.Show();
this.Close();
}
else
{
MessageBox.Show("Invalid Username or password");
}
}
}
}
|
|
|
|
|
Your error has nothing to do with XML itself.
The call to DataNode.SelectSingleNode probably returns null. In fact, directly calling methods on method calls that are prone to return null is one of the worst coding habit someone can have.Here is what a good programmer would have done:
userid = DataNode.SelectSingleNode("Username");
if ((userid != null) && (!String.IsNullOrEmpty(userid.InnerText))
{
}
else
{
throw new NoUsernameNodeException();
}
Not checking for null values before using object references is one the worst thing to do, always leading to obscure error message "Object reference not set to an object".
|
|
|
|
|
I was hoping someone could give me a hand with this. I'd like to convert a standard XML file into one that groups the data by one of the data elements.
Here is a sample of data I'd be using:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Inventory>
<Item>
<producttype>Book</producttype>
<productname>A Connecticut Yankee in King Arthur's Court</productname>
<artistfirstname>Mark</artistfirstname>
<artistlastname>Twain</artistlastname>
<description>A Connecticut Yankee travels back to King Arthur's court and adventure ensues. Fun, fun, fun.</description>
<company>Pocket Books</company>
<year>1889</year>
<productid>978-1416534730</productid>
<price>4.95</price>
<image/>
</Item>
<Item>
<producttype>Book</producttype>
<productname>A Farewell To Arms</productname>
<artistfirstname>Ernest</artistfirstname>
<artistlastname>Hemingway</artistlastname>
<description>The tragic tale of love and loss during WWI.</description>
<company>Charles Scribner's Sons</company>
<year>1929</year>
<productid>978-0684837888</productid>
<price>18.15</price>
<image href="file://images/978-0684837888.jpg"/>
</Item>
<Item>
<producttype>Book</producttype>
<productname>A Portrait of the Artist as a Young Man</productname>
<artistfirstname>James</artistfirstname>
<artistlastname>Joyce</artistlastname>
<description>A a fictionalized memoir of Joyce's alter ego, Stephen Daedelus, describing his coming of age in Dublin.</description>
<company>Everyman's Library</company>
<year>1916</year>
<productid>978-0679405757</productid>
<price>14.25</price>
<image href="file://images/978-0679405757.jpg"/>
</Item>
<Item>
<producttype>Audiobook</producttype>
<productname>A Tale of Two Cities</productname>
<artistfirstname>Charles</artistfirstname>
<artistlastname>Dickens</artistlastname>
<description>Classic telling of life in two cities, London and Paris, during the upheaval of the French Revolution.</description>
<company>Blackstone Audiobooks</company>
<year>2005</year>
<productid>978-0786180394</productid>
<price>19.77</price>
<image href="file://images/978-0786180394.jpg"/>
</Item>
<Item>
<producttype>Audiobook</producttype>
<productname>Anna Karenina</productname>
<artistfirstname>Leo</artistfirstname>
<artistlastname>Tolstoy</artistlastname>
<description>Audiobook version of the intricate intrigue of love and scandal in high society of Czarist Russia.</description>
<company>Naxos Audiobooks</company>
<year>1999</year>
<productid>978-9626340813</productid>
<price>20.55</price>
<image href="file://images/978-9626340813.jpg"/>
</Item>
</Inventory>
I'd like to end up with something like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Inventory>
<category>
<type>Book</type>
<Item>
<productname>A Connecticut Yankee in King Arthur's Court</productname>
<artistfirstname>Mark</artistfirstname>
<artistlastname>Twain</artistlastname>
<description>A Connecticut Yankee travels back to King Arthur's court and adventure ensues. Fun, fun, fun.</description>
<company>Pocket Books</company>
<year>1889</year>
<productid>978-1416534730</productid>
<price>4.95</price>
<image/>
</Item>
<Item>
<productname>A Farewell To Arms</productname>
<artistfirstname>Ernest</artistfirstname>
<artistlastname>Hemingway</artistlastname>
<description>The tragic tale of love and loss during WWI.</description>
<company>Charles Scribner's Sons</company>
<year>1929</year>
<productid>978-0684837888</productid>
<price>18.15</price>
<image href="file://images/978-0684837888.jpg"/>
</Item>
<Item>
<productname>A Portrait of the Artist as a Young Man</productname>
<artistfirstname>James</artistfirstname>
<artistlastname>Joyce</artistlastname>
<description>A a fictionalized memoir of Joyce's alter ego, Stephen Daedelus, describing
his coming of age in Dublin.</description>
<company>Everyman's Library</company>
<year>1916</year>
<productid>978-0679405757</productid>
<price>14.25</price>
<image href="file://images/978-0679405757.jpg"/>
</Item>
</category>
<category>
<type>Audiobook</type>
<Item>
<productname>A Tale of Two Cities</productname>
<artistfirstname>Charles</artistfirstname>
<artistlastname>Dickens</artistlastname>
<description>Classic telling of life in two cities, London and Paris, during the
upheaval of the French Revolution.</description>
<company>Blackstone Audiobooks</company>
<year>2005</year>
<productid>978-0786180394</productid>
<price>19.77</price>
<image href="file://images/978-0786180394.jpg"/>
</Item>
<Item>
<productname>Anna Karenina</productname>
<artistfirstname>Leo</artistfirstname>
<artistlastname>Tolstoy</artistlastname>
<description>Audiobook version of the intricate intrigue of love and scandal in high
society of Czarist Russia.</description>
<company>Naxos Audiobooks</company>
<year>1999</year>
<productid>978-9626340813</productid>
<price>20.55</price>
<image href="file://images/978-9626340813.jpg"/>
</Item>
</category>
</Inventory>
Does anyone know how to write an XSLT to create this kind of grouping?
If you have any suggestions, I'd entertain any options.
Thanks
|
|
|
|
|
blindcapt wrote: Does anyone know how to write an XSLT to create this kind of grouping?
What kind of grouping? I'm not going to reverse engineer your XML to decipher the problem statement for you. If you understand your problem clearly, you should have no trouble stating it in a post.
|
|
|
|
|
Each record contains these elements: producttype, productname, productid, productprice
I want the elements to group under the producttype element, such as:
Original:
<products>
<item>
producttype
productname
productid
productprice
</item>
<item>
producttype
productname
productid
productprice
</item>
</products>
Desired:
<products>
<category>
<producttype></producttype>
<item>
productname
productid
productprice
</item>
<item>
productname
productid
productprice
</item>
</category>
<category>
<producttype></producttype>
<item>
productname
productid
productprice
</item>
<item>
productname
productid
productprice
</item>
</category>
</products>
|
|
|
|
|
The technique for this is known as the Muenchian Method (or Muenchian grouping[^]) and it involves the use of xsl:key in a rather clever way.
I just love Koalas - they go great with Bacon.
|
|
|
|
|
Hey all,
Are the following three XPath expression equivalent?
resolve-uri(@url)
resolve-uri(@url, base-uri(.))
resolve-uri(@url, static-base-uri())
Cheers!
Lea Hayes
|
|
|
|
|
I need to extract some results from a XML file. The XML sort of like the below (each day has a record). The results are expected to be imported into a table with four columns (Month, Total rain for each month, highest temp for each month, lowest tem for each month) and 12 rows (for each month).
Can anyone help to provide some solutions? how to retrive and do simply calculation for this scenario? Many thanks.
<climatedata>
<lang>ENG</lang>
<stationdata day="1" month="1" year="2008">
<maxtemp description="Maximum Temperature" units="°C">8.80</maxtemp>
<mintemp description="Minimum Temperature" units="°C">3.90</mintemp>
<meantemp description="Mean Temperature" units="°C">6.40</meantemp>
<totalrain description="Total Rain" units="mm">0.00</totalrain>
<totalsnow description="Total Snow" units="cm">0.00</totalsnow>
<totalprecipitation description="Total Precipitation" units="mm">0.00</totalprecipitation>
<snowonground description="Snow on Ground" units="cm">0.00</snowonground>
<dirofmaxgust description="Direction of Maximum Gust" flag="E" units="10's Deg">6.00</dirofmaxgust>
<speedofmaxgust description="Speed of Maximum Gust" flag="E" units="km/h">54.00</speedofmaxgust>
<heatdegdays description="Heating Degree Days" units="°C">11.60</heatdegdays>
<cooldegdays description="Cooling Degree Days" units="°C">0.00</cooldegdays>
</stationdata>
modified on Tuesday, March 31, 2009 12:49 PM
|
|
|
|