OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   document XML inside another document XML using XLINK

[ Lists Home | Date Index | Thread Index ]

Hi,
I'm trying to add XML documents into another XML document
using XLINK but I don't know how.

I've tried several ways but it doesn't work,
could you help me, please?

Example:

generalstocks.xml

	<?xml version="1.0" standalone="yes"?>
	<mystocks xmlns:xlink="http://www.w3.org/1999/xlink";>
	   <contactlink xlink:type="simple" xlink:href="stocks.xml" 
xlink:show="embed"/>
	</mystocks>

stocks.xml
	<?xml version="1.0"?>
	<portfolio>
	  <stock exchange="y">
	    <name>new</name>
	    <symbol>zzzz</symbol>
	    <price dt="number">20.313</price>
	  </stock>
	</portfolio>

stocks.dtd
	<!ELEMENT mystocks (contactlink)>

	<!ELEMENT portfolio (stock+)>
	<!ELEMENT stock (name, symbol, price)>
	<!ELEMENT name CDATA>
	<!ELEMENT sysmbol CDATA>
	<!ELEMENT price CDATA>
	<!ATTLIST price dt CDATA #REQUIRED>


	<!ELEMENT contactlink ANY>
	<!ATTLIST contactlink
		xlink:type (simple) #FIXED "simple"
		xlink:href CDATA #IMPLIED
		xlink:show (embed) #FIXED "embed"
		xlink:actuate (onLoad) #FIXED "onLoad">



And this is the source code (I'm using Visual C++):

#include <stdio.h>
#import <msxml4.dll>
using namespace MSXML2;

int main(int argc, char* argv[])
{
   IXMLDOMDocument2Ptr pXMLDom;
   IXMLDOMParseError *pXMLErr=NULL;
   HRESULT hr;

   CoInitialize(NULL);

   hr = pXMLDom.CreateInstance(__uuidof(DOMDocument40));
   if (FAILED(hr))
   {
      printf("Failed to instantiate DOMDocument40 class\n");
      return -1;
   }

   pXMLDom->async = VARIANT_FALSE;

   if ( pXMLDom->load("generalstocks.xml") != VARIANT_TRUE)
   {
      printf("Failed load xml data from file.\n%s\n",
         (LPCSTR)pXMLDom->parseError->Getreason());
      return -1;
   }

   // Query a single node.
   IXMLDOMNodePtr pNode = pXMLDom->selectSingleNode("//stock[1]/*");
   if (pNode == NULL)
   {
      printf("Invalid node fetched.\n%s\n",
         (LPCSTR)pXMLDom->parseError->Getreason());
   }
   else
   {
      printf("Result from selectSingleNode:\nNode, <%s>:\n\t%s\n\n",
         (LPCSTR)pNode->nodeName, (LPCSTR)pNode->xml);
   }

   pXMLDom.Release();
   pNode.Release();

   CoUninitialize();

   return 0;
}

Thanks in advance,
Davinia

_________________________________________________________________
Reparaciones, servicios a domicilio, empresas, profesionales... Todo en la 
guía telefónica de QDQ. http://qdq.msn.es/msn.cfm





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS