[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

document XML inside another document XML using XLINK

  • To: xml-dev@l...
  • Subject: document XML inside another document XML using XLINK
  • From: "Davinia Lopez" <davlobe@h...>
  • Date: Mon, 16 Feb 2004 19:48:33 +0000
  • Bcc:

jaxb xlink
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


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.