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

Re: Parameterized entities?

  • From: Roger L Costello <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Thu, 16 Jun 2022 12:20:48 +0000

Re:  Parameterized entities?

Thank you David. It is a shame XML doesn’t support parameterized ENTITY’s.

 

I decided to write a simple preprocessor using the Flex lexical analyzer.  It converts the following “fake” ENTITY references:

 

    &file('ARPT.XML');

    &file('NAV.XML');

    &file('TRM.XML');

 

into these XSLT variable declarations:

 

    <xsl:variable name='ARPT.XML' select="doc('ARPT.XML')"/>

    <xsl:variable name='NAV.XML' select="doc('NAV.XML')"/>

    <xsl:variable name='TRM.XML' select="doc('TRM.XML')"/>

 

For those interested, the Flex lexical analyzer that I created is shown below. Here’s how I run it from a command line:

 

more sample.xsl | preprocess > result.xsl

 

Here is the preprocessor (Flex lexical analyzer). I am sure that a skilled C programmer could write much better C code (the stuff within braces below) to extract the filename. If you are a skilled C programmer and have suggestions for improvement, I would love to hear them!

 

%option noyywrap

%{

#include <string.h>

%}

%%

"&file('"[A-Z]+".XML');"           {

                                                           char replacement[20];

                                                           char *start = strstr(yytext, "'");

                                                           char *end   = strstr(yytext, ".");

                                                           int length = end - start - 1;

                                                           char *marker = start + 1;

                                                           int i;

                                                           for (i=0; i<length; i++)

                                                              replacement[i] = *marker++;

                                                           replacement[i]    = '\0';

                                                           fprintf(stdout, "<xsl:variable name='%s.XML' select=\"doc('%s.XML')\"/>", replacement, replacement);

                               }

%%

int main()

{yylex();}



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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.