标签云

微信群

扫码加入我们

WeChat QR Code

I have the XML below and I would like to filter the XML using XSLT to seprate CompanyType based on IsBusiness <CompanyTypes><CompanyType> <CompanyTypeID>1</CompanyTypeID> <CompanyTypeName>Individual</CompanyTypeName> <CompanyTypeDesc>Individual</CompanyTypeDesc> <IsBusiness>N</IsBusiness></CompanyType><CompanyType> <CompanyTypeID>2</CompanyTypeID> <CompanyTypeName>Proprietorship</CompanyTypeName> <CompanyTypeDesc>Proprietorship</CompanyTypeDesc> <IsBusiness>N</IsBusiness></CompanyType><CompanyType> <CompanyTypeID>3</CompanyTypeID> <CompanyTypeName>Trust Irrevocable</CompanyTypeName> <CompanyTypeDesc>Irrevocable Trust</CompanyTypeDesc> <IsBusiness>N</IsBusiness></CompanyType><CompanyType> <CompanyTypeID>4</CompanyTypeID> <CompanyTypeName>Trust Revocable</CompanyTypeName> <CompanyTypeDesc>Revocable Trust</CompanyTypeDesc> <IsBusiness>N</IsBusiness></CompanyType><CompanyType> <CompanyTypeID>5</CompanyTypeID> <CompanyTypeName>Association</CompanyTypeName> <CompanyTypeDesc>Association</CompanyTypeDesc> <IsBusiness>Y</IsBusiness></CompanyType></CompanyTypes>I would like to get all the IsBusiness = N in <CompanyTypesIndividual><CompanyType> <CompanyTypeID>3</CompanyTypeID> <CompanyTypeName>Trust Irrevocable</CompanyTypeName> <CompanyTypeDesc>Irrevocable Trust</CompanyTypeDesc> <IsBusiness>N</IsBusiness></CompanyType> <CompanyType> <CompanyTypeID>4</CompanyTypeID> <CompanyTypeName>Trust Revocable</CompanyTypeName> <CompanyTypeDesc>Revocable Trust</CompanyTypeDesc> <IsBusiness>N</IsBusiness></CompanyType></CompanyTypesIndividual>and ISBusiness = Y<CompanyTypesBusiness><CompanyType> <CompanyTypeID>3</CompanyTypeID> <CompanyTypeName>Trust Irrevocable</CompanyTypeName> <CompanyTypeDesc>Irrevocable Trust</CompanyTypeDesc> <IsBusiness>Y</IsBusiness></CompanyType><CompanyType> <CompanyTypeID>3</CompanyTypeID> <CompanyTypeName>Trust Irrevocable</CompanyTypeName> <CompanyTypeDesc>Irrevocable Trust</CompanyTypeDesc> <IsBusiness>Y</IsBusiness></CompanyType></CompanyTypesBusiness>Really appreciate your feedback


Do you mean you want to have two output documents as a result of a single transformation? That's not possible in XSLT 1.0 (unless your processor supports an extension to enable such thing).

2019年04月20日22分33秒

Hi Michael, I don't need two documents as an ouput, I need to map the result as shown in my example into two new nodes. <CompanyTypesBusiness> and <CompanyTypesIndividual> based on the IsBusiness Value

2019年04月19日22分33秒

That should be very easy. For example, you could use xsl:copy-of with the expression suggested by Lingamurthy CS.

2019年04月20日22分33秒

Your result is not XML.

2019年04月20日22分33秒

Really appreciate it matthias_h

2019年04月19日22分33秒

michael.hor257k Thanks for mentioning, updated in answer.

2019年04月19日22分33秒

I can't use XPath. When I use XPath its returning the first instance only, because the application is using Xpath version 1.0.

2019年04月20日22分33秒

I really appreciate your feedback.

2019年04月19日22分33秒

SherifAbdelzaher even in version 1.0 the xpath to select all would be the one I've mentioned, but the way you use it is that matters. If you use xsl:copy-of, xsl:for-each, or xsl:apply-templates this would work fine, but when xsl:value-of is used only first value is presented.

2019年04月20日22分33秒