Loading ...
Sorry, an error occurred while loading the content.

Multiple XML Files as Input

Expand Messages
  • sg_goli@yahoo.com
    Hi I am resposting this question as i had no luck so far to achieve the following, I am trying to do something like this, with 2 XML files. 1. Highland
    Message 1 of 3 , May 14, 2001
    • 0 Attachment
      Hi

      I am resposting this question as i had no luck so far to achieve
      the following, I am trying to do something like this, with 2 XML
      files.

      1.
      <CITY>Highland Park</CITY>
      <STATE>NJ</STATE>
      <CITY>Elmhurst</CITY>
      <STATE>NY</STATE>

      2.
      <SHORTSTATE>NJ</SHORTSTATE>
      <LONGSTATE>New Jersey</LONGSTATE>
      <SHORTSTATE>NY</SHORTSTATE>
      <LONGSTATE>New York</LONGSTATE>


      I will have to match on state and get the long name from XML 2.

      I am using XALAN, XERCER and FOP to generate PDF.

      Thanks
    • ronald heller
      Your question is a XSLT one, not FO, but I gave it a go anyway. I think I have solved your problem try the example below. Use the stylesheet on a.xml and it ll
      Message 2 of 3 , May 15, 2001
      • 0 Attachment
        Your question is a XSLT one, not FO, but I gave it a go anyway.
        I think I have solved your problem try the example below.
        Use the stylesheet on a.xml and it'll work like a charm.
        Maybe it's not as good and clean as it should be, but I'm not stopping you
        for cleaning up the code. :-)

        Ronald Heller

        I used the following sources:

        a.xml
        <?xml version="1.0"?>
        <ROOT>

        <CITY>Highland Park</CITY>
        <STATE>NJ</STATE>

        <CITY>Elmhurst</CITY>
        <STATE>NY</STATE>

        </ROOT>

        b.xml
        <?xml version="1.0"?>
        <ROOT>
        <SHORTSTATE>NJ</SHORTSTATE>

        <LONGSTATE>New Jersey</LONGSTATE>

        <SHORTSTATE>NY</SHORTSTATE>

        <LONGSTATE>New York</LONGSTATE>
        </ROOT>

        xsl:
        <?xml version="1.0"?>
        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/">
        <xsl:apply-templates select="ROOT"/>
        </xsl:template>

        <xsl:template match="ROOT">
        <xsl:for-each select="//STATE">
        <xsl:variable name="STATE"><xsl:value-of select="."/></xsl:variable>
        <xsl:text>
        - </xsl:text>
        <xsl:value-of select="$STATE"/>
        <xsl:text> Long name:</xsl:text>
        <xsl:value-of
        select="document('b.xml')//LONGSTATE[preceding-sibling::SHORTSTATE=$STATE]"/>

        </xsl:for-each>
        </xsl:template>

        </xsl:stylesheet>

        my result:
        - NJ Long name:New Jersey

        - NY Long name:New York

        This should help I think.
      • Sangeetha Goli
        Thanks! that s exactly what i needed. SG ... select= document( b.xml )//LONGSTATE[preceding-sibling::SHORTSTATE=$STATE] / ...
        Message 3 of 3 , May 17, 2001
        • 0 Attachment
          Thanks! that's exactly what i needed.


          SG
          --- ronald heller <ronald@...> wrote:
          > Your question is a XSLT one, not FO, but I gave it a
          > go anyway.
          > I think I have solved your problem try the example
          > below.
          > Use the stylesheet on a.xml and it'll work like a
          > charm.
          > Maybe it's not as good and clean as it should be,
          > but I'm not stopping you
          > for cleaning up the code. :-)
          >
          > Ronald Heller
          >
          > I used the following sources:
          >
          > a.xml
          > <?xml version="1.0"?>
          > <ROOT>
          >
          > <CITY>Highland Park</CITY>
          > <STATE>NJ</STATE>
          >
          > <CITY>Elmhurst</CITY>
          > <STATE>NY</STATE>
          >
          > </ROOT>
          >
          > b.xml
          > <?xml version="1.0"?>
          > <ROOT>
          > <SHORTSTATE>NJ</SHORTSTATE>
          >
          > <LONGSTATE>New Jersey</LONGSTATE>
          >
          > <SHORTSTATE>NY</SHORTSTATE>
          >
          > <LONGSTATE>New York</LONGSTATE>
          > </ROOT>
          >
          > xsl:
          > <?xml version="1.0"?>
          > <xsl:stylesheet version="1.0"
          > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
          > <xsl:template match="/">
          > <xsl:apply-templates select="ROOT"/>
          > </xsl:template>
          >
          > <xsl:template match="ROOT">
          > <xsl:for-each select="//STATE">
          > <xsl:variable name="STATE"><xsl:value-of
          > select="."/></xsl:variable>
          > <xsl:text>
          > - </xsl:text>
          > <xsl:value-of select="$STATE"/>
          > <xsl:text> Long name:</xsl:text>
          > <xsl:value-of
          >
          select="document('b.xml')//LONGSTATE[preceding-sibling::SHORTSTATE=$STATE]"/>
          >
          > </xsl:for-each>
          > </xsl:template>
          >
          > </xsl:stylesheet>
          >
          > my result:
          > - NJ Long name:New Jersey
          >
          > - NY Long name:New York
          >
          > This should help I think.
          >
          >


          __________________________________________________
          Do You Yahoo!?
          Yahoo! Auctions - buy the things you want at great prices
          http://auctions.yahoo.com/
        Your message has been successfully submitted and would be delivered to recipients shortly.