xsl-list
[Top] [All Lists]

Re: [xsl] Checking external files based on the attribute value

2008-08-17 22:02:39
Thank you very much Darcy for your detailed suggestions.

Regards,
Ganesh


On 8/14/08, Darcy Parker <darcyparker(_at_)gmail(_dot_)com> wrote:
Hi Ganesh,

As mentioned by others, the Schematron Mailing List doesn't receive
many postings... but it is a good forum to ask questions.
http://www.eccnet.com/mailman/listinfo/schematron

To me it seems like you just need practice thinking about and writing
XPath expressions.  Others here and on the Schematron mailing list can
probably help with XPath statements if you get stuck.

FYI on other applicable resources:

I first learned about Schematron in chapter 16 of "Beginning XSLT" by
Jeni Tennison.  It was an excellent introduction with many example
XPaths to study.  I was disappointed that this chapter on schematron
was removed from the more recent edition of her book on XSLT.  If you
can locate a copy of the first edition "Beginning XSLT", I recommend
it.  (It will probably be cheaper because it is only available used.)

The O'Reilly XSLT 2.0 Cookbook also has a chapter with example XPath
expressions that I found a useful learning tool.

Dave Pawson also wrote an excellent tutorial on Schematron.
http://www.dpawson.co.uk/schematron/

Darcy

On Thu, Aug 14, 2008 at 12:00 AM, Ganesh Babu N 
<nbabuganesh(_at_)gmail(_dot_)com>
wrote:
Dear Darcy,

I am writing an schematron and i struck in this case. I did not found
any forum which is providing help on schematron. As the schematron is
based on XSLT and XPath I am raising the questions here.

Thanks once again for you ready made solution for me.

Regards,
Ganesh


On 8/13/08, Darcy Parker <darcyparker(_at_)gmail(_dot_)com> wrote:
Hi Ganesh,

There are a few problems with your expression...

The predicate is:
contains(.,substring-after(concat(@picfile,'.tif'),'I'))

Note: There is no @picfile attribute in the
document('filelist.xml')/files/file elements... so
concat(@picfile,'.tif') is going to just return '.tif'.

I don't think you need boolean()

I am assuming your are running the XSL with <graphic
picfile="I970106058X_bulb"/> in your input XML.

I am not sure the context you are calling the expression that checks
for the presence of the slightly modified @picfile value in
filelist.xml... So the following is a guess along with a suggested new
expression:

<xsl:for-each select="//graphic/@picfile"/>
   <xsl:variable name="Currentpicfile" select="."/>
   <xsl:choose>
     <xsl:when
test="document('filelist.xml')/files/file[contains(.,substring-after(concat($Currentpicfile,'.tif'),'I'))]">
         Good
     </xsl:when>
     <xsl:otherwise>
         Bad
     </xsl:otherwise>
   </xsl:choose>
</xsl:for-each>

Note:
This type of check is what Schematron is excellent at...

<?xml version="1.0" encoding="UTF-8"?>

<schema       xmlns="http://purl.oclc.org/dsdl/schematron";
                      xmlns:iso="http://purl.oclc.org/dsdl/schematron";
                      schemaVersion="Test1.0">
      <title>Example</title>

      <let name="RVPStructure"
value="doc(concat($RVPDITABranchHomeURL,'/wbs_precompose/ExpandedRVPStructure.xml'))"/>

      <pattern id="GeneralExecutionSteps.Checks">
              <title>Example Pattern</title>
              <rule context="//graphic/@picfile">
                  <let name="Currentpicfile" value="."/>
                  <assert
test="document('filelist.xml')/files/file[contains(.,substring-after(concat($Currentpicfile,'.tif'),'I'))]">Error
@picfile="<value-of select="."/>" does not exist in
filelist.xml</assert>
              </rule>
      </pattern>
</schema>

Darcy

On Wed, Aug 13, 2008 at 9:12 AM, Ganesh Babu N 
<nbabuganesh(_at_)gmail(_dot_)com>
wrote:

Dear All,

I am having an XML file in which I am having the following coding

                               <graphic picfile="I970106058X_bulb"/>

All the graphic filenames are stored in a separate XML file the contents
are:

filelist.xml

<files>
<file>./970106058X_c01_0002.tif</file>
<file>./970106058X_c01_0001.tif</file>
<file>./970106058X_bulb.tif</file>
<file>./970106058X_0000.tif</file>
<file>./970106058X_c01_0003.tif</file>
</files>


Now my task is to search the filelist.xml for @picfile value and if it
is not found raise an error.
I am using the following code:

boolean(document('filelist.xml')/files/file[contains(.,
substring-after(concat(@picfile,'.tif'),'I'))] )

But i am not getting any message. Please help me how to achieve this
task.

Regards,
Ganesh

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--