Subject: Re: [xsl] Json to xml From: "dvint dvint@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 14 Mar 2025 18:50:35 -0000 |
It is only processing one document, but the format is changing based upon the fact it is taken through the json-to-xml() which then changes how it us processed. Is there someway to get the json-to-xml() to be run before anything else starts?..danSent from my Verizon, Samsung Galaxy smartphone -------- Original message --------From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: 3/14/25 10:27 AM (GMT-08:00) To: xsl-list <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Cc: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Subject: Re: [xsl] Json to xml A global variable is always evaluated with the principal source document as the context item.If you're running with multiple documents, e.g. a multi-phase transformation, then it's best to avoid relying on this and instead always use global variables to refer to each document explicitly.Michael KaySaxonica> On 14 Mar 2025, at 17:20, dvint@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:> > In trying to build a small sample I have found where the problem is coming from. It looks like this might be a timing issue of when the stylesheet is read vs when the json-to-sml() file is triggered and that XML becomes available to evaluate.> > At the top of the included XSLT is this> > <!-- Remeber thsi content to lookup details laterB -->> <xsl:variable name="PROPERTIES" select="/j:map/j:map[@key='properties']"/>> > I use this value to lookup details that are linked to much further down and deeply nested. This works prefectly when using this XSLT standalone with the generated XML file.> > I'm guessing what happens when it is included in the main XSLT, that this variable is being set based upon the JSON file that the main XSLT is called with.> > In the main XSLT, I moved this declaration out of the template so the variable is global:> > <xsl:variable name="MAPFILE" select="json-to-xml(., map { 'escape' : true() })"/>> > I then modified the PROPERTIES variable to use $MAPFILE and it now works.> > <!-- Remeber thsi content to lookup details laterB -->> <xsl:variable name="PROPERTIES" select="$MAPFILE/j:map/j:map[@key='properties']"/>> > BUT it is now no longer possible to run the second stylesheet standalone.> > So, I've found the problem and need to find a better way to capture this information.> > ..dan> > > On 2025-03-13 23:55, Martin Honnen martin.honnen@xxxxxx wrote:>> On 13/03/2025 19:25, dvint@xxxxxxxxx wrote:>>> I'll try and see if I can make a small sample JSON and associated>>> included XSLT.>> Please do that, I couldn't see any obviuous mistakes in the code you posted.> >
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Json to xml, Michael Kay michaelk | Thread | Re: [xsl] Json to xml, dvint@xxxxxxxxx |
Re: [xsl] Json to xml, dvint@xxxxxxxxx | Date | Re: [xsl] Json to xml, Martin Honnen martin |
Month |