|
Did a look up on Infopath. The reasons I didn't use it for a class project was due to it's proprietary software. To nutshell Infopath too much, it's just another XML web service and can run async like Ajax.
My thoughts are that it's always better to learn the guts, like XForms and XML web services (using REST & SOAP) before bumping up to proprietary software, like Infopath.
Most likely, Infopath runs async by creating a data model like the XForms example above and submitting it to a service. I'd have to dig much deeper and it wouldn't probably answer your question enough.
Gotta love the details! :LOL:
|
|
|
|
|
For XForms use with every recent browser, have a look at XSLTForms : http://www.agencexml.com/xsltforms
|
|
|
|
|
Hi all!
I am a new one in XML. Now I have a project which need to call GetObject() function with the syntax of JavaScript. The aim of this action is to get an object of a COM. The COM is created by myself. This COM has several interface. One of these interface is named as NetworkClass. And the COM is named as WindowsNetwork.
Now I'm sure that this COM had been registed in windows correctly. I write the code as following:
var WindowsNetwork = GetObject("WindowsNetwork,NetworkClass");
But an error is return. It say that this object is undefined. The variable is invalid. I think this is because of the syntax error of GetObject(). Maybe it shouldn't be written as this if a COM have several interface. So I hope someone could be kind to tell me how to write this code. Thx!
Best Regards!
whiteclouds
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
Try with
var WindowsNetwork = GetObject("WindowsNetwork.NetworkClass");
Also Refer
http://www.c-point.com/javascript_tutorial/jsfncGetObject.htm
Regards
Akhila
|
|
|
|
|
Thx for your reply. My problem had been resolved.
There is some white cloud floating on the blue sky. That's the landscape I like.
|
|
|
|
|
Hi,
I have the xml document like,
<?xml version="1.0" encoding="utf-8"?>
<Drive>
<folders>
<folder name="f1">
</folder>
<folder name="f2">
</folder>
</folders>
</Drive>
Please notice that there is no xmlns used and I cannot used xmlns in this xml document.
I have problem creating schema (.xsd) file to validate this xml document.
My schema is like
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.tempuri.com/temp"
elementFormDefault="qualified">
<element name="Drive">
<complexType>
<sequence>
<element ref="folders" minOccurs="0" maxOccurs="1"/>
</sequence>
</complexType>
</element>
<element name ="folders">
<complexType>
<sequence minOccurs ="0" maxOccurs ="unbounded">
<element ref ="folder"/>
</sequence>
</complexType>
</element>
<element name ="folder">
<complexType>
<sequence>
<element ref ="folders" minOccurs ="0" maxOccurs="1" />
</sequence>
<attribute name ="name" type="string" />
</complexType>
</element>
</schema>
But the ref attribute is not working. ie the attribute 'folders' cannot reference the element 'folders'. I am using VS2008 to create/edit xsd file. VS2008 shows warning message
"The 'http://www.w3.org/2001/XMLSchema:folders' element is not declared.". The same exception occurs if I run my c# program to valid the xml.
Could you please suggest me how to refernce element using ref attribute without using namespace? Is there any other workaround?
Thanks.
Prakash
|
|
|
|
|
I may have steered you wrong before saying that ref didn't work without namespaces. I think they do, but there are a few things that need to change before your schema could possibly work:
- Remove the targetNamespace attribute - this is the namespace that the elements your defining in the schema (Drive, folder
- You need to change the default namespace declaration to be a named namespace:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
and prefix all elements that come from the XML Schema namespace with the namespace prefix you choose (xs in this case)
Oh and one other thing - learn about XML namespaces, what they imply and how they interact with XML Schemas. You need to know this stuff if you're going to design XML Schemas - you need to know it if you're working with XML!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You have referenced the element 'folders' before it was described in your xml that is why you are getting this error. Try changing the order in your xml .
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.tempuri.com/temp"
elementFormDefault="qualified">
&lt;element name ="folders"&gt;
&lt;complexType&gt;
&lt;sequence minOccurs ="0" maxOccurs ="unbounded"&gt;
&lt;element ref ="folder"/&gt;
&lt;/sequence&gt;
&lt;/complexType&gt;
&lt;/element&gt;
<element name="Drive">
<complexType>
<sequence>
<element ref="folders" minOccurs="0" maxOccurs="1"/>
</sequence>
</complexType>
</element>
<element name ="folder">
<complexType>
<sequence>
<element ref ="folders" minOccurs ="0" maxOccurs="1" />
</sequence>
<attribute name ="name" type="string" />
</complexType>
</element>
</schema>
Regards
Akhila
|
|
|
|
|
The job I'm working on wants to use XML for storing strings in the various languages we plan to support.
We're choosing xml for a variety of reasons:
Not tied to a specific platform (.resx etc)
Doesn't require application recompilation on editing/adding strings
Doesn't require recompilation on adding new languages.
Human readability.
Overall, I agree with using XML, but my boss has tasked me with finding out the reasons why *not* to use it. To play the Devil's Advocate so to speak.
While I can think up a few reasons, I'm coming short on anything really convincing, which I'm worried is due to my bias of actually wanting to use it.
Anyone have some solid reasons not to use XML for this type of data storage?
I have:
Possible slower load time at initial startup, or at string access.
Possible memory overhead depending on schema, and how we handle language data loading.
Resource size: xml contains a lot of overhead in the markup language (this is a concern for us)
|
|
|
|
|
You've probably hit most of the reasons you might not want to use XML. Couple of other reasons to use XML - a) not having to write your own parsing code and b) XML files explicitly define the encoding they use.
This design decision doesn't seem to be so important that you want to take too much effort over it. Using XML's a no-brainer, really, IMO.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi All,
I used an Altova XMLSpy tool generate an XSD file for my XML file.
The xsd equivalent for an simple xml element "Mfg" generated via the tool was
<xs:element name="Mfg">
<xs:simpleType>
<xs:restriction base="xs:string">
</xs:restriction>
</xs:simpleType>
</xs:element>
I found out that modifying the above xsd to the one below just works fine.
<xs:element name="Mfg" type="xs:string"/>
Just wanted to know if these 2 XSD representations for the xml element are the same or are they different.
Do the elements xs:simpleType, xs:restriction above have any signifance int he above mentioned scenario?
(Actually tried going through MSDN but conldn't infer much info).
It would be of great help if somebody points out the differences between the 2 if any and brief on it's significance.
|
|
|
|
|
They are exactly the same because the restriction specified doesn't actually restrict the base type (i.e. xs:string). Here's an example of a restriction on a string using a regular expression pattern that could be used as a variable or type name:
<xs:simpleType>
<xs:restriction baseType="xs:string">
<xs:pattern value="[A-Za-z][A-Za-z0-9_]*"/>
</xs:restriction>
</xs:simpleType>
[edit]I recommend downloading the Essential XML Quick Reference PDF[^], as it's a very easy to use reference to XML technologies, including XSD.[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Oh. I see.
Thanks for the info.
|
|
|
|
|
<Root>
<Products>
<Item ItemColor="Red" ItemName="Item1"/>
<Item ItemColor="White" ItemName="Item2"/>
<Item ItemColor="Blue" ItemName="Item2"/>
</Products>
<Desciptions>
<Color ColorName="Red" ColorId="15"/>
<Color ColorName="White" ColorId="14"/>
<Color ColorName="Blue" ColorId="13"/>
</Desciptions>
</Root>
<xsl:template match="/">
<xsl:for-each select="Products/Item">
<tr>
<td><xsl:value-of select="ItemColor" /></td>
<td> ? Right here I want the ColorId of the
ColorName that matches ItemColor found by the previous select ?</td>
</tr>
</xsl:for-each>
</xsl:template match="/">
Thank You for reading this post.
modified on Friday, July 10, 2009 6:12 PM
|
|
|
|
|
Throw the value into a variable then XPath with a condition on the variable, like this:
<xsl:for-each select="Products/Item">
<xsl:variable name="colorname" select="@ItemColor"/>
<tr>
<td><xsl:value-of select="$colorname"/></td>
<td><xsl:value-of select="//Color[@ColorName=$colorname]/@ColorId"/></td>
</tr>
</xsl:for-each>
Jeremy Likness
http://csharperimage.jeremylikness.com/
|
|
|
|
|
Thanks , you have solved my problem and
enlightened me on the use of variables .
Very much appreciated .
|
|
|
|
|
An alternative solution without variables:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:for-each select="//Products/Item">
<tr>
<td><xsl:value-of select="@ItemColor" /></td>
<td><xsl:value-of select="//Desciptions/Color[@ColorName=current()/@ItemColor]/@ColorId"/></td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
current() retrieves the context node of the scope surrounding the select attribute, i.e. the node currently selected by the for-each element in this case.
Here's another solution, using an XSLT key element. This approach is very useful when there's a large number of things to lookup in.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:key name="color-name-to-id" match="//Desciptions/Color/@ColorId" use="../@ColorName"/>
<xsl:template match="/">
<xsl:for-each select="//Products/Item">
<tr>
<td><xsl:value-of select="@ItemColor" /></td>
<td><xsl:value-of select="key('color-name-to-id', @ItemColor)"/></td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi
I am doing a code generation app. using .Net 3.5.
I wish to know if it is possible to generate multiple code files from a single xslt file.
I know that it can be accomplished in XSLT 2.0 using result-document tag.
Is it possible using XSLT 1.0 ?
Thanks
Fadi
|
|
|
|
|
Exslt[^] provides the exsl:document[^] element - but that only seems to be implemented in libxslt.
As you're using .NET, though, you could implement something like exsl:document using an Extension Object[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you Stuart
But can you clarify some more things?
My xml file is
<?xml version="1.0" encoding="utf-8" ?>
<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
My xslt file is
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:output="urn:output">
<xsl:template match="bookstore">
<bookstore>
<xsl:for-each select="book">
<book>
<xsl:copy-of select="node()"/>
<new-price>
<xsl:value-of select="output:SaveOutput(@genre, node())"/>
</new-price>
</book>
</xsl:for-each>
</bookstore>
</xsl:template>
</xsl:stylesheet>
C# code goes like
private void ExtensionTest()
{
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load("extension.xslt");
XsltArgumentList xslArg = new XsltArgumentList();
OutputSaver obj = new OutputSaver();
xslArg.AddExtensionObject("urn:output", obj);
using (XmlWriter w = XmlWriter.Create("output.xml"))
{
xslt.Transform("books.xml", xslArg, w);
}
}
public class OutputSaver
{
public void SaveOutput(string fileName, string node)
{
StreamWriter s = new StreamWriter(fileName);
s.Write(node);
s.Flush();
}
}
Now I have 2 issues
* How to pass the xslt node content to SaveOutput method in c#
* How avoid specifying an output file in Trnasform method of XslCompiledTransform (This is to avoid generating an addtional file with the files generated using extennsion method)
Thank you
Fadi
|
|
|
|
|
I got one more query. Will it be possible by embedding script in xslt?
I tried the following way
Xslt file
?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
xmlns:user="urn:myscripts"
>
<xsl:output method="xml" indent="yes"/>
<msxsl:script language="C#" implements-prefix="user">
<![CDATA[
public void SaveOutput(string fileName)
{
System.IO.TextWriter t = new System.IO.StreamWriter(fileName);
t.Write("got it");
t.Flush();
}
]]>
</msxsl:script>
<xsl:template match="@* | node()">
<xsl:value-of select="user:SaveOutput('d:\testing.txt')"/>
</xsl:template>
</xsl:stylesheet>
My C# code is
private void ScriptTest()
{
XsltSettings settings = new XsltSettings();
settings.EnableScript = true;
XslCompiledTransform trs = new XslCompiledTransform();
trs.Load("Custom.xslt", settings, new XmlUrlResolver());
StreamWriter writer = new StreamWriter(@"e:\samples.txt");
trs.Transform(@"E:\\9.xml", null, writer);
writer.Flush();
writer.Close();
}
But when I run the code, I get en error like
IOException unhandled - The device is not ready
Thank you
Fadi
|
|
|
|
|
|
Hello all,
I am rendering my page using XSL.At place I am using sorting using xsl sort.But this need to be dynamic i e user can sort by some specific fiend by his own choice.
So I have to put select as dynamic which I am passing to xsl as a parameter as
<code><xsl:param name="SortName" select="Name" />
<xsl:param name="SortDataType" select="text" /></code>
Now I am accessing these parameter in xsl:sort tag as
<code> <xsl:sort select="$SortName" data-type='{$SortDataType}'/></code>
but its not working...
Waiting for your reply..
|
|
|
|
|
If SortName is the name of an element, try something like this:
<xsl:sort select="./*[name()=$SortName]"/>
[edit]Or if SortName is the name of an attribute, then use this:
<xsl:sort select="./@*[name()=$SortName]"/>
[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello friends,
How can i implement RSS feeds in wy website.
Thanks in ADvance.
With regards,
MAHESH.K
|
|
|
|