´ë¹®    
FindPage  |  TitleIndex  |  UserPreferences  |  [http]me2day  |  redpixel
RecentChanges
 


expat

icon

Contents

1 expatÀÌ ¹¹ÁÒ?
2 expatÀÇ °³¿ä
3 expatÀ» ºôµåÇϱâ
4 ÄÄÆÄÀÏ ¼³Á¤º¯¼öµé
5 expatÀ» ÀÌ¿ëÇÏ¿© ÀÛ¾÷Çϱâ
6 Çڵ鷯°£¿¡ Åë½ÅÇϱâ
7 ³×ÀÓ½ºÆäÀ̽º ó¸®
8 ¹®ÀÚ ÀÎÄÚµù
9 ¿Ü¹« °³Ã¼ ÂüÁ¶¸¦ ´Ù·ç±â
10 DTD ÆÄ½Ì
  • »çÀÌÆ® ¸µÅ© : [http]http://expat.sourceforge.net/
  • xml.comÀÇ ¾ÆÆ¼Å¬ Àü¹ÝºÎ¸¦ ¹ø¿ªÇÑ °ÍÀÔ´Ï´Ù.
  • mingw¿¡¼­ ºôµåÇÒ °æ¿ì
    ./configure --enable-shared=no ; make install clean
    

1 expatÀÌ ¹¹ÁÒ? #

expatÀº C·Î ÀÛ¼ºµÈ XML¹®¼­¸¦ ÆÄ½ÌÇϱâ À§ÇÑ ¶óÀ̺귯¸®ÀÔ´Ï´Ù. À̰ÍÀº ¿ÀǼҽº ÇÁ·ÎÁ§Æ®ÀÎ ¸ðÁú¶ó ÇÁ·ÎÁ§Æ®, ÆÞ ¾ð¾îÀÇ XML:Parser, ±×¿Ü ´Ù¸¥ ¿ÀǼҽº XML ÆÄ¼­·Î¼­ ³»ÀåµÇ¾îÀÖ½À´Ï´Ù. ³ªÀÇ [http]º¥Ä¡¸¶Å© ¾ÆÆ¼Å¬¿¡¼­ÀÇ ½Ã¿¬ µ¥ÀÌŸ¸¦ º¸¸é ÀÌ ¶óÀ̺귯¸®´Â ¸Å¿ì ºü¸£´Ù´Â °ÍÀ» ¾Ë ¼ö ÀÖ½À´Ï´Ù. ¶ÇÇÑ ¾ÈÁ¤¼º°ú °ß°íÇÔ, ¿À·ù ¼öÁ¤¿¡ ´ëÇÑ ±âÁØÀ» ³ô°Ô µÎ¾î °³¹ßµÇ¾ú½À´Ï´Ù. ÀÌ ¶óÀ̺귯¸®´Â james clark¿¡ ÀÇÇØ ¸¸µé¾îÁ³½À´Ï´Ù. (±×´Â groff(nroff¿Í ºñ½ÁÇÑ Åø), Jade(SGMLÀ» À§ÇÑ ½ºÅ¸ÀÏ½ÃÆ® ¾ð¾îÀÎ ISOÀÇ DSSSL ±¸Çö), XP(ÀÚ¹Ù XML ÆÄ¼­ ÆÐŰÁö), XT(ÀÚ¹Ù XSL ¿£Áø)À» °³¹ßÇÑ °ÍÀ¸·Î À¯¸íÇÕ´Ï´Ù) James´Â ¶ÇÇÑ XML ½ºÆÑÀ» Á¦Á¤ÇÏ´Â W3ÀÇ XML Working GroupÀÇ ±â¼ú °í¹®À» ¿ªÀÓÇϰí ÀÖ½À´Ï´Ù. ÀÌµé ÆÐŰÁöÀÇ ´ëºÎºÐÀº [ftp]ftp://ftp.jclark.com/pub¿¡¼­ ±¸ÇÒ ¼ö ÀÖ½À´Ï´Ù.

2 expatÀÇ °³¿ä #

expatÀº ½ºÆ®¸² ±â¹Ý ÆÄ¼­ÀÔ´Ï´Ù. ¿©·¯ºÐÀº ÆÄ¼­¿¡ Äݹé(¶Ç´Â Çڵ鷯)¸¦ µî·ÏÇϰí, ¹®¼­¸¦ Á¦´ÜÇϱ⠽ÃÀÛÇÕ´Ï´Ù. ÆÄ¼­°¡ ¹®¼­ÀÇ °¢ ºÎºÐÀ» ÀνÄÇÒ ¶§¸¶´Ù ±×ºÎºÐ¿¡ ¾Ë¸ÂÀº Çڵ鷯¸¦ È£ÃâÇÒ °Í ÀÔ´Ï´Ù(¸¸¾à ¿©·¯ºÐÀÌ µî·ÏÇß´Ù¸é ¸»ÀÌÁÒ) ¹®¼­´Â ÆÄ¼­¿¡ ¿©·¯Á¶°¢À¸·Î Á¦´ÜµÇ¹Ç·Î, ¿©·¯ºÐÀº Àüü ¹®¼­¸¦ ÀбâÀü¿¡ ÆÄ½ÌÀ» ½ÃÀÛÇÒ ¼ö ÀÖ½À´Ï´Ù. ÀÌ ±â´ÉÀº ¸Þ¸ð¸®¾È¿¡ ·ÎµùÇÒ ¼ö ¾ø´Â °Å´ëÇÑ ¹®¼­¸¦ ÆÄ½ÌÇÒ ¼ö ÀÖµµ·Ï ¸¸µé¾î ÁÝ´Ï´Ù.

expat¿¡ ÀÖ´Â ¸¹Àº Á¾·ùÀÇ ÇÚµé¾î¿Í ¿É¼Ç ¶§¹®¿¡ ¹Ì¸® °ÌÀ» ¸ÔÀ» ¼öµµ ÀÖÀ» °Ì´Ï´Ù. ÇÏÁö¸¸ ¿©·¯ºÐÀÌ ¿øÇÏ´Â ÀÛ¾÷ÀÇ 80%Á¤µµ´Â 4°³ÀÇ ÇÔ¼ö¸¸ ¾Ë¸é µË´Ï´Ù.
  • XML_ParserCreate - »õ·Î¿î ÆÄ¼­ °´Ã¼¸¦ »ý¼ºÇÕ´Ï´Ù
  • XML_SetElementHandler - ½ÃÀÛ°ú ³¡ Å×±× Çڵ鷯¸¦ ¼³Á¤ÇÕ´Ï´Ù
  • XML_SetCharacterDataHandler - ÅØ½ºÆ®¿¡ ´ëÇÑ Çڵ鷯¸¦ ¼³Á¤ÇÕ´Ï´Ù
  • XML_Parse - ÆÄ¼­·Î ¹®¼­ ³»¿ëÀ» ´ãÀº ¹öÆÛ¸¦ Àü´ÞÇÕ´Ï´Ù.

ÀÌ ÇÔ¼öµé°ú ³ª¸ÓÁö´Â ÀÌ ¾ÆÆ¼Å¬ ¸¶Áö¸·¿¡ ¼³¸íµÇ¾îÀÖ½À´Ï´Ù. ·¹ÆÛ·±½º ºÎºÐ ¶ÇÇÑ °¢°¢ÀÇ Çڵ鷯 ŸÀÔ¿¡ Àü´ÞµÇ´Â ¸Å°³º¯¼ö¿¡ ´ëÇÏ¿© »ó¼¼È÷ ¼³¸íÇÕ´Ï´Ù. (·¹ÆÛ·±½º´Â expat/reference ÂüÁ¶)

ÀÌ [http]zip È­ÀÏÀº ÀÌ ¾ÆÆ¼Å¬¿¡¼­ »ç¿ëµÈ Makefile°ú ¼Ò½ºÄڵ带 ´ã°í ÀÖ½À´Ï´Ù.

À§ ÇÔ¼öµéÁß ´ÜÁö 3°³¸¸À» »ç¿ëÇÏ´Â ¾ÆÁÖ °£´ÜÇÑ ÇÁ·Î±×·¥À» º¸µµ·Ï ÇսôÙ(¹®ÀÚ Çڵ鷯¸¦ ¼³Á¤ÇÒ ÇÊ¿ä´Â ¾ø½À´Ï´Ù) ÇÁ·Î±×·¥ [http]outline.cÀº ±¸¼º¿ä¼ÒÀÇ ¿ä¾àÀ» Ãâ·ÂÇϴµ¥, ºÎ¸ð ¿ä¼Ò¿Í ±¸ºÐµÇµµ·Ï ÀÚ½Ä ¿ä¼Ò´Â µé¿©¾²±âÇÏ¿© Ãâ·ÂÇÕ´Ï´Ù. start Çڵ鷯°¡ ¸ðµç ÀÛ¾÷À» ¼öÇàÇÕ´Ï´Ù. ÀÌ Çڵ鷯´Â ºÎ¸ð ±¸¼º¿ä¼ÒÀÇ °¢ ´Ü°è¸¶´Ù µé¿©¾²±â¸¦ À§ÇØ 2°³ÀÇ space ¹®ÀÚ¸¦ Ãâ·ÂÇÑ´ÙÀ½, ±¸¼º¿ä¼Ò¿Í ¼Ó¼º Á¤º¸¸¦ Ãâ·ÂÇÕ´Ï´Ù. ¸¶Áö¸·À¸·Î Depth Àü¿ª º¯¼ö¸¦ Áõ°¡½Ãŵ´Ï´Ù.

int Depth;

void
start(void *data, const char *el, const char **attr) {
  int i;

  for (i = 0; i < Depth; i++)
    printf("  ");

  printf("%s", el);

  for (i = 0; attr[i]; i += 2) {
    printf(" %s='%s'", attr[i], attr[i + 1]);
  }

  printf("\n");
  Depth++;
}

end ű״ ´ÜÁö Depth¸¦ °¨¼Ò½ÃŰ´Â ÀÛ¾÷¸¸ ½ÇÇàÇÕ´Ï´Ù.

void
end(void *data, const char *el) {
  Depth--;
}

ÆÄ¼­¸¦ »ý¼ºÇÑ ÀÌÈÄ¿¡´Â main ÇÁ·Î±×·¥Àº ´ÜÁö ¹®¼­ÀÇ ³»¿ëÀ» ÆÄ¼­·Î ÆÛ³Ö´Â ÀÛ¾÷¸¸À» ½ÇÇàÇÏ¸ç ±×°Ô ÀüºÎÀÔ´Ï´Ù.

3 expatÀ» ºôµåÇϱâ #

One of the problems with using expat is that isn't packaged as a library. Instead there are four separate object files that you have to link into your application. The Makefile that builds the sample applications in this article can be used as a template.

4 ÄÄÆÄÀÏ ¼³Á¤º¯¼öµé #

There are a few compiletime macros that control how the compiled expat behaves:
XML_UNICODEUse UTF-16 internally and pass strings to application using UTF-16 instead of UTF-8. This changes the type definition of XML_Char, which would otherwise be defined as char.
XML_UNICODE_WCHAR_TUse UTF-16 internally as declared as wchar_t from <stddef.h>. and pass strings to application this way. This sets XML_UNICODE if it wasn't already set. If XML_UNICODE is set but not XML_UNICODE_WCHAR_T, then the UTF-16 is stored as unsigned short.
XML_DTDInclude code to parse external DTD.
XML_NSDo lexical checking of namespaces
XML_BYTE_ORDERSet this to "12" for little-endian machines (machines that have the least significant byte first) and to "21" for big-endian (most significant byte first.)
XML_MIN_SIZEMakes a parser that's smaller but that, in general, will run slower.

If your system doesn't have memmove, but does have bcopy, then you'll want to have a macro that redfines memmove to bcopy. There's a Makefile macro that does this in the sample Makefile, XP_MM. You'll have to uncomment its definition in order to have it take effect.

5 expatÀ» ÀÌ¿ëÇÏ¿© ÀÛ¾÷Çϱâ #

°³¿ä¿¡¼­ ÀÌ¹Ì ¾ð±ÞÇß½À´Ï´Ù¸¸, ¹®¼­´Â Çѹø¿¡ ÇÑ Á¶°¢¾¿ ³ª´©¾î ÆÄ¼­¿¡ °ø±ÞµË´Ï´Ù. It is completely up to the calling application how much of the document to fit into a piece. ¿¹Á¦ ÇÁ·Î±×·¥ lineÀº À̰Ϳ¡ ´ëÇÑ ¿¹¸¦ º¸¿©ÁÖ°í ÀÖ½À´Ï´Ù. ÀÌ ¿¹Á¦´Â Çѹø¿¡ ÇÑÁÙ¾¿ ÆÄ¼­¿¡ ³»¿ëÀ» Àü´ÞÇÑ´ÙÀ½, start, end, test, processing ¸í·É À̺¥Æ®¸¦ ¹®¼­¿¡ ¾Ë·ÁÁÝ´Ï´Ù. ÀÌ ÇÁ·Î±×·¥¿¡ ¹®¼­¸¦ ÀÔ·ÂÇØ º½À¸·Î¼­ ÆÄ¼­ÀÇ µ¿ÀÛ ¿ø¸®¿¡ ´ëÇÑ °³³äÀû ´À³¦À» ¾òÀ» ¼ö ÀÖÀ» °Ì´Ï´Ù.

½ºÆ®¸² ±â¹Ý ÆÄ¼­¸¦ »ç¿ëÇÏ¿© ¹®¼­ÀÇ °¢ °èÃþÀ» °Ë»öÇÏ´Â °ÍÀº ÇöÀç ¹®¸ÆÀ» ÃßÀûÇϱâÀ§ÇÑ ½ºÅÃÀ» ÇÊ¿ä·Î ÇÕ´Ï´Ù. ¿¹¸¦ µé¾î "ÀÌ ¹®ÀÚ¿­ÀÌ ¼ÓÇØÀÖ´Â ±¸¼º¿ä¼Ò űװ¡ ¹¹Áö?"¸¦ ±¸ÇöÇÏ·Á¸é ½ºÅÃÀÌ ÇÊ¿äÇѵ¥, ÀÌ´Â ÆÄ¼­´Â ÇöÀç ¿ä¼ÒÀÇ ÀڽĿä¼ÒÀÎ ´Ù¸¥ ÅÂ±× ¿ä¼Ò·Î À̵¿Çß°í ÀÌ ¹®ÀÚ¿­Àº ÀÌ¹Ì Áö³ªÃĹö·È±â ¶§¹®ÀÔ´Ï´Ù.

½ºÅÃÀ» »ç¿ëÇÏ¿© ¿©·¯ºÐÀÌ ÇϰíÀÚ ÇÏ´Â °ÍÀº ÇöÀç ¿­·ÁÀÖ´Â ¿ä¼Ò ÅÂ±×¿Í ±× ¼Ó¼ºÀ» ¾Ë¾Æ³»´Â °Í ÀÔ´Ï´Ù. ¿©·¯ºÐÀº ÀÌ Á¤º¸¸¦ start Çڵ鷯¿¡¼­ pushÇϰí end Çڵ鷯¿¡¼­ popÇÏ´Â ¹æ½ÄÀ¸·Î ó¸®ÇÒ ¼ö ÀÖ½À´Ï´Ù.

¸î¸î °æ¿ì¿¡¼­´Â ½ºÅÃÀÇ ±íÀ̰¡ ¾ó¸¶ÀÎÁö ¾Ë¾Æ³»´Â °Í¸¸À¸·Îµµ ÃæºÐÇÒ ¼ö ÀÖ½À´Ï´Ù. outline ¿¹Á¦¿¡¼­´Â ÀÌ¿Í °°Àº °æ¿ì¸¦ ±¸ÇöÇÑ °ÍÀÔ´Ï´Ù. ÀÌ·¯ÇÑ ¶Ç´Ù¸¥ 󸮴 ¿ÏÀüÇÑ ±¸¼º ű׽ÖÀ¸·Î ÆÇÁ¤µÇ¸é 󸮸¦ °Ç³Ê¶Ù´Â °ÍÀÔ´Ï´Ù. °Ç³Ê¶Ù°íÀÚÇÏ´Â ±¸¼º Å×±×ÀÇ ½ÃÀÛ Å±׸¦ º¸¾Ò´Ù¸é skip ¿É¼Ç º¯¼ö¿¡ °ªÀ» ¼³Á¤Çϰí, ±× ±¸¼º¿ä¼Ò°¡ ½ÃÀÛÇßÀ» ¶§ÀÇ ±íÀ̸¦ ÀúÀåÇÕ´Ï´Ù. end ÅÂ±× Çڵ鷯°¡ ÀúÀåµÈ ±íÀÌÀ϶§ È£ÃâµÇ¸é, ¿©±â±îÁö°¡ °Ç³Ê¶Û ±¸¼º¿ä¼ÒÀÇ ³¡À̹ǷΠ¿É¼Ç º¯¼ö°ªÀ» ÇØÁ¦»óÅ·Π¼³Á¤ÇÕ´Ï´Ù. ¸¸¾à root ±¸¼º¿ä¼Ò°¡ 1ºÎÅÍ ½ÃÀÛÇÑ´Ù´Â °ü¿ë¹ýÀ» µû¸¥´Ù¸é, °Ç³Ê¶Ù±â(skip) ¿É¼Ç°ú °Ç³Ê¶Ù±â ±íÀÌ º¯¼ö¿¡ ´ëÇØ °°Àº º¯¼ö¸¦ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.

void
init_info(Parseinfo *info) {
  info->skip = 0;
  info->depth = 1;
  /* Other initializations here */
}  /* End of init_info */

void
rawstart(void *data, const char *el, const char **attr) {
  Parseinfo *inf = (Parseinfo *) data;

  if (! inf->skip) {
    if (should_skip(inf, el, attr)) {
      inf->skip = inf->depth;
    }
    else
      start(inf, el, attr);     /* This does rest of start handling */
  }

  inf->depth++;
}  /* End of rawstart */

void
rawend(void *data, const char *el) {
  Parseinfo *inf = (Parseinfo *) data;

  inf->depth--;

  if (! inf->skip)
    end(inf, el);              /* This does rest of end handling */

  if (inf->skip == inf->depth)
    inf->skip = 0;
}  /* End rawend */

Notice in the above example the difference in how depth is manipulated in the start and end handlers. The end tag handler should be the mirror image of the start tag handler. This is necessary to properly model containment. Since, in the start tag handler, we incremented depth after the main body of start tag code, then in the end handler, we need to manipulate it before the main body. If we'd decided to increment it first thing in the start handler, then we'd have had to decrement it last thing in the end handler.

6 Çڵ鷯°£¿¡ Åë½ÅÇϱâ #

Àü¿ª º¯¼öµéÀ» »ç¿ëÇÏÁö ¾Ê°í ¼­·Î ´Ù¸¥ Çڵ鷯 °£¿¡ Á¤º¸¸¦ Àü´ÞÇÒ ¼ö ÀÖÀ¸·Á¸é °øÀ¯ÇÒ º¯¼öµéÀ» ´ãÀ» µ¥ÀÌŸ ±¸Á¶Ã¼¸¦ Á¤ÀÇÇØ¾ß¸¸ ÇÕ´Ï´Ù. ¿©·¯ºÐÀº Çڵ鷯µé¿¡°Ô ÀÌ ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅ͸¦ Àü´ÞÇϱâ À§ÇØ (XML_SetUserData ÇÔ¼ö¸¦ »ç¿ëÇÏ¿©) expat¿¡ ÀÌ Æ÷ÀÎÅ͸¦ ÁöÁ¤ÇÒ ¼ö ÀÖ½À´Ï´Ù. ÀÌ °ªÀº ´ëºÎºÐÀÇ Çڵ鷯µéÀÇ Ã¹¹øÂ° ¸Å°³º¯¼ö·Î ÁöÁ¤µÇ¾îÀÖ½À´Ï´Ù.

7 ³×ÀÓ½ºÆäÀ̽º ó¸® #

ÆÄ¼­¸¦ »ý¼ºÇÒ ¶§ XML_ParserCreateNSÇÔ¼ö¸¦ »ç¿ëÇϸé expatÀº À̸§°ø°£Ã³¸®¸¦ ½ÇÇàÇÕ´Ï´Ù. À̸§°ø°£ ó¸®ÇÏ¿¡¼­´Â expatÀº xmlns¿Í xmlns: ¼Ó¼ºÀ» ó¸®Çϴµ¥, À̵éÀº ÁöÁ¤µÈ ±¸¼º¿ä¼ÒÀÇ À¯È¿¹üÀ§¸¦ À§ÇÑ À̸§°ø°£À» Á¤ÀÇÇÕ´Ï´Ù. ÀÌ´Â ½ÃÀÛ Çڵ鷯¿¡¼­´Â ÀÌµé ¼Ó¼ºÀ» ¾ËÁö ¸øÇÑ´Ù´Â °ÍÀ» ÀǹÌÇÕ´Ï´Ù. ÇÏÁö¸¸ ¾îÇø®ÄÉÀ̼ÇÀº XML_SetNamespaceDeclHandler·Î »ç¿ëÇÏ¿© À̸§°ø°£ ó¸® Çڵ鷯¸¦ ¼³Á¤ÇÔÀ¸·Î¼­ À̵é Á¤ÀÇ¿¡ ´ëÇÏ¿© ó¸®ÇÒ ¼ö ÀÖ½À´Ï´Ù.

ÁÖ¾îÁø À̸§°ø°£¿¡ ¼ÓÇÑ ±¸¼º¿ä¼Ò ŸÀÔ°ú ¼Ó¼º¸íÀº È®Àå ¾ç½ÄÀ» °¡Áø ¾Ë¸ÂÀº Çڵ鷯·Î Àü´ÞµË´Ï´Ù. ÀÌ È®Àå¾ç½ÄÀº À̸§°ø°£ URI, ±¸ºÐÀÚ ¹®ÀÚ(XML_ParserCreateNSÀÇ µÎ¹øÂ° ¸Å°³º¯¼ö)¿Í Áö¿ª¸í(¿¹:ÄÝ·Ð ¹®ÀÚ ÀÌÈÄ ºÎºÐ)ÀÔ´Ï´Ù.

You can set handlers for the start of a namespace declaration and for the end of a scope of a declaration with the XML_SetNamespaceDeclHandler function. The StartNamespaceDeclHandler is called prior to the start tag handler and the EndNamespaceDeclHandler is called before the corresponding end tag that ends the namespace's scope. The namespace start handler gets passed the prefix and URI for the namespace. For a default namespace declaration (xmlns='...'), the prefix will be null. The URI will be null for the case where the default namespace is being unset. The namespace end handler just gets the prefix for the closing scope.

These handlers are called for each declaration. So if, for instance, a start tag had three namespace declarations, then the StartNamespaceDeclHandler would be called three times before the start tag handler is called, once for each declaration.

The namespace.c example demonstrates the use of these features. Like outline.c, it produces an outline, but in addition it annotates when a namespace scope starts and when it ends. This example also demonstrates use of application user data.

8 ¹®ÀÚ ÀÎÄÚµù #

While XML is based on Unicode, and every XML processor is required to recognized UTF-8 and UTF-16 (1 and 2 byte encodings of Unicode), other encodings may be declared in XML documents or entities. For the main document, an XML declaration may contain an encoding declaration:
<?xml version="1.0" encoding="ISO-8859-2"?>

External parsed entities may begin with a text declaration, which looks like an XML declaration with just an encoding declaration:
<?xml encoding="Big5"?>

With expat, you may also specify an encoding at the time of creating a parser. This is useful when the encoding information may come from a source outside the document itself (like a higher level protocol.)

expat¿¡´Â 4°¡Áö ³»Àå ÀÎÄÚµù ¼³Á¤À» Áö¿øÇÕ´Ï´Ù:

  • UTF-8
  • UTF-16
  • ISO-8859-1
  • US-ASCII

Anything else discovered in an encoding declaration or in the protocol encoding specified in the parser constructor, triggers a call to the UnknownEncodingHandler. This handler gets passed the encoding name and a pointer to an XML_Encoding data structure. Your handler must fill in this structure and return 1 if it knows how to deal with the encoding. Otherwise the handler should return 0. The handler also gets passed a pointer to an optional application data structure that you may indicate when you set the handler.

Expat places restrictions on character encodings that it can support by filling in the XML_Encoding structure. include file:
  1. Every ASCII character that can appear in a well-formed XML document must be represented by a single byte, and that byte must correspond to it's ASCII encoding (except for the characters $@\^'{}~)
  2. Characters must be encoded in 4 bytes or less.
  3. All characters encoded must have Unicode scalar values less than or equal to 65535 (0xFFFF)This does not apply to the built-in support for UTF-16 and UTF-8
  4. No character may be encoded by more that one distinct sequence of bytes

XML_Encoding contains an array of integers that correspond to the 1st byte of an encoding sequence. If the value in the array for a byte is zero or positive, then the byte is a single byte encoding that encodes the Unicode scalar value contained in the array. A -1 in this array indicates a malformed byte. If the value is -2, -3, or -4, then the byte is the beginning of a 2, 3, or 4 byte sequence respectively. Multi-byte sequences are sent to the convert function pointed at in the XML_Encoding structure. This function should return the Unicode scalar value for the sequence or -1 if the sequence is malformed.

One pitfall that novice expat users are likely to fall into is that although expat may accept input in various encodings, the strings that it passes to the handlers are always encoded in UTF-8. Your application is responsible for any translation of these strings into other encodings.

9 ¿Ü¹« °³Ã¼ ÂüÁ¶¸¦ ´Ù·ç±â #

Expat does not read or parse external entities directly. Note that any external DTD is a special case of an external entity. If you've set no ExternalEntityRefHandler, then external entity references are silently ignored. Otherwise, it calls your handler with the information needed to read and parse the external entity.

Your handler isn't actually responsible for parsing the entity, but it is responsible for creating a subsidiary parser with XML_ExternalEntityParserCreate that will do the job. This returns an instance of XML_Parser that has handlers and other data structures initialized from the parent parser. You may then use XML_Parse or XML_ParseBuffer calls against this parser. Since external entities my refer to other external entities, your handler should be prepared to be called recursively.

10 DTD ÆÄ½Ì #

In order to parse parameter entities, the macro XML_DTD, must be defined when expat is compiled. In addition, after creating the parser and before starting the parse, you must call XML_SetParamEntityParsing with one of the following arguments:

XML_PARAM_ENTITY_PARSING_NEVERDon't parse parameter entities or the external subset
XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONEParse parameter entites and the external subset unless standalone was set to "yes" in the XML declaration.
XML_PARAM_ENTITY_PARSING_ALWAYSAlways parse parameter entities and the external subset

In order to read an external subset, you also have to set an external entity reference handler as described above.


EditText | FindPage | DeletePage | LikePages

Powered by MoniWiki
xhtml1 | css2 | any browser | rss
Last modified 2005-01-11 13:27:23
Loading 0.4625 sec