Re: [xsl] Validation XSLT using XSLT 1.0

Subject: Re: [xsl] Validation XSLT using XSLT 1.0
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Thu, 03 Jul 2008 09:44:51 +0200
Ganesh Babu N schrieb:
1. [...] My question is how to get entity name and value in to a test.

<!ENTITY I9780073379470_A_TB004 SYSTEM "9780073379470_A_TB004.tif" NDATA TIFF>

<graphic picfile="I9780073379470_A_TB004"/>

To ensure a value equals another one, maybe you can use the DTD ID and IDREF feature, and then validate the document against the DTD.

I don't understand why you define an entity the name of which seems to
be identical to its value. What's the point?

2. In the XML file we are using named entities eg:- &nbsp; &acute;
instead of &#123; or &#x123; in XSLT how to find if the XML file
contains entities other than named entities?

Maybe this is an opportunity for the DPH (Desperate Perl Hacker) to come back on stage: You could search the document using a regular expression (yes!) and replace all unwanted numerical entities with named entities of your liking, or - Oxford comma - the official HTML entity catalogue.

Does anyone know of a tool that parses an XML document and outputs it
as ASCII replacing characters with named entities instead of numeric
entites? Named entites you'd probably have to supply yourself?

3. How to find non-ascii characters in the XML file and report an
error using XSLT.

Don't use XSLT for this. Add the following XML declaration to your input documents:

<?xml version="1.0" encoding="us-ascii"?>

This will ensure the document won't get parsed unless it is pure ASCII.

4. How to find double enters in the XML file and report an error
using XSLT.

While not tackling the specific problem you're presenting, maybe this XSL gets you somewhere near your desired result:

<xsl:transform version="1.0"
  <xsl:strip-space elements="*"/>
  <xsl:output indent="yes"/>
  <xsl:template match="@*|node()">
      <xsl:apply-templates select="@*|node()"/>

Michael Ludwig

Current Thread