[no subject]

<xsl:template match="*[not(*)]">

where he said:

"Yes, kind of, it matches any element node not having element node children."

I think that I NOW need something like:

"it matches any element node not having element node children AND having
parent element named "adrRecord"

Is that correct?

However, I am struggling with how to express that in XSLT :(...

I've tried something like:

<xsl:template match="*[not(*)] and name(..)='adrRecord'">

but when I try that, it is complaining that

"Unable to save: The XSL is missing or invalid. Element type "saml:Attribute"
must be followed by either attribute specifications, ">" or "/>".

Can some tell me how to accomplish this?

Thanks,
Jim
     On Thursday, February 16, 2023, 09:51:57 AM EST, ohaya ohaya@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

  Hi,

It turns out that the incoming XML is slightly different than what I posted
originally. It has some nodes before the "adrRecord" node, and the XSLT is
picking up elements from inside those other nodes but we only want to produce
attributes from inside/under the "adrRecord". So here's an example of the XML
now:

record>
 <rule>
 <customer>1234</customer>
 <schemaName>schema_name</schemaName>
 <schemaVersion>1.0</schemaVersion>
 </rule>
 <identifier>
 <PN_ID>1111111111</PN_ID>
 </identifier>
 <adrRecord>
 <PN_ID>1111111</PN_ID>
 <personnel>
 <ADM_ORG_CD>urn:NORM:DEPT</ADM_ORG_CD>
 <DOD_ASSOC_CD>urn:NORM:V01</DOD_ASSOC_CD>
 </personnel>
 <enterpriseUser>
 <entUserRoles>a:b:c</entUserRoles>
 </enterpriseUser>
 </adrRecord>
</record>

and we only want output of the ones under/inside the <adrRecord>.

How can I modify the XSLT:

<xsl:stylesheet exclude-result-prefixes="xs" version="2.0"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

 <xsl:output indent="yes"/>

 <xsl:template match="*">
 <xsl:apply-templates/>
 </xsl:template>

 <xsl:template match="text()"/>

 <xsl:template match="/">
 <saml:AttributeStatement>
 <xsl:apply-templates/>
 </saml:AttributeStatement>
 </xsl:template>

 <xsl:template match="*[not(*)]">
 <saml:Attribute Name="{name()}"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
 <xsl:for-each select="tokenize(.,':')">
 <saml:AttributeValue xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xsi:type="xsd:string">
 <xsl:value-of select="."/>
 </saml:AttributeValue>
 </xsl:for-each>
 </saml:Attribute>
 </xsl:template>

</xsl:stylesheet>

to do that?

I have tried changing:

 <xsl:template match="/">
 <saml:AttributeStatement>
 <xsl:apply-templates/>
 </saml:AttributeStatement>
 </xsl:template>

to:

 <xsl:template match="//adrRecord">
 <saml:AttributeStatement>
 <xsl:apply-templates/>
 </saml:AttributeStatement>
 </xsl:template>


but when I do that the output is missing the surrounding
<saml:AttributeStatement>.

Thanks,
Jim
     On Sunday, January 22, 2023, 08:54:51 AM EST, Eliot Kimber
eliot.kimber@xxxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

 #yiv3354467305 filtered {}#yiv3354467305 filtered {}#yiv3354467305 filtered
{}#yiv3354467305 filtered {}#yiv3354467305 p.yiv3354467305MsoNormal,
#yiv3354467305 li.yiv3354467305MsoNormal, #yiv3354467305
div.yiv3354467305MsoNormal
{margin:0in;font-size:10.0pt;font-family:sans-serif;}#yiv3354467305 h3
{margin-right:0in;margin-left:0in;font-size:13.5pt;font-family:sans-serif;}#y
iv3354467305 a:link, #yiv3354467305 span.yiv3354467305MsoHyperlink
{color:blue;text-decoration:underline;}#yiv3354467305
span.yiv3354467305Heading3Char
{font-family:sans-serif;color:#1F3763;}#yiv3354467305
span.yiv3354467305EmailStyle20
{font-family:sans-serif;color:windowtext;}#yiv3354467305
.yiv3354467305MsoChpDefault {font-size:10.0pt;}#yiv3354467305 filtered
{}#yiv3354467305 div.yiv3354467305WordSection1 {}
I would write not(*) as empty(*) but it means the same thing:

 B 

<xsl:template match=b*[empty(*)]b>

Cheers,

 B 

E.

 B 

_____________________________________________

Eliot Kimber

Sr Staff Content Engineer

O: 512 554 9368

M: 512 554 9368

servicenow.com

LinkedInB |B TwitterB |B YouTubeB |B Facebook

 B 

From:BR Chrisman brchrisman@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sunday, January 22, 2023 at 1:43 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: New XSLT NOT WORKING was Re: [xsl] XSLT to populate a SAML
AttributeStatement from an XML

[External Email]

 B 

It will match anB element that has no child elements.

 B 

On Sat, Jan 21, 2023 at 11:19 PM ohayaohaya@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:


Hi,

I was wondering if someone could explain what:

<xsl:template match="*[not(*)]">

does?

Is that not(*) checking for non-empty nodes?

Thanks,
Jim



On Saturday, January 21, 2023, 05:00:18 AM EST, Martin
Honnenmartin.honnen@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

 B 

 B 


Am 1/21/2023 um 10:02 AM schrieb ohaya ohaya@xxxxxxxxx:
> Hi,
>
> I was wondering, is it possible to add a condition to this:
>
> <xsl:template match="/record/adrRecord/*">
>
> for only if the node has no value?
>
> If it is possible, how to do that, and also do you all think this
> would fix the problem that is happening?


I am wondering if the input sample


<record>
<adrRecord>
<PN_ID>1111111</PN_ID>
<personnel>
<ADM_ORG_CD>urn:NORM:DEPT</ADM_ORG_CD>
<DOD_ASSOC_CD>urn:NORM:V01</DOD_ASSOC_CD>
</personnel>
<enterpriseUser>
<entUserRoles>a:b:c</entUserRoles>
</enterpriseUser>
</adrRecord>
</record>


transformed by e.g.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
B  version="2.0"
B  xmlns:xs="http://www.w3.org/2001/XMLSchema";
B  xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
B  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
B  exclude-result-prefixes="xs">

B  <xsl:output indent="yes"/>

B  <xsl:template match="*">
B B B  <xsl:apply-templates/>
B  </xsl:template>

B  <xsl:template match="text()"/>

B  <xsl:template match="/">
B B B  <saml:AttributeStatement>
B B B B B  <xsl:apply-templates/>
B B B  </saml:AttributeStatement>
B  </xsl:template>

B  <xsl:template match="*[not(*)]">
B B B  <saml:Attribute Name="{name()}"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
B B B B B  <xsl:for-each select="tokenize(.,':')">
B B B B B B B  <saml:AttributeValue
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xsi:type="xsd:string">
B B B B B B B B B  <xsl:value-of select="."/>
B B B B B B B  </saml:AttributeValue>
B B B B B  </xsl:for-each>
B B B  </saml:Attribute>
B  </xsl:template>

</xsl:stylesheet>


into e.g.

<saml:AttributeStatement
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
B B  <saml:Attribute Name="PN_ID"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
B B B B B  <saml:AttributeValue
xsi:type="xsd:string">1111111</saml:AttributeValue>
B B  </saml:Attribute>
B B  <saml:Attribute Name="ADM_ORG_CD"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
B B B B B  <saml:AttributeValue
xsi:type="xsd:string">urn</saml:AttributeValue>
B B B B B  <saml:AttributeValue
xsi:type="xsd:string">NORM</saml:AttributeValue>
B B B B B  <saml:AttributeValue
xsi:type="xsd:string">DEPT</saml:AttributeValue>
B B  </saml:Attribute>
B B  <saml:Attribute Name="DOD_ASSOC_CD"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
B B B B B  <saml:AttributeValue
xsi:type="xsd:string">urn</saml:AttributeValue>
B B B B B  <saml:AttributeValue
xsi:type="xsd:string">NORM</saml:AttributeValue>
B B B B B  <saml:AttributeValue
xsi:type="xsd:string">V01</saml:AttributeValue>
B B  </saml:Attribute>
B B  <saml:Attribute Name="entUserRoles"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
B B B B B  <saml:AttributeValue xsi:type="xsd:string">a</saml:AttributeValue>
B B B B B  <saml:AttributeValue xsi:type="xsd:string">b</saml:AttributeValue>
B B B B B  <saml:AttributeValue xsi:type="xsd:string">c</saml:AttributeValue>
B B  </saml:Attribute>
</saml:AttributeStatement>

is perhaps all you want to output?


But with so many posts I have lost track of what the input is and what
the wanted output is.



XSL-List info and archive

EasyUnsubscribe (by email)


XSL-List info and archive

EasyUnsubscribe (by email)
 XSL-List info and archiveEasyUnsubscribe(by email)  XSL-List info and
archiveEasyUnsubscribe(by email)

Current Thread