|
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
|
|
|
|
|
Sorry, the XML didn't show properly.
See below for example XML:
<devices>
<device>
<name>Nokia N73</name>
</device>
<device>
<name>Nokia N95</name>
</device>
</devices>
|
|
|
|
|
Don't worry guys, I've found the solution:-
XPath: "/devices/device[starts-with(., 'Nokia')]"
|
|
|
|
|
threemp3 wrote: Don't worry guys, I've found the solution:-
whew! What a relief!
led mike
|
|
|
|
|
Hello,
Maybe I want the impossible, i don't know..does anyone? I'm only just starting to learn xsd schema-s.
Is it possible to have an element in an xsd that is dependand of the value of an attribute?
for example: in the below schema, can the name and type of the element where ORDER is located be dependand of the value of the attribute REPORT_TYPE? If the REPORT_TYPE="ORDER_DEFINITION" there should be an ORDER of ORDERType, if the REPORT_TYPE="ORDER_BATCH_CONSUMPTION" there should be a RUN of RUNType, or when the value is something else in the future there should't be an element at all?
<code>
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema blockDefault="" elementFormDefault="qualified" targetNamespace="xdwhml" version="1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="DATAREPORT">
<xs:complexType>
<xs:sequence>
<xs:element name="REPORT_HEADER">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="REPORT">
<xs:complexType>
<xs:attribute name="REPORT_ID" type="xs:string" />
<xs:attribute name="DATETIME" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element xmlns:q1="xdwhml" name="ORDER" type="q1:ORDERType" />
</xs:choice>
</xs:sequence>
<xs:attribute xmlns:q1="xdwhml" name="REPORT_TYPE" type="q1:REPORT_TYPE_ENUM" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="REPORT_TYPE_ENUM">
<xs:restriction base="xs:string">
<xs:enumeration value="ORDER_DEFINITION" />
<xs:enumeration value="ORDER_BATCH_CONSUMPTION" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="ORDERType">
<xs:attribute name="ORDER_NAME" type="xs:string" use="required" />
<xs:attribute name="LINE_NAME" type="xs:string" use="required" />
<xs:attribute name="DESTINATION_NAME" type="xs:string" use="required" />
<xs:attribute name="RECIPE_NAME" type="xs:string" use="required" />
<xs:attribute name="BATCH_NUMBER" type="xs:string" use="optional" />
</xs:complexType>
</xs:schema>
</code>
|
|
|
|
|
Hello. How can I use XSL to get the most common value of a given attribute in some unsorted XML? For instance, here is some XML:
<fixtures>
<fixture time="1930" date="20080926"></fixture>
<fixture time="0930" date="20080927"></fixture>
<fixture time="0930" date="20080927"></fixture>
<fixture time="1000" date="20080928"></fixture>
<fixture time="1000" date="20080926"></fixture>
<fixture time="0930" date="20080926"></fixture>
<fixture time="1230" date="20080930"></fixture>
</fixtures>
I would like to end up with <xsl:value-of select="$mostCommonTime" xmlns:xsl="#unknown"></xsl:value-of>, therefore producing an output of "0930" - the most common value of the time attribute.
Just to complicate things, I need to do further validation on each fixture (using the date attribute), to see whether it is counted or not. This validation is done using Javascript, since it involves date functions, and we are using (and due to 3rd party restrictions, can only use) XSL 1.0. So, each fixture needs to be examined in a separate template, rather like this: <xsl:value-of select="lxslt:isFixtureValid(string(Fixture/@date))" xmlns:xsl="#unknown"></xsl:value-of>, and is discounted or counted depending on whether this output is 'true' or 'false'.
I've tried a recursive template, but do not see a way of sorting the Fixtures node that has to be passed into it; if I try a for-each loop, there is no way of keeping track of the most common time.
Thanks.
|
|
|
|
|
This does not seem like an appropriate use of XSLT. It is a data transformation mechanism not a data analysis mechanism. Therefore even if you could figure out how to do it, it doesn't mean it's a good idea.
led mike
|
|
|
|
|
This is part of a data transformation. I want to place an element around the fixtures, stating "time is hh:mm unless stated", where hh:mm is the most common value. The purpose of the stylesheet is certainly not analysis.
I think that this is a grouping problem, requiring Muenchian grouping, but I've got no further than that.
|
|
|
|
|
darasd wrote: This is part of a data transformation.
That's the way you are looking and perhaps implementing it but that is not what I am referring to.
darasd wrote: to get the most common value
That is an analysis activity, not a transformation activity. Do you understand my point?
led mike
|
|
|
|