working with saxon:unparsed-entities()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

working with saxon:unparsed-entities()

markus.sticker.epos

Hello Saxon,

 

I just want to ask: Is it possible to use saxon:unparsed-entities to get an entity from the
source document?

Because, I didn’t found any samples about that function.

 

The source

--------------8<-------------------------

<?xml version="1.0"?>

<!DOCTYPE XMLBlock SYSTEM dtd/XMLBlock.dtd" [

<!ENTITY change "<change><functionalChange><![CDATA[somewhere

over

the

rainbow    ]]></functionalChange><test><![CDATA[fsfsdfsf]]></test><testNotes><![CDATA[sfdssfsd]]></testNotes><dependencies><![CDATA[fsdffs]]></dependencies></change>">]>

<?change <change><functionalChange><![CDATA[ghjgj]]></functionalChange><test><![CDATA[]]></test><testNotes><![CDATA[]]></testNotes><dependencies><![CDATA[]]></dependencies></change>?>

<XMLBlock>

<someText>Lorem ipsum dolor sit amet, consetetur ...</someText>

</XMLBlock>

-------------->8-------------------------

 

The xslt

--------------8<-------------------------

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

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:saxon="http://saxon.sf.net/" version="2.0">

  <xsl:template match ="/">

    <xsl:variable name="change"><xsl:value-of select="processing-instruction('change')" disable-output-escaping="yes"/></xsl:variable>

    <xsl:variable name="ch2"><xsl:copy-of select="saxon:parse($change)" /></xsl:variable>

    <aaa>

       <xsl:for-each select="saxon:unparsed-entities(.)" >

         <xsl:copy-of select="." />

       </xsl:for-each>

      <bbb>

        <xsl:copy-of select="$ch2/change/functionalChange/text()" />

      </bbb>

    </aaa>

  </xsl:template>

</xsl:stylesheet>

-------------->8-------------------------

 

Thanks for your help. ( … saxon:parse works fine! )
Kind regards

Markus Sticker

 


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: working with saxon:unparsed-entities()

Michael Kay
Your example uses a parsed entity, not an unparsed entity. It’s not possible to obtain information about parsed entities: Saxon doesn’t have that information. You could try using LexEv from Andrew Welch, this converts the entity information into elements (IIRC) that can be processed using Saxon in the normal way.

saxon:unparsed-entities() is there largely because the information is known to Saxon (it’s needed to implement unparsed-entity-uri() and unparsed-entity-system-id()) so it seems reasonable to provide it to users. Not many people use unparsed entities, but those that do appreciate having improved support.

Michael Kay
Saxonica


On 6 Oct 2015, at 10:31, [hidden email] wrote:

Hello Saxon,

 

I just want to ask: Is it possible to use saxon:unparsed-entities to get an entity from the
source document?

Because, I didn’t found any samples about that function.

 

The source

--------------8<-------------------------

<?xml version="1.0"?>

<!DOCTYPE XMLBlock SYSTEM dtd/XMLBlock.dtd" [

<!ENTITY change "<change><functionalChange><![CDATA[somewhere

over

the

rainbow    ]]></functionalChange><test><![CDATA[fsfsdfsf]]></test><testNotes><![CDATA[sfdssfsd]]></testNotes><dependencies><![CDATA[fsdffs]]></dependencies></change>">]>

<?change <change><functionalChange><![CDATA[ghjgj]]></functionalChange><test><![CDATA[]]></test><testNotes><![CDATA[]]></testNotes><dependencies><![CDATA[]]></dependencies></change>?>

<XMLBlock>

<someText>Lorem ipsum dolor sit amet, consetetur ...</someText>

</XMLBlock>

-------------->8-------------------------

 

The xslt

--------------8<-------------------------

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

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:saxon="http://saxon.sf.net/" version="2.0">

  <xsl:template match ="/">

    <xsl:variable name="change"><xsl:value-of select="processing-instruction('change')" disable-output-escaping="yes"/></xsl:variable>

    <xsl:variable name="ch2"><xsl:copy-of select="saxon:parse($change)" /></xsl:variable>

    <aaa>

       <xsl:for-each select="saxon:unparsed-entities(.)" >

         <xsl:copy-of select="." />

       </xsl:for-each>

      <bbb>

        <xsl:copy-of select="$ch2/change/functionalChange/text()" />

      </bbb>

    </aaa>

  </xsl:template>

</xsl:stylesheet>

-------------->8-------------------------

 

Thanks for your help. ( … saxon:parse works fine! )
Kind regards

Markus Sticker

 

------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: working with saxon:unparsed-entities()

markus.sticker.epos

Hello Mr. Kay,

 

thanks for your help.

I tried to get it run but I didn’t get it managed to integrate it into Saxon.

Best regards

 

Markus Sticker

 

Von: Michael Kay [mailto:[hidden email]]
Gesendet: Dienstag, 6. Oktober 2015 11:46
An: Mailing list for the SAXON XSLT and XQuery processor
Betreff: Re: [saxon] working with saxon:unparsed-entities()

 

Your example uses a parsed entity, not an unparsed entity. It’s not possible to obtain information about parsed entities: Saxon doesn’t have that information. You could try using LexEv from Andrew Welch, this converts the entity information into elements (IIRC) that can be processed using Saxon in the normal way.

 

saxon:unparsed-entities() is there largely because the information is known to Saxon (it’s needed to implement unparsed-entity-uri() and unparsed-entity-system-id()) so it seems reasonable to provide it to users. Not many people use unparsed entities, but those that do appreciate having improved support.

 

Michael Kay

Saxonica

 

 

On 6 Oct 2015, at 10:31, [hidden email] wrote:

 

Hello Saxon,

 

I just want to ask: Is it possible to use saxon:unparsed-entities to get an entity from the
source document?

Because, I didn’t found any samples about that function.

 

The source

--------------8<-------------------------

<?xml version="1.0"?>

<!DOCTYPE XMLBlock SYSTEM dtd/XMLBlock.dtd" [

<!ENTITY change "<change><functionalChange><![CDATA[somewhere

over

the

rainbow    ]]></functionalChange><test><![CDATA[fsfsdfsf]]></test><testNotes><![CDATA[sfdssfsd]]></testNotes><dependencies><![CDATA[fsdffs]]></dependencies></change>">]>

<?change <change><functionalChange><![CDATA[ghjgj]]></functionalChange><test><![CDATA[]]></test><testNotes><![CDATA[]]></testNotes><dependencies><![CDATA[]]></dependencies></change>?>

<XMLBlock>

<someText>Lorem ipsum dolor sit amet, consetetur ...</someText>

</XMLBlock>

-------------->8-------------------------

 

The xslt

--------------8<-------------------------

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

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:saxon="http://saxon.sf.net/" version="2.0">

  <xsl:template match ="/">

    <xsl:variable name="change"><xsl:value-of select="processing-instruction('change')" disable-output-escaping="yes"/></xsl:variable>

    <xsl:variable name="ch2"><xsl:copy-of select="saxon:parse($change)" /></xsl:variable>

    <aaa>

       <xsl:for-each select="saxon:unparsed-entities(.)" >

         <xsl:copy-of select="." />

       </xsl:for-each>

      <bbb>

        <xsl:copy-of select="$ch2/change/functionalChange/text()" />

      </bbb>

    </aaa>

  </xsl:template>

</xsl:stylesheet>

-------------->8-------------------------

 

Thanks for your help. ( … saxon:parse works fine! )
Kind regards

Markus Sticker


 

------------------------------------------------------------------------------
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help

 


------------------------------------------------------------------------------

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help