|
Before I rush off and write the thing, would anyone be interested in an article explaining how to use SAX and DOM together to create an extensible mechanism for dealing with bulk (>1Gb) XML documents?
Steve S
|
|
|
|
|
I want to use MSXML to create a XML file like this
<?xml version="1.0" encoding="UTF-8"?>
<Schema xmlns="http://www.w3.org/2001/XMLSchema">
<element name="Features" type="wfs:featuresType" substitutionGroup="gml:_FeatureCollection"/>
</Schema>
Here is my source coede
#include <stdio.h>
#import <msxml4.dll>
using namespace MSXML2;
int main(int argc, char* argv[])
{
IXMLDOMDocument2Ptr pXMLDom;
HRESULT hr;
CoInitialize(NULL);
hr = pXMLDom.CreateInstance(__uuidof(DOMDocument40));
if (FAILED(hr))
{
printf("Failed to CreateInstance on an XML DOM");
return NULL;
}
pXMLDom->preserveWhiteSpace = VARIANT_TRUE;
IXMLDOMProcessingInstructionPtr pi;
pi = pXMLDom->createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
if (pi != NULL)
{
pXMLDom->appendChild(pi);
pi.Release();
}
IXMLDOMElementPtr pe;
IXMLDOMNodePtr nodePtr;
_variant_t varTyp((short)NODE_ELEMENT);
nodePtr=pXMLDom->createNode(varTyp,"Schema","http://www.w3.org/2001/XMLSchema");
pXMLDom->appendChild(nodePtr);
nodePtr.Release();
pe = pXMLDom->documentElement;
IXMLDOMAttributePtr pa;
pXMLDom->documentElement->appendChild(pXMLDom->createTextNode("\n\t"));
IXMLDOMDocumentFragmentPtr pdf;
pdf = pXMLDom->createDocumentFragment();
pe = pXMLDom->createElement("element");
pe->setAttribute("name","Features");
pe->setAttribute("type","wfs:featuresType");
pe->setAttribute("substitutionGroup","gml:_FeatureCollection");
pdf->appendChild(pe);
pe.Release();
pXMLDom->documentElement->appendChild(pdf);
pdf.Release();
pXMLDom->documentElement->appendChild(pXMLDom->createTextNode("\n\t"));
hr = pXMLDom->save("dynaDom.xml");
if (FAILED(hr))
{
printf("Failed to save DOM to dynaDom.xml\n");
}
else
{
printf("DOM saved to dynamDom.xml\n");
}
if (pXMLDom) pXMLDom.Release();
CoUninitialize();
return 0;
}
But the output is:
<?xml version="1.0" encoding="UTF-8"?>
<Schema xmlns="http://www.w3.org/2001/XMLSchema">
<element xmlns="" name="Features" type="wfs:featuresType" substitutionGroup="gml:_FeatureCollection"/>
</Schema>
you can see that :there is an attribute "xmlns" within the "element" tag and the value of the attribute is nothing.
I don't want the out come is this,Please Help!
|
|
|
|
|
When you create the "element" node you need so specify that it is part of the same namspace as the Schema element.
Otherwise what you are saying is that the element node does not belong to any namespace, hence the empty xmlns attribute.
Something like :
pXMLDom->createElement("element",","http://www.w3.org/2001/XMLSchema");
|
|
|
|
|
Thank you for your help!
This question has been resolved .
|
|
|
|
|
I am trying to store an article in an xml file and use an xsl transform to create an html version of the article. I am having no problems with the article text, heading and etc. however i wish to place a simple image tag that gets the image url from the xml file and outputs the tag to the html. I am a newcomer to xml and have been unable to make this work. any help would be greatly appreciated.
|
|
|
|
|
What have you tried so far?
How about posting examples of the xml and xsl that you are using.
|
|
|
|
|
Me and some partners are together going to construct a XML-format for storing data. New datatypes will come in the future so the XML-tags will grow. Are there a common way for all of us to handle the way to build up valid documents.
Pleased for all suggestions
...and justice for all
APe
|
|
|
|
|
Look up XSD and Schema's
Lots of information.
|
|
|
|
|
how can i transform an xml using xslt without loading the xslt from a file?
I have two strings containing the source of the xml and xslt
I can load an xmldocument object using the InnerText property, but then i can't find a way to transform it since all the methods available for loading an xslt document and transforming the xml document involve an xslt file
|
|
|
|
|
If you are using .Net Framework try following:
XmlDocument doc=new XmlDocument();
doc.LoadXml(xmlString);<br /><br />
XslTransform xslt=new XslTransform();
TextReader txt=new StringReader(xsltString);
XmlReader reader=new XmlTextReader(txt);
xslt.Load(reader,null,null);<br />
<br />
xslt.Transform(...);
|
|
|
|
|
Look at the loadXML() method. It takes a string of XML and loads it into the MSXML4::IXMLDOMDocument2 object.
|
|
|
|
|
Sub : How to use Amazon Web Services..
Hi all...
Please let me know How to start with amazon web services..
I'm not finding any XML or REST Query format to send request to amazon..
I've purchased Seller account but How to use that to upload Items..I don't know...
Please help me getting start..
I hope some one definatly know about this
e-mail if attachment at sumit_kapoor1980@hotmail.com
Thanks...
..---Sumit Kapoor---
|
|
|
|
|
Stop Cross posting and use your eyes: The answer is already on Code Project, if you would care to look.
My suggestion is to use the little search box near the top of this page and type "Amazon web services", ensure the drop down says "Articles" and then press "Go". You'll be amazed at what you can find.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|
|
Don't be rude. If you were interested in helping him you could have posted the URL to the article. If not, you could just told him there was an article on CP.
|
|
|
|
|
Paul Wolfensberger wrote:
Don't be rude
Be more positive. How about saying: "Be nice!". Reinforce the behaviour you wish, rather than the behaviour you don't want.
Paul Wolfensberger wrote:
If you were interested in helping him you could have posted the URL to the article
If you give a man a fish, you feed him for a day. If you teach a man to fish, you feed him for a lifetime.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|
|
i was able to generate html doc/code from xml and xsl through c++ using IXMLDOMDocumentPtr , IXSLTemplatePtr , IXSLProcessorPtr .
but when i added/wrote schema for xml , it was skipping tag elements text
in xml file.
how can i get/access tag elements text ?
|
|
|
|
|
Is it possible to define schema for the following element ? :
<processor>
<param>arial</param>
<param>3.5</param>
<param>50</param>
<param>95</param>
<param>some text</param>
</processor>
I want to enforce that exactly five 'param' elements can be specified, and I want
to enforce types for the elements (i.e. first element is xs:string, seconf xs:double,
... etc
I tried to create the following schema, but I get error when checking for validity
<xs:complexType name="processor_type">
<xs:sequence>
<xs:element name="param" type="xs:string"></xs:element>
<xs:element name="param" type="xs:double"></xs:element>
<xs:element name="param" type="xs:decimal"></xs:element>
<xs:element name="param" type="xs:decimal"></xs:element>
<xs:element name="param" type="xs:string"></xs:element>
</xs:sequence>
</xs:complexType>
Error:
In the same scope, elements with the same name have to have the same type.
Is there any workaround for this, but without giving different names for current 'param'
elements
Thanks
Michał Januszczyk
|
|
|
|
|
Hi
I want to print an Organisation Chart which is more like an Inverted Tree Structure.
Like that with proper Lines. I could find ready tools for Explorer Type of Tree Structure (similar to windows Explorer). But i want an inverted tree structure like above one.
Actually I am doing my work in ASP. But any solution is accepted.
Thanks
|
|
|
|
|
Have a look here http://www.15seconds.com/issue/020424.htm or http://www.15seconds.com/focus/XML.htm for more solution.
Goodluck
|
|
|
|
|
Is there any way that this can be presented in a horizantal way
|
|
|
|
|
I am trying to write a stylesheet to extract information from an XML Schema. However, I cannot figure out how to handle the namespace in the source XML/XSD document. Do you have to declare the namespace in the XSL stylesheet as well? What about in the XPath expressions in the XSL? Do you have to use the namepsaces there as well?
Thanks
|
|
|
|
|
Hello,
I'm new to xslt and xml. I have a xml-document that looks like this :
<?xml version="1.0" standalone="yes"?>
<sessions version="1.0">
<session name="Development">
<libraries>
<library name="contxtlib">
<fullname>123</fullname>
<super>true</super>
<loadorder>8</loadorder>
</library>
<library name="xmllib">
<fullname>xmllib.p</fullname>
<super>true</super>
<loadorder>12</loadorder>
</library>
<library name="clientdebuglib">
<fullname>clientdebuglib.p</fullname>
<super>true</super>
<loadorder>3</loadorder>
</library>
</libraries>
</session>
</sessions>
Now i want to sort this xml-file. The loadorder should be 3 then 8 and then 12 and not in this order. So it has to be sorted. I tried writing a xslt file but he doesn't sort my data.
My xslt file looks like this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="session">
<xsl:copy>
<xsl:apply-templates>
<xsl:sort data-type="number" select="session/libraries/library/loadorder"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Everything could be wrong for me, i found this on the internet and made some changes but now i don't know whether it's good. All i want to to is sort the library's on loadorder.
thx a lot in advance
|
|
|
|
|
your first template match is wrong it should be "sessions" rather than "session"
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hai,
I have been able to develop database applications using Recordsets technology. I worry is that this approach is a bit cumbersome for large database applications.
I want to use an approache were I will be able to access a single or set of records directly from a Database without having to search in the resulting recordset.
In short I want to be able to use SQL in my database programs in VC++.
How should I connect to the database. What specific coding and setup is needed.
Lloyd.
|
|
|
|
|
Hai,
I'am a new VC++ developer, I have been able to develop applications using
MFC Single/Mutiple Doments and manipulating recordsets.
I want to access records in a database using Dialogue Boxes instead of document forms. I do not like the appearance of a Document based database apllication.
What procedures should I follow to be able to access a database using Dialogue Boxes.
Lloyd.(Zambia)
|
|
|
|