|
Google?
Now seriously. Do you want to write your own parser or use some already created parser? If first one is the case, read up about parsers... e.g. here on CP like http://www.codeproject.com/cpp/yard-xml-parser.asp[^] or others. You may want to study XML spec. (http://www.w3.org/TR/2004/REC-xml-20040204/[^])
If latter, give more info please, like what parser do you want to use, in what language and what features do you need. CP/Google will help you as well.
Does it help? You can allways ask for more...
p.s. more keywords ( not only obvious "XML, Parser") are "Token, Grammar"
I'd love to help you more, but these days I am struggling with my own HTML parser (and with math, but this is different story ), so I don't spent so much time here now... hopefully somebody else will help you more (hey Phil, it's time to show off :->)
best regards
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
|
Hi all,
Can anyone help me out by showing a small piece of code on how to use fo:bookmark-tree and fo:bookmark. I am using FOP 0.20.5 to create the PDF. I tried out an example but it gave error specifying that no such tag as fo:bookmark-tree.
|
|
|
|
|
Hi All,
I am trying to implement
<fo:inline background-color="yellow">My Text</fo:inline>
But while creating my PDF with FOP 0.20.5, my background color does not change. Is there a work around for this.
|
|
|
|
|
hi,
i couldnt able to add a new element to a xml document using VC++ 6.0. im getting problem in appendChild function. if anyone having samples plz send it to kannaa_ram@yahoo.com
thanks and regards
kannan
|
|
|
|
|
I want to serialize (write) a DOM document out in an XML document.
1.How can i write <?xml version="1.0" encoding="UTF-8"?> and <!DOCTYPE rootElement SYSTEM "URIreference.dtd"> to the local file.
|
|
|
|
|
ladies & gentlemen.
i'm new in xerces xml dom. can anyone help me with following:
how can i get the XML content of the DOMDocument (as in msxml)?
there methods like, getTextContent... but it returns text without tags.
i've seen that java implemantation of xerces has DOMSerializer object.
maybe there is any analogical object...
any ideas?
4apai
There're no impossible tasks. There're tasks that required infinite period of execution time.
|
|
|
|
|
int main(int argc, char **argv)
{
int errorCount = 0;
try
{
XMLPlatformUtils::Initialize();
}
catch(const XMLException& toCatch)
{
cout << "XMLPlatformUtils::Initialize() failed." << endl;
XMLPlatformUtils::Terminate();
}
std::auto_ptr<xercesdomparser> pXercesDOMParser(new XercesDOMParser());
std::auto_ptr<mydomtreeerrorreporter> errReporter(new myDOMTreeErrorReporter());
pXercesDOMParser->setErrorHandler(errReporter.get());
XercesDOMParser::ValSchemes valScheme = XercesDOMParser::Val_Auto;
pXercesDOMParser->setValidationScheme(valScheme);
try
{
char filename[] = "config/command.xml";
pXercesDOMParser->parse(filename);
errorCount = pXercesDOMParser->getErrorCount();
if (errorCount > 0)
{
cout << "open file failed. 0" << endl;
XMLPlatformUtils::Terminate();
//goto Exit;
return 0;
}
}
catch (const DOMException& e)
{
cout << "open file failed. 1" << endl;
XMLPlatformUtils::Terminate();
return 0;
}
catch (const XMLException& e)
{
cout << "open file failed. 2" << endl;
XMLPlatformUtils::Terminate();
return 0;
}
DOMNode *pDOC = pXercesDOMParser->getDocument();
DOMNode *pNode = pDOC->getFirstChild();
//std::string name(getProp(pNode, "?xml"));
for (pNode = getNextElementNode(pNode);
pNode != NULL;
pNode = getNextElementNode(pNode))
{
/*if (!UtilXML::matchNode(pNode, "dictionary");
if (!matchNode(pNode, "dictionary"))
{
cout << "Bad dictionary format." << endl;
break;
}
std::string proto(getProp(pNode, "protocol"));
int currentProtocol = atol(proto.c_str());
#ifdef _DEBUG
cout << "protocol = " << currentProtocol << endl;
#endif
parseDictionary(pNode->getFirstChild(), currentProtocol);
*/
if(!matchNode(pNode, "command"))
{
cout << "Bad command format." << endl;
break;
}
parseCommand(pNode, 0);
}
//Exit:
pXercesDOMParser.release();
errReporter.release();
XMLPlatformUtils::Terminate();
return 0;
}
|
|
|
|
|
thx a lot. thats not really what i meant. but i find it helpful too.
4apai
There're no impossible tasks. There're tasks that required infinite period of execution time.
|
|
|
|
|
I have an XML File:
<ROOT>
<CAR Name="Maruti">
<SALES Year="2000">10</SALES>
<SALES Year="2001">11</SALES>
<SALES Year="2002">9</SALES>
<SALES Year="2004">8</SALES>
</CAR>
<CAR Name="Fort">
<SALES Year="2000">8</SALES>
<SALES Year="2002">7</SALES>
<SALES Year="2003">6</SALES>
<SALES Year="2004">9</SALES>
</CAR>
<CAR Name="Mercedes">
<SALES Year="2000">2</SALES>
<SALES Year="2001">4</SALES>
<SALES Year="2003">6</SALES>
<SALES Year="2004">3</SALES>
</CAR>
</ROOT>
Now I want to print the sales of each car Year wise in a tabular format. Something like a pivot table. If the car does not have sales for a particular year, it should display blank space. The output should be in the format like:
Maruti Fort Mercedes
2000 10 8 2
2001 11 - 4
2002 9 7 -
2003 - 6 6
2004 8 9 3
I am not able to print the values particularly. Please help.
|
|
|
|
|
Hi,
This doesn't seem like a very elegant solution. I'm sure there must be a better way, but I couldn't get there
Hope this helps.
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="unique-years" select="/ROOT/CAR/SALES[not(@Year=preceding::*/@Year)]/@Year" />
<xsl:variable name="unique-carnames" select="/ROOT/CAR[not(@Name=preceding::*/Name)]/@Name" />
<html>
<body>
<table>
<tr>
<td> </td>
<xsl:for-each select="$unique-carnames">
<xsl:sort select="." />
<td><xsl:value-of select="." /></td>
</xsl:for-each>
</tr>
<xsl:for-each select="$unique-years">
<xsl:sort select="." />
<tr>
<xsl:variable name="this-year" select="."/>
<td><xsl:value-of select="$this-year" /></td>
<xsl:for-each select="$unique-carnames">
<xsl:sort select="." />
<xsl:variable name="this-car" select="."/>
<td><xsl:value-of select="/ROOT/CAR[@Name=$this-car]/SALES[@Year=$this-year]" /></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Cheers
Phil Hobgen
barbari.co.uk
Southampton, UK
|
|
|
|
|
Thanks a lot Phil. It works.
|
|
|
|
|
I am a beginner of xml programming.
I am going to transmission an image file, a text file and a video file through TCP/IP. Therefore, I want to group them by a xml file.
I don't know how to get start on it.
Can someone show me some guidelines?
Please help
|
|
|
|
|
Hi,
The best place to start is with some questions :
1) What's your development environment?
2) Is there an existing XML Schema that you need to comply with? If you are exchanging the data with an external system, a schema is useful as a definition of the exchanged data format. Alternatively you may just be able to agree a simple xml structure.
3) Do you need to enclose the binary data in the xml, or could you use a url within the xml to indicate where the binary data can be retrieved from? If you need to enclose the binary data then you will need to encode it, as xml does not allow binary data. Note that this encoding will expand the size of the binary data, and hence the size of your xml.
4) When you transmit via TCP/IP do you mean HTTP, a web service, or some other standard protocol or just from port to port using some 'informal' protocol?
A good link to bookmark is http://www.zvon.org[^]
Good Luck!
Cheers
Phil Hobgen
barbari.co.uk
Southampton, UK
|
|
|
|
|
Thank you for your reply. It is very helpful for me.
I am programming with C#.net in XP.
Moreover, I am using "TCPListener" and "TCPClient" and the data are transmitted by "StreamWriter" and "StreamReader".
-Can XML Schema be used in non-website case?
-I am not using web service. Can SOAP be used for binary data encoding?
If not, what should I use?
Regards
|
|
|
|
|
Hi,
XML can be used anywhere where you can use text. You can pass it around in files, or over the web. SOAP is a protocol that uses XML for sending/receiving to call methods, this doesn't sound like what you want.
To do the binary encoding take a look at base64 encoding.
Cheers
Phil Hobgen
barbari.co.uk
Southampton, UK
|
|
|
|
|
Hi,
I solve it. I learn a lot. Thank You.
Cheers
RockRock
|
|
|
|
|
Can somebody give me a GOOD START on XMI - Just the Basics.
I tried to get some information on What XMI is and its intended use, but did not get any useful information.
All I know of it is that it is an XML-based, stream representation of a UML model which has the potential to allow models to be shared between different UML tools.
I find tools to convert XMI to UML and vice versa, but no good start on what XMI is, what is it used for? The future of XMI or in other words, will it have a widespread use as XML has today.
I am told it would take the place of UML soon - How true is this Statement?
|
|
|
|
|
Hi,
A starting point would be the OMG web site generally, and maybe this page http://www.omg.org/technology/xml/index.htm[^] in particular.
From what I know, it's just an XML language for describing UML models so they can be exchanged between different vendors modelling tools. It can't take the place of UML as it is just a standard language for describing UML models. As for its' future - personally I can't see much call for it in the real world, except maybe for large open source projects where a number of different UML editors might be used by different contributors. From my experience organisations tend to standardise on the use of a single modelling tool, so unless they want to exchange models externally they would have no call for XMI.
I have no real idea, but perhaps it is possible be that certain vendors would like to use XMI to store the models generated by their modelling tools, however xml would seem to be an extremely inefficient way to store this data. A bit like storing very large spreadsheets as XML, only worse!
It would be interesting to hear what started your interest in XMI?
Cheers
Phil Hobgen
barbari.co.uk
Southampton, UK
|
|
|
|
|
Thank you Phil for the start.
I interest in XMI started as read an introductory article on it. I tried to search for more information on it and wasn't able find much to my dismay.
All GREAT Men were ORDINARY people to start with.
What you CANnot VISUALIZE you CANnot ACHIEVE.
|
|
|
|
|
I tried to use DOM to do the XML validation with XSD and I used IXMLDOMSchemaCollection.
I followed the example you can find at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmproschemas.asp
but when I arrive at instruction
hr = pSchemaCache->add("",pSchemaDDoc.GetInterfacePtr());
add() always crashed on me. In fact, I tried with some of
my own XSDs, and it crashed right at add() too.
I'm listing part of my source code below, it must be something that I missed. Please help.
Thanks!
IXMLDOMDocument2Ptr pXMLDoc = NULL;
CoInitialize(NULL);
HRESULT hr;
try
{
//load the schema file
IXMLDOMDocumentPtr pSchemaDoc;
hr = pSchemaDoc.CreateInstance(__uuidof(DOMDocument30));
pSchemaDoc->async = VARIANT_FALSE;
hr = pSchemaDoc->load("C:\\Progetti\\books.xsd");
//check on the parser error
if(hr!=VARIANT_TRUE)
{
MessageBox(NULL, "Error", "", MB_OK);
return false;
}
//create schemachache
IXMLDOMSchemaCollectionPtr pSchemaCache;
hr = pSchemaCache.CreateInstance(__uuidof(XMLSchemaCache30));
//add schema to schema cache
hr = pSchemaCache->add("", pSchemaDoc.GetInterfacePtr());
// load the XML file
// ****** you need to use IXMLDOMDocument2 interface *********
IXMLDOMDocument2Ptr pXMLDoc;
hr = pXMLDoc.CreateInstance(__uuidof(DOMDocument30));
pXMLDoc->validateOnParse = VARIANT_FALSE;
pXMLDoc->async = VARIANT_FALSE;
//associate xml doc with schemacache
pXMLDoc->schemas = pSchemaCache.GetInterfacePtr();
// relative path works in debugger, modify it with absolute path
hr = pXMLDoc->load("C:\\Progetti\\XMLfile.xml");
//check on the parser error
if(hr!=VARIANT_TRUE)
{
MessageBox(NULL, "Error", "", MB_OK);
return false;
}
//call validate
IXMLDOMParseErrorPtr pError;
pError = pXMLDoc->validate();
if(pError->errorCode != S_OK)
{
MessageBox(NULL,"validate error", "",MB_OK);
_bstr_t parseError = _bstr_t("Error code: ")+ _bstr_t(pError->errorCode) +_bstr_t("\n") + _bstr_t("Reason: ")+ pError->Getreason();
MessageBox(NULL, (char*)parseError, "Parse Error",MB_OK);
return false;
}
else
MessageBox(NULL,"Validation succeeded", "Results",MB_OK);
}
catch(_com_error e)
{
MessageBox(NULL, e.ErrorMessage(), "",MB_OK);
MessageBox(NULL, e.Source(), "",MB_OK);
return false;
}
return true;
|
|
|
|
|
I have a XML File of the format
<br />
<CRICKET><br />
<TEAM Name="INDIA"><br />
<PLAYER>India Player 1</PLAYER><br />
<PLAYER>India Player 2</PLAYER><br />
<PLAYER>India Player 3</PLAYER><br />
<PLAYER>India Player 4</PLAYER><br />
<PLAYER>India Player 5</PLAYER><br />
<PLAYER>India Player 6</PLAYER><br />
<PLAYER>India Player 7</PLAYER><br />
<PLAYER>India Player 8</PLAYER><br />
<PLAYER>India Player 9</PLAYER><br />
<PLAYER>India Player 10</PLAYER><br />
</TEAM><br />
<TEAM Name="PAKISTAN"><br />
<PLAYER>Pakistan Player 1</PLAYER><br />
<PLAYER>Pakistan Player 2</PLAYER><br />
<PLAYER>Pakistan Player 3</PLAYER><br />
<PLAYER>Pakistan Player 4</PLAYER><br />
<PLAYER>Pakistan Player 5</PLAYER><br />
<PLAYER>Pakistan Player 6</PLAYER><br />
<PLAYER>Pakistan Player 7</PLAYER><br />
<PLAYER>Pakistan Player 8</PLAYER><br />
<PLAYER>Pakistan Player 9</PLAYER><br />
<PLAYER>Pakistan Player 10</PLAYER><br />
</TEAM><br />
</CRICKET><br />
I want to print this file in a tabular format with the name of the country in te header and the name of the players as rows. That is in a tabular format. Below the name of the country there should be the name of the players. Can anyone help me.
|
|
|
|
|
Hi,
This should get you started - it's not in a table, but you should get there from here
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<h1>Cricket</h1>
<xsl:apply-templates select="CRICKET/TEAM"/>
</body>
</html>
</xsl:template>
<xsl:template match="TEAM">
<h2><xsl:value-of select="@Name" /></h2>
<xsl:apply-templates select="PLAYER"/>
</xsl:template>
<xsl:template match="PLAYER">
<h3><xsl:value-of select="." /></h3>
</xsl:template>
</xsl:stylesheet>
Cheers
Phil Hobgen
barbari.co.uk
Southampton, UK
|
|
|
|
|
Can anyone help me with this problem??
|
|
|
|
|
Hi,
I think what you want is the IXMLDOMDocumentType interface which inherits from an IXMLDOMNode so you should be able to deal with it like any other node.
Cheers
Phil Hobgen
barbari.co.uk
Southampton, UK
|
|
|
|