Re: [xslt] Parse stylesheet from a string (in memory) instead of from a file?

2021-11-18 Thread Liam R E Quin
On Thu, 2021-11-18 at 18:34 +, Bloomquist, Leif via xslt wrote:
> 
> 
> xmlDocPtr temp = xmlParseMemory(mystring, (int)strlen(mystring)); 
> xsltStylesheetPtr xsl = xsltParseStylesheetDoc(temp);
> 
If your stylesheet uses xsl:import or xsl:include, or your XML document
tries to include fragments using XInclude  or entities, you'll also
need to write a resolver, i think.

-- 
Liam Quin, Paligo AB
https://www.delightfulcomputing.com/
http://www.fromoldbooks.org

___
xslt mailing list, project page http://xmlsoft.org/XSLT/
xslt@gnome.org
https://mail.gnome.org/mailman/listinfo/xslt


Re: [xslt] Parse stylesheet from a string (in memory) instead of from a file?

2021-11-18 Thread Bloomquist, Leif via xslt
Hi Christian,

> I had to solve this once before. My solution had then several step:
> - use xmlReadMemory from libxml2 to read the XML from memory. this creates an 
> xmlDocPtr
> - use xmlDocGetRootElement to get the root xmlNodePtr
> - use xsltParseStylesheetDoc from libxslt to create the xsltStylesheetPtr
> - use xsltApplyStylesheet with the the stylesheet and an xmlDocPtr to convert.

Thank you for the reply!  My colleague actually found a post from 2002 with a 
slightly simpler solution:

https://mail.gnome.org/archives/xslt/2002-January/msg00080.html

So this reduces the solution to two steps (although there should also be an 
intermediate check that temp isn't NULL)

xmlDocPtr temp = xmlParseMemory(mystring, (int)strlen(mystring)); 
xsltStylesheetPtr xsl = xsltParseStylesheetDoc(temp);

From there I can use xsltApplyStylesheet as before, and this approach works 
perfectly for my use case.

Cheers
-Leif


___
xslt mailing list, project page http://xmlsoft.org/XSLT/
xslt@gnome.org
https://mail.gnome.org/mailman/listinfo/xslt


Re: [xslt] Parse stylesheet from a string (in memory) instead of from a file?

2021-11-18 Thread Christian Ceelen via xslt
Hi Leif,

I had to solve this once before. My solution had then several step:
- use xmlReadMemory from libxml2 to read the XML from memory. this creates
an xmlDocPtr
- use xmlDocGetRootElement to get the root xmlNodePtr
- use xsltParseStylesheetDoc from libxslt to create the xsltStylesheetPtr
- use xsltApplyStylesheet with the the stylesheet and an xmlDocPtr to
convert.

This worked quite well in my case.

Best regards,
Christian

On Wed, Nov 17, 2021 at 6:44 PM Bloomquist, Leif via xslt 
wrote:

> Hi all,
>
>
>
> I’m porting an application that uses libxml/libxslt to an embedded
> platform that has no filesystem.
>
>
>
> Accordingly, I’m trying to find (and hopefully not have to write) an
> equivalent to xsltParseStylesheetFile() that accepts a string
> representation of the stylesheet, instead of a filename/URI pointing to
> it.  Coming up blank.
>
>
>
> For the schema file, I was able to simply replace xmlSchemaNewParserCtxt()
> with xmlSchemaNewMemParserCtxt() – is there an equivalent in libxslt that
> I’m overlooking?
>
>
>
> I’m also willing to accept that there is a better approach that I haven’t
> considered : - )
>
>
>
> Any help appreciated.
>
>
>
> Thanks
>
> -Leif
>
> The information transmitted by and/or attached to this email is intended
> only for the person or entity to which it is addressed. This email and any
> attachments may contain proprietary, confidential and/or privileged
> material. If you are not the intended recipient of this message, be aware
> that any use, review, retransmission, distribution, reproduction or any
> action taken in reliance upon this message is strictly prohibited. If you
> received this in error, please contact the sender and delete the material
> from all computers.
>
> Les renseignements transmis par ou joints au présent courrier électronique
> sont destinés uniquement à la personne ou à l'entité à laquelle ils sont
> adressés. Le présent courrier électronique et toute pièce jointe peuvent
> contenir des renseignements exclusifs, confidentiels ou privilégiés. Si
> vous n'êtes pas le destinataire de ce message, veuillez noter que toute
> utilisation, révision, retransmission, distribution, reproduction ou toute
> action entreprise sur la base de ce message est strictement interdite. Si
> vous avez reçu ce message par erreur, veuillez communiquer avec
> l'expéditeur et supprimer le contenu de tous les ordinateurs.
> ___
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt@gnome.org
> https://mail.gnome.org/mailman/listinfo/xslt
>
___
xslt mailing list, project page http://xmlsoft.org/XSLT/
xslt@gnome.org
https://mail.gnome.org/mailman/listinfo/xslt


[xslt] Parse stylesheet from a string (in memory) instead of from a file?

2021-11-17 Thread Bloomquist, Leif via xslt
Hi all,

I'm porting an application that uses libxml/libxslt to an embedded platform 
that has no filesystem.

Accordingly, I'm trying to find (and hopefully not have to write) an equivalent 
to xsltParseStylesheetFile() that accepts a string representation of the 
stylesheet, instead of a filename/URI pointing to it.  Coming up blank.

For the schema file, I was able to simply replace xmlSchemaNewParserCtxt() with 
xmlSchemaNewMemParserCtxt() - is there an equivalent in libxslt that I'm 
overlooking?

I'm also willing to accept that there is a better approach that I haven't 
considered : - )

Any help appreciated.

Thanks
-Leif

The information transmitted by and/or attached to this email is intended only 
for the person or entity to which it is addressed. This email and any 
attachments may contain proprietary, confidential and/or privileged material. 
If you are not the intended recipient of this message, be aware that any use, 
review, retransmission, distribution, reproduction or any action taken in 
reliance upon this message is strictly prohibited. If you received this in 
error, please contact the sender and delete the material from all computers.

Les renseignements transmis par ou joints au pr?sent courrier ?lectronique sont 
destin?s uniquement ? la personne ou ? l'entit? ? laquelle ils sont adress?s. 
Le pr?sent courrier ?lectronique et toute pi?ce jointe peuvent contenir des 
renseignements exclusifs, confidentiels ou privil?gi?s. Si vous n'?tes pas le 
destinataire de ce message, veuillez noter que toute utilisation, r?vision, 
retransmission, distribution, reproduction ou toute action entreprise sur la 
base de ce message est strictement interdite. Si vous avez re?u ce message par 
erreur, veuillez communiquer avec l'exp?diteur et supprimer le contenu de tous 
les ordinateurs.
___
xslt mailing list, project page http://xmlsoft.org/XSLT/
xslt@gnome.org
https://mail.gnome.org/mailman/listinfo/xslt