Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > In saxon XSLT, getting Content is not allowed in prolog, can't outputmarkup in a processing instruction.

Reply
Thread Tools

In saxon XSLT, getting Content is not allowed in prolog, can't outputmarkup in a processing instruction.

 
 
stryder100@gmail.com
Guest
Posts: n/a
 
      02-25-2009
Hi. I'm processing a stylesheet with saxonb9-1-0-5j and am trying to
output a processing instruction that has an exact copy of some markup
in it. I'm running into the same problem whether I use the java
version of SAXON on UNIX or the Windows/.Net version.

Here's what I'm trying.

<xsl:for-each select="//footnote">
<xslrocessing-instruction name="footnote"><xsl:value-
of select="."/></xslrocessing-instruction>
</xsl:for-each>

This doesn't give me what I want because I guess it applies the
"default" template and just outputs the text as the body of the PI.
However if I try to output parsed data as the body of the processing
instruction using the saxon parse function like this...

<xsl:for-each select="//footnote">
<xslrocessing-instruction name="footnote"><xsl:value-
of select="saxonarse(.)"/></xslrocessing-instruction>
</xsl:for-each>

or even...

<xsl:for-each select="//footnote">
<xslrocessing-instruction name="footnote"
select="saxonarse(.)"/>
</xsl:for-each>

I get a runtime error "SXXP0003: Error reported by XML parser: Content
is not allowed in prolog.". As I understand it the "prolog" is what
occurs outside of the document element of an XML document, like a DTD
declaration or an <?xml ... ?> declaration. But I'm trying to output
this processing instruction inside the document element. It even
gives me this error message when I just try and output this PI in
place, right where the footnote is...

<xsl:template match="footnote">
<xslrocessing-instruction name="footnote"><xsl:value-of
select="saxonarse(.)"/></xslrocessing-instruction>
</xsl:template>

This gives me the "Content not allowed in prolog" error also, even
though the <footnote> is inside the document element.

According to http://www.w3.org/TR/REC-xml/#NT-Char there are no real
limitations on what can be included as the body of a PI, certainly no
exceptions that could possibly exist in a footnote's content.

I've tried numerous other combinations using <xsl:copy>, <xsl:copy-
of>, <xsl:variable>, <xsl:apply-templates>, all sorts of trickery to
try and accomplish this to no avail.

I'm able to output markup in a processing instruction if I define it
literally, as in...

<xslrocessing-instruction name="footnote">"&lt;tag&gt;here's some
arbitrary data&lt;/tag&gt;"</xslrocessing-instruction>

which outputs

<?footnote "<tag>here's some arbitrary data</tag>"?>

This suggests that technically I CAN put markup in the data in a
processing instruction, I just can't put in parsed data from the
document. Or something.

If anyone knows a way to do it I'd be most appreciative.

Thanks.


 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      02-25-2009
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi. I'm processing a stylesheet with saxonb9-1-0-5j and am trying to
> output a processing instruction that has an exact copy of some markup
> in it. I'm running into the same problem whether I use the java
> version of SAXON on UNIX or the Windows/.Net version.
>
> Here's what I'm trying.
>
> <xsl:for-each select="//footnote">
> <xslrocessing-instruction name="footnote"><xsl:value-
> of select="."/></xslrocessing-instruction>
> </xsl:for-each>
>
> This doesn't give me what I want because I guess it applies the
> "default" template and just outputs the text as the body of the PI.


In the above no default template is applied, indeed no template at all
is applied. You just have a for-each outputting a processing instruction
for each 'footnote' element.
Thus if that does not do what you want you would better show us a
minimal but complete XML input document and the transformation result
you want to create from that input.
So how do your 'footnote' elements in the XML input look exactly? And
what kind of processing instructions do you want to generate from them?

> I'm able to output markup in a processing instruction if I define it
> literally, as in...
>
> <xslrocessing-instruction name="footnote">"&lt;tag&gt;here's some
> arbitrary data&lt;/tag&gt;"</xslrocessing-instruction>
>
> which outputs
>
> <?footnote "<tag>here's some arbitrary data</tag>"?>
>
> This suggests that technically I CAN put markup in the data in a
> processing instruction, I just can't put in parsed data from the
> document. Or something.


I don't know how the your 'footnote' elements look but it sounds as if
you want to serialize nodes into a string of markup so saxon:serialize
might do what you want:
http://www.saxonica.com/documentatio...serialize.html

But I am guessing, show us the XML input you have and the transformation
result, then it is possible to tell how to achieve that.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Stryder
Guest
Posts: n/a
 
      02-25-2009
On Feb 25, 11:48*am, Martin Honnen <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > Hi. *I'm processing a stylesheet with saxonb9-1-0-5j and am trying to
> > output a processing instruction that has an exact copy of some markup
> > in it. *I'm running into the same problem whether I use the java
> > version of SAXON on UNIX or the Windows/.Net version.

>
> > Here's what I'm trying.

>
> > * * * * * * <xsl:for-each select="//footnote">
> > * * * * * * * * <xslrocessing-instruction name="footnote"><xsl:value-
> > of select="."/></xslrocessing-instruction>
> > * * * * * * </xsl:for-each>

>
> > This doesn't give me what I want because I guess it applies the
> > "default" template and just outputs the text as the body of the PI.

>
> In the above no default template is applied, indeed no template at all
> is applied. You just have a for-each outputting a processing instruction
> for each 'footnote' element.
> Thus if that does not do what you want you would better show us a
> minimal but complete XML input document and the transformation result
> you want to create from that input.
> So how do your 'footnote' elements in the XML input look exactly? And
> what kind of processing instructions do you want to generate from them?
>
> > I'm able to output markup in a processing instruction if I define it
> > literally, as in...

>
> > <xslrocessing-instruction name="footnote">"&lt;tag&gt;here's some
> > arbitrary data&lt;/tag&gt;"</xslrocessing-instruction>

>
> > which outputs

>
> > <?footnote "<tag>here's some arbitrary data</tag>"?>

>
> > This suggests that technically I CAN put markup in the data in a
> > processing instruction, I just can't put in parsed data from the
> > document. *Or something.

>
> I don't know how the your 'footnote' elements look but it sounds as if
> you want to serialize nodes into a string of markup so saxon:serialize
> might do what you want:http://www.saxonica.com/documentatio...ions/serialize....
>
> But I am guessing, show us the XML input you have and the transformation
> result, then it is possible to tell how to achieve that.
>
> --
>
> * * * * Martin Honnen
> * * * *http://JavaScript.FAQTs.com/


On Feb 25, 11:48 am, Martin Honnen <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > Hi. I'm processing a stylesheet with saxonb9-1-0-5j and am trying to
> > output a processing instruction that has an exact copy of some markup
> > in it. I'm running into the same problem whether I use the java
> > version of SAXON on UNIX or the Windows/.Net version.

>
> > Here's what I'm trying.

>
> > <xsl:for-each select="//footnote">
> > <xslrocessing-instruction name="footnote"><xsl:value-
> > of select="."/></xslrocessing-instruction>
> > </xsl:for-each>

>
> > This doesn't give me what I want because I guess it applies the
> > "default" template and just outputs the text as the body of the PI.

>
> In the above no default template is applied, indeed no template at all
> is applied. You just have a for-each outputting a processing instruction
> for each 'footnote' element.
> Thus if that does not do what you want you would better show us a
> minimal but complete XML input document and the transformation result
> you want to create from that input.
> So how do your 'footnote' elements in the XML input look exactly? And
> what kind of processing instructions do you want to generate from them?
>
> > I'm able to output markup in a processing instruction if I define it
> > literally, as in...

>
> > <xslrocessing-instruction name="footnote">"&lt;tag&gt;here's some
> > arbitrary data&lt;/tag&gt;"</xslrocessing-instruction>

>
> > which outputs

>
> > <?footnote "<tag>here's some arbitrary data</tag>"?>

>
> > This suggests that technically I CAN put markup in the data in a
> > processing instruction, I just can't put in parsed data from the
> > document. Or something.

>
> I don't know how the your 'footnote' elements look but it sounds as if
> you want to serialize nodes into a string of markup so saxon:serialize
> might do what you want:http://www.saxonica.com/documentatio...ions/serialize....
>
> But I am guessing, show us the XML input you have and the transformation
> result, then it is possible to tell how to achieve that.
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/


Thanks Martin. saxon:serialize is just what I needed.

In case this helps anyone else who comes across this thread, here's my
input footnote, the XSLT I'm using to process it, and the output.
Note that I'm also stripping newlines and multi-spaces with my XSLT
because it's possible a <footnote> will have some indenting. Also a
disclaimer - I probably wouldn't have designed things this way but
like so many others I'm maintaining and extending someone else's code.

Input:
<footnote link-ref="fn1268661_1_ref" link-id="fn1268661_1"><p><sup>1</
sup> Unless otherwise indicated, all section references are to the
Internal Revenue Code in effect for the taxable year at issue, and all
Rule references are to the Tax Court Rules of Practice and Procedure.</
p></footnote>

XSLT:
<xsl:for-each select="//footnote">
<xslrocessing-instruction
name="footnote">"<xsl:value-of select="replace(replace(saxon:serialize
(., 'serializer'), '&#xA;', ''), ' +', ' ')"/>"</xslrocessing-
instruction>
</xsl:for-each>

Output:
<?footnote "<footnote link-ref="fn1268661_1_ref" link-
id="fn1268661_1"> <p> <sup>1</sup> Unless otherwise indicated, all
section references are to the Internal Revenue Code in effect for the
taxable year at issue, and all Rule references are to the Tax Court
Rules of Practice and Procedure.</p> </footnote>"?>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why defining a constant in a method is not allowed but usingself.class.const_set is allowed? IƱaki Baz Castillo Ruby 13 05-01-2011 06:09 PM
error: Only Content controls are allowed directly in a content page that contains Content controls. hazz ASP .Net 6 06-09-2010 01:54 PM
Error: Content is not allowed between the opening and closing tags for element Allan Ebdrup ASP .Net 0 01-26-2006 08:45 AM
Saxon and XQuery : how not to repeat the XML source file name in the query ? pepin_labulle@yahoo.fr XML 0 07-04-2005 08:57 AM
"Literal content is not allowed within a user control"? =?Utf-8?B?RGF2ZQ==?= ASP .Net 0 05-17-2004 03:21 AM



Advertisments