|
Hi all
In my projecr we need to handle the singleclick and doubleclick events ;
when i use single click one action should perform
when i use doubleclick another action should perform
pleae help me
#sanroop#
|
|
|
|
|
And how do you do propose doing it in XML? Wrong question, wrong forum. Which is why you have had no answers.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi,
I am using an XSL file to format a document for display on my website. A content block has a title, and contains HTML content. The references section always appears at the bottom of the rendered document (regardless of its location within the XML file).
<?xml version="1.0"?>
<mydoc>
<content title="Introduction">
...
</content>
<references>
...
</references>
</mydoc>
In the XSL I want to create a contents for the document. I have managed to get the content sections listed in the contents. But I find myself duplicating a large chunk of XSL just to add the references section to the contents.
Is there a way to do something along the lines of the following?
<xsl:variable name="contents-listing">
concatenate
?? Get list of content nodes "/mydoc/content" ??
with
<content title="References">
<references>
...
</references>
</content>
</xsl:variable>
so that I can:
<xsl:for-each select="$contents_listing">
<!-- Clicking an item goes to the corresponding named anchor -->
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('#ref', position())" />
</xsl:attribute>
<xsl:value-of select="@title" />
</a>
</xsl:for-each>
and also:
<xsl:for-each select="$contents-listing">
<!-- Named anchor indicates where to click goes to -->
<a>
<xsl:attribute name="name">
<xsl:value-of select="concat('ref', position())" />
</xsl:attribute>
<xsl:apply-templates />
</a>
</xsl:for-each>
Many thanks,
Lea Hayes
|
|
|
|
|
It's probably easy in XSLT 2, but if you're using XSLT 1 like most of us who are relying on Microsoft tools, avoiding duplicated xsl code ist hard.
Using a workaround pattern I've sometimes applied in such cases it would look like this:
<mydoc>
<content title="Introduction">
<xsl:call-template name="EvaluateContent">
<xsl:with-param name="Context">Contents</xsl:with-param>
</xsl:call-template>
</content>
<references>
<xsl:call-template name="EvaluateContent">
<xsl:with-param name="Context">References</xsl:with-param>
</xsl:call-template>
</references>
</mydoc>
<xsl:template name="EvaluateContent">
<xsl:param name="Context" />
<xsl:for-each select="/mydoc/content">
<xsl:choose>
<xsl:when test="$Context = 'Contents'">
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('#ref', position())" />
</xsl:attribute>
<xsl:value-of select="@title" />
</a>
</xsl:when>
<xsl:when test="$Context = 'References'">
<a>
<xsl:attribute name="name">
<xsl:value-of select="concat('ref', position())" />
</xsl:attribute>
</a>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
This is not nice, and can be further refined, but the only way I know to avoid duplicating the logic contained in the for-each statement.
I don't have the patience right now to adjust the tabs and spaces which don't look right in the preview.
And please be aware that I just copied and pasted it from some old stylesheets of mine and your fragments and have not tested it. There may be syntax errors, but I'm sure you get the gist.
And if any one points out a better pattern, I'll add my thanks to yours.
|
|
|
|
|
Hi,
Thanks for your advice! This has helped me to solve the problem!
Best regards,
Lea Hayes
|
|
|
|
|
Hi,
I'm trying to validate an Xml document using an XmlReader. Here is my code:
private void Validate(TextReader source, string xsd)
{
XmlReaderSettings settings = new XmlReaderSettings();
XmlUrlResolver resolver = new XmlUrlResolver();
settings.ProhibitDtd = false;
resolver.Credentials = CredentialCache.DefaultCredentials;
settings.XmlResolver = resolver;
settings.ValidationFlags = XmlSchemaValidationFlags.ProcessSchemaLocation;
settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
settings.Schemas.XmlResolver = resolver;
settings.Schemas.Add(null, xsd);
settings.Schemas.Compile();
\\settings.Schemas.Add(null, http://www.w3.org/2001/xml.xsd);
settings.ValidationType = ValidationType.Schema;
settings.ValidationEventHandler += ValidationHandler;
XmlReader reader = XmlReader.Create(source, settings);
while (reader.Read())
{
}
}
The xsd of the xml document I want to validate contains an xs:import that points to local xsd (the schemaLocation is, as example "./dc.xsd"). This xsd imports serveral other xsd, one of which is the following:
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/03/xml.xsd">
</xs:import>
When settings.Schemas.Add(null,xsd) is executed, all nested LOCAL xsd are correctly resolved by the XmlUrlResolver I created. If i inspect during debug my XmlReaderSetting instance i can see tha all the required xsd are correctly loaded, EXCEPT http://www.w3.org/2001/03/xml.xsd. Then settings.Schemas.Compile() is executed, an exception is raised telling me that the attribute xml:lang is not defined (it's defined in the missing xsd).
This exception is not raised, and validaion is performed correctly, if i manually add the namespace (see the commented line of my code), or if i change the scema location in the xsd file to point to a local copy of xml.xsd (schemaLocation="./xml.xsd").
I would like to know how can I make this work, because i don't want to add manually anything related to this specific scenario (i.e. i would like to reuse the code). In other words, why this remote location is not resolved?
|
|
|
|
|
Hi guys,
Usually I use XSL to transform XML at the server-side with ASP.NET. I have recently found out that it is possible to specify a stylesheet at the top of an XML file. The web browser then uses the XSL document to render the XML file.
I came across several websites which say that there is lack of browser support, but they were quite old.
I have tested a simple scenario in IE7, IE8 BETA, Chrome, FF3, and Safari and it seems to work wonders. So I didn't know whether there were any more subtle issues, or compatibility problems.
Are there any issues with this approach? Ideally I wanted to have the client browser do the transforms to ease the load at the server-side.
Many thanks,
Lea Hayes
|
|
|
|
|
lhayes00 wrote: So I didn't know whether there were any more subtle issues, or compatibility problems.
There certainly can be, I imagine. This is awkward since I detest assumptions, however given the history of browser compatibility it's likely a safe one.
lhayes00 wrote: Are there any issues with this approach?
Obviously, the more basic your XML-XSLT is the less likely any problems will surface. Conversely.... well I think you get the idea, yes?
led mike
|
|
|
|
|
I'm not sure which browsers other than IE support embedded XSLT documents, meaning they automatically do the transformation. However you can do the transformation using javascript and write out the result using the .innerHTML property. This is especially useful when creating Ajax style interfaces.
The code looks something like this:
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
xmlDoc.async = false;
xmlDoc.load("doc.xml")
var xslDoc = new ActiveXObject("Msxml2.DOMDocument");
xslDoc.async = false;
xslDoc.load(Server.MapPath("doc.xsl"));
myDiv.innerHTML = xmlDoc.transformNode(xslDoc);
For cross-browser support you will need to modify the line of code where you create the Xml document because different browsers handle it differently.
|
|
|
|
|
Hi,
That's fantastic! I am working on Ajax stuff at the moment, I didn't realize you could do XSL transforms with JavaScript.
Thanks for that!
Lea Hayes
|
|
|
|
|
Hai,
I just want to know "joomla" can you give me the related search.
With regards,
rose
|
|
|
|
|
rose196 wrote: can you give me the related search.
You mean this?[^]
led mike
|
|
|
|
|
Hai led mike
Thanks for your reply. Yes, I mean that only. Already I saw the link but I couldn't understand.Can you give the exact link related to 'joomla' Or can you tell me the use of 'joomla'.
Thanks and Regards,
Rose
|
|
|
|
|
rose196 wrote: I saw the link but I couldn't understand.
It's difficult to believe you can't understand a Google search. On the other hand, if you truly can't then it is likely a waste of time trying to help you.
|
|
|
|
|
Loading an XML file into C# I get the error: "There is an error in XML document (5, 4)." but nothing looks wrong and it loads without error into MS's XML Notepad. Any suggestions?
|
|
|
|
|
My first guess is there is something wrong with the file or XML you are loading. Are you sure you know what you are loading?
led mike
|
|
|
|
|
Sorted it - it was saved in Germany and the numbers in it were in "0,000" format instead of "0.000" and unsurprisingly it barfed.
|
|
|
|
|
when i run xsd.exe with my xml file it reports that it can't create nested tables in multiple namesapces, is there a way around this? the xml example below does not generate this error, the example xml is to show part of the structure of the xml doc
I need to be able to read when i leave the Computer and user elements of the xml doc below, what is the best way to read this xml file?
<gpo>
<computer>
<versiondirectory>0</versiondirectory>
<versionsysvol>0</versionsysvol>
<enabled>true</enabled>
</computer>
- <user>
<versiondirectory>2</versiondirectory>
<versionsysvol>2</versionsysvol>
<enabled>true</enabled>
- <extensiondata>
- <extension xmlns:q1="http://www.microsoft.com/GroupPolicy/Settings/Registry" xsi:type="q1:RegistrySettings" xmlns:xsi="#unknown">
- <q1:policy>
<q1:name> Data</q1:name>
</q1:policy>
</extension>
<name>Registry</name>
</extensiondata>
</user>
</gpo>
|
|
|
|
|
I need to scan a very big XML file (several millions of records), and I have discovered that access to data is very slow.
On a Pentium IV / 3 Ghz, the following instruction need 9 milliseconds :
BSTR BSTR_Result;
IXMLDOMNodePtr pNode;
// scan tree of nodes
...
pNode = pNode->nextSibling; // very quick (0 ms)
// get the text of the node
pNode->get_text( &BSTR_Result); // < need 9 milliseconds
To scan the whole file, the call to "nextSibling" is very quick. But the access to value is very slow ("get_text").
How can I increase performances ?
Best regards.
|
|
|
|
|
marcelcerdanjunior wrote: How can I increase performances ?
marcelcerdanjunior wrote: How can I increase performances ?
You can try switching to a SAX parser but I doubt that will satisfy your 9ms requirement. It is far more likely that you are abusing XML. XML is NOT a replacement for Databases. You will probably have to use some form of optimized database to satisfy your 9ms requirement.
Last modified: after originally posted -- clicked wrong button
led mike
|
|
|
|
|
It is strange that DOT.NET gives correct performances (less than 1 second to find a record in million list), but not the msxml4.dll interface.
|
|
|
|
|
marcelcerdanjunior wrote: It is strange that DOT.NET gives correct performances (less than 1 second to find a record in million list), but not the msxml4.dll interface.
Why is that strange? It would be strange if they were the same thing, but since they are not the same thing why is it strange. There is a web page out there somewhere that lists the multitude of XML parsers with performance information. But again, at a million records that just screams "Database".
led mike
|
|
|
|
|
If you are trying to find 1 record in a list of a million, why not use selectSingleNode() instead of looping through each node yourself?
|
|
|
|
|
Thanks,
I have tried your suggest, and I have the following result with selectSingleNode(.) call :
(ms = milliseconds)
/*
nb records table load duration last record access time
identifier to access
-----------------------------------------------------------------------------------
1000000 75000 ms "999999" ~ 43000 ms
100000 2119 ms "99999" 52 ms
10000 160 ms "9999" 5 ms
*/
My table looks like :
<root>
<general>
<type>Bigtest
<items>
<item>
<identifier>0000000
<profile>Guest
<password>
<name>Guest 0
<phone>06.00.00.00.00
<used>true
<item>
<identifier>0000001
<profile>Guest
<password>
<name>Guest 1
<phone>06.00.00.00.00
<used>true
<item>
<identifier>0000002
<profile>Guest
<password>
<name>Guest 2
<phone>06.00.00.00.00
<used>true
<item>...
|
|
|
|
|
Hi guys
Is it possible in xpath to select all elements that start with a value?
For example, say I have this XML:-
<devices>
<device>
<name>Nokia N73
<device>
<name>Nokia N95
And I want to select all device elements whose name starts with "Nokia".
Is there something like this in XPath: "/devices/device[name like 'Nokia*']"
Thanks in advance
|
|
|
|