Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT: Possible To Add X,Y Space If Additional XML Data Exists?

Status
Not open for further replies.

DavidC2

Programmer
Joined
Jul 20, 2004
Messages
5
Location
US
Back, again!

My query this time: In my XSLT, I am requesting data from my XML source files if it exists within specific elements and stating that if it does, stream and transform this data into an SVG at these given X,Y coordinates in my viewbox. To date, I have found nothing in either XSLT or SVG specifications that would allow for a flexible flow of data...all data seems to be etched in stone based on these X,Y coordinates. Am I wrong on this matter? Are X,Y coordinates more flexible than I have discovered? Please tell me "Yes"!

In my particular situation, I have flowchart logic-test's (my source XML files) which may contain any number of <step><para><pcnarr>'s (<pcnarr> being the only element which may contain PCDATA). These I have accommodated to flow into my XSLT transformed SVG as such:

Code:
SOURCE XSLT:

<xsl:template match="logic-test">
  <svg width="100%" height="100%">		
    <g>
      <xsl:for-each select="descendant-or-self::step">
        <xsl:if test="position()=1 and not(para/null)">
          <text x="10" y="75" style="text-anchor: start; font-size: 8pt;">
            <xsl:number format="1. " level="single"/>
              <xsl:value-of select="para/pcnarr"/>
          </text>
        </xsl:if>

        <xsl:if test="position()=2 and not(para/null)">
          <text x="10" y="90" style="text-anchor: start; font-size: 8pt;">
            <xsl:number format="1. " level="single"/>
              <xsl:value-of select="para/pcnarr"/>
          </text>
        </xsl:if>

        <xsl:if test="position()=3 and not(para/null)">
          <text x="10" y="105" style="text-anchor: start; font-size: 8pt;">
            <xsl:number format="1. " level="single"/>
              <xsl:value-of select="para/pcnarr"/>
          </text>
        </xsl:if>

        <xsl:if test="position()=4 and not(para/null)">
          <text x="10" y="105" style="text-anchor: start; font-size: 8pt;">
            <xsl:number format="1. " level="single"/>
              <xsl:value-of select="para/pcnarr"/>
          </text>
        </xsl:if>
<!-- A TABLE EXISTS HERE WITH 4 ROWS -->
        <xsl:if test="position()=5 and not(para/null)">
          <text x="10" y="105" style="text-anchor: start; font-size: 8pt;">
            <xsl:number format="1. " level="single"/>
              <xsl:value-of select="para/pcnarr"/>
          </text>
        </xsl:if>
<!-- A TABLE EXISTS HERE WITH 8 ROWS -->
      </xsl:for-each>
    </g>
    <xsl:apply-templates/>
  </svg>
</xsl:template>

My problem exists in that at any given time, these <step><para><pcnarr>'s may also include <table>'s between them, which in themselves may also contain any number of <row><entry><pcnarr>'s. Given the following <table>:

Code:
SOURCE XML:

<table frame="none" id=" ">
  <title><null/></title>
    <tgroup cols="2">
      <colspec align="right" colwidth="1.25in"/>
      <colspec align="left" colwidth="1.00in"/>
    <tbody>
      <row id="T00002-TS-11-5820-890-30-327">
        <entry align="right"><pcnarr>MODE:</pcnarr></entry>
        <entry align="left"><pcnarr>MTRS</pcnarr></entry>
      </row>
      <row id="T00002-TS-11-5820-890-30-328">
        <entry align="right"><pcnarr>SELECT:</pcnarr></entry>
        <entry align="left"><pcnarr>DMM</pcnarr></entry>
      </row>
      <row id="T00002-TS-11-5820-890-30-329">
        <entry align="right"><pcnarr>FUNCTION:</pcnarr></entry>
        <entry align="left"><pcnarr>DCV</pcnarr></entry>
      </row>
      <row id="T00002-TS-11-5820-890-30-330">
        <entry align="right"><pcnarr>RANGE:</pcnarr></entry>
        <entry align="left"><pcnarr>200 V</pcnarr></entry>
      </row>
    </tbody>
    </tgroup>
</table>

...and that this <table> falls after step #4 (having 4 rows) and that another similar <table> exists after step #5, is it at all possible to create some sort of a formula/counter/whatever which will be able to read the XML source file; determine that these <table>'s exist; and not only stream this tabulated data into the SVG, but provide the additional horizontal "Y" space necessary to accomodate however many <row><pcnarr>'s exist?

Or is this all just pushing the XSLT/SVG specifications too far? Possibly do-able with the assistance of JavaScript?

Any help on this issue would be geatly appreciated.

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top